/[ascend]/trunk/base/generic/compiler/instantiate.c
ViewVC logotype

Diff of /trunk/base/generic/compiler/instantiate.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 183 by johnpye, Fri Jan 13 02:35:00 2006 UTC revision 373 by johnpye, Tue Mar 14 08:39:37 2006 UTC
# Line 147  or symbol values in each of the CASEs Line 147  or symbol values in each of the CASEs
147  /*  /*
148   * Variables to switch old and new pass 2 instantiation.   * Variables to switch old and new pass 2 instantiation.
149   * The condition for using new pass 2 (anonymous type-based   * The condition for using new pass 2 (anonymous type-based
150   * relation copying) is g_use_copyanon != 0   * relation copying) is g_use_copyanon != 0
151   * || FORCE applied.   * || FORCE applied.
152   */   */
153    
154  int g_use_copyanon = 1;  int g_use_copyanon = 1;
155  /* g_use_copyanon is the user switch for anonymous type based relation  /* g_use_copyanon is the user switch for anonymous type based relation
156   * copying. if 0, no copying by that method is done.   * copying. if 0, no copying by that method is done.
157   */   */
158    
159  #if TIMECOMPILER  #if TIMECOMPILER
# Line 395  int CalcSetType(symchar *c, struct State Line 395  int CalcSetType(symchar *c, struct State
395   * probably should check constantness too but does not.   * probably should check constantness too but does not.
396   * return 0 if ok, 1 if not.   * return 0 if ok, 1 if not.
397   */   */
398  static  static
399  int CheckSetVal(struct value_t setval)  int CheckSetVal(struct value_t setval)
400  {  {
401    if (ValueKind(setval) != set_value) {    if (ValueKind(setval) != set_value) {
# Line 519  void SignalChildExpansionFailure(struct Line 519  void SignalChildExpansionFailure(struct
519    }    }
520    if (StatInFOR(statement)) {    if (StatInFOR(statement)) {
521      MarkStatContext(statement,context_WRONG);      MarkStatContext(statement,context_WRONG);
522      WSEM(ASCERR,statement, "Add another FOR index. In FOR loops,"      WSEM(ASCERR,statement, "Add another FOR index. In FOR loops,"
523           " all array subscripts must be scalar values, not sets.");           " all array subscripts must be scalar values, not sets.");
524      WSS(ASCERR,statement);      WSS(ASCERR,statement);
525    } else {    } else {
526      MarkStatContext(statement,context_WRONG);      MarkStatContext(statement,context_WRONG);
527      WSEM(ASCERR,statement, "Subscripts of conflicting or incorrect types"      WSEM(ASCERR,statement, "Subscripts of conflicting or incorrect types"
528           " in rectangular array.");           " in rectangular array.");
529      WSS(ASCERR,statement);      WSS(ASCERR,statement);
530    }    }
# Line 1757  struct Instance *MakeSimpleInstance(stru Line 1757  struct Instance *MakeSimpleInstance(stru
1757        break;        break;
1758      case relation_type:      case relation_type:
1759        inst = NULL;        inst = NULL;
1760        FPRINTF(ASCERR,"Type '%s' is not allowed in IS_A.\n",        FPRINTF(ASCERR,"Type '%s' is not allowed in IS_A.\n",
1761                SCP(GetBaseTypeName(relation_type)));                SCP(GetBaseTypeName(relation_type)));
1762      case logrel_type:      case logrel_type:
1763        inst = NULL;        inst = NULL;
# Line 1907  int ArrayElementsTypeCompatible(CONST st Line 1907  int ArrayElementsTypeCompatible(CONST st
1907      if (InstanceKind(i) == SET_ATOM_INST) {      if (InstanceKind(i) == SET_ATOM_INST) {
1908        /* both should be of same type "set" */        /* both should be of same type "set" */
1909        if (atype!=ptype ||        if (atype!=ptype ||
1910            (IntegerSetInstance(i)==0 &&            (IntegerSetInstance(i)==0 &&
1911             stype == GetBaseTypeName(integer_constant_type))             stype == GetBaseTypeName(integer_constant_type))
1912            || (IntegerSetInstance(i)==1 &&            || (IntegerSetInstance(i)==1 &&
1913                stype == GetBaseTypeName(symbol_constant_type))                stype == GetBaseTypeName(symbol_constant_type))
1914           ) {           ) {
1915          /* set type mismatch */          /* set type mismatch */
# Line 3866  void MakeInstance(CONST struct Name *nam Line 3866  void MakeInstance(CONST struct Name *nam
3866    struct TypeDescription *arydef;    struct TypeDescription *arydef;
3867    struct gl_list_t *indices;    struct gl_list_t *indices;
3868    int tce;    int tce;
3869      /*char *nstr;
3870      nstr = WriteNameString(name);
3871      CONSOLE_DEBUG(nstr);
3872      ascfree(nstr); */
3873    if ((childname = SimpleNameIdPtr(name))!=NULL){ /* simple 1 element name */    if ((childname = SimpleNameIdPtr(name))!=NULL){ /* simple 1 element name */
3874      if (StatInFOR(statement) && StatWrong(statement)==0) {      if (StatInFOR(statement) && StatWrong(statement)==0) {
3875        MarkStatContext(statement,context_WRONG);        MarkStatContext(statement,context_WRONG);
# Line 4230  void MissingInsts(struct Instance *inst, Line 4234  void MissingInsts(struct Instance *inst,
4234      while(list!=NULL){      while(list!=NULL){
4235        temp = FindInstances(inst,NamePointer(list),&err);        temp = FindInstances(inst,NamePointer(list),&err);
4236        if (temp==NULL){        if (temp==NULL){
4237          error_reporter_start(ASC_USER_ERROR,NULL,0);          ERROR_REPORTER_START_NOLINE(ASC_USER_ERROR);
4238          FPRINTF(ASCERR,"Problem finding instance(s): \n");          FPRINTF(ASCERR,"Problem finding instance(s): \n");
4239          WriteName(ASCERR,NamePointer(list));          WriteName(ASCERR,NamePointer(list));
4240          FPRINTF(ASCERR,"\n");          FPRINTF(ASCERR,"\n");
# Line 4648  struct Instance *MakeRelationInstance(st Line 4652  struct Instance *MakeRelationInstance(st
4652                                        struct Statement *stat,                                        struct Statement *stat,
4653                                        enum Expr_enum type)                                        enum Expr_enum type)
4654  {  {
4655      CONSOLE_DEBUG("...");
4656    symchar *childname;    symchar *childname;
4657    struct Instance *child;    struct Instance *child;
4658    struct InstanceName rec;    struct InstanceName rec;
# Line 4675  struct Instance *MakeRelationInstance(st Line 4680  struct Instance *MakeRelationInstance(st
4680        if (InstanceChild(parent,pos)==NULL){        if (InstanceChild(parent,pos)==NULL){
4681          /* must make array */          /* must make array */
4682          child = MakeSparseArray(parent,name,stat,NULL,0,NULL,NULL,NULL);          child = MakeSparseArray(parent,name,stat,NULL,0,NULL,NULL,NULL);
4683        } else {          } else {
4684          /* must add array element */          /* must add array element */
4685          child = AddArrayChild(parent,name,stat,NULL,NULL,NULL);          child = AddArrayChild(parent,name,stat,NULL,NULL,NULL);
4686        }        }
# Line 4795  int ExecuteREL(struct Instance *inst, st Line 4800  int ExecuteREL(struct Instance *inst, st
4800                       "Unmade or Undefined instances in relation",3);                       "Unmade or Undefined instances in relation",3);
4801            return 1;            return 1;
4802          case impossible_instance:          case impossible_instance:
4803            WSSM(ASCERR,statement,            WSSM(ASCERR,statement,
4804                       "Relation contains an impossible instance",3);                       "Relation contains an impossible instance",3);
4805            return 1;            return 1;
4806          case correct_instance:          case correct_instance:
# Line 5530  int CheckGlassBoxIndex(struct Instance * Line 5535  int CheckGlassBoxIndex(struct Instance *
5535    
5536    str = SimpleNameIdPtr(n);    str = SimpleNameIdPtr(n);
5537    if (str) {    if (str) {
5538      result = atoi(SCP(str));    /* convert to integer. fixme strtod */      result = atoi(SCP(str));    /* convert to integer. FIXME strtod */
5539      *err = okay;      *err = okay;
5540      return result;      return result;
5541    }    }
# Line 5657  int ExecuteEXT(struct Instance *inst, st Line 5662  int ExecuteEXT(struct Instance *inst, st
5662  {  {
5663    int mode;    int mode;
5664    
5665      CONSOLE_DEBUG("...");
5666    
5667    mode = ExternalStatMode(statement);    mode = ExternalStatMode(statement);
5668    switch(mode) {    switch(mode) {
5669    default:    default:
# Line 6017  static Line 6024  static
6024  int NameContainsName(CONST struct Name *n,CONST struct Name *sub)  int NameContainsName(CONST struct Name *n,CONST struct Name *sub)
6025  {  {
6026    struct gl_list_t *nl;    struct gl_list_t *nl;
6027    unsigned long c,len;                      unsigned long c,len;
6028    struct Expr *en;    struct Expr *en;
6029    
6030    assert(n!=NULL);    assert(n!=NULL);
# Line 6713  int CheckRelModName(struct Instance *wor Line 6720  int CheckRelModName(struct Instance *wor
6720       }       }
6721      }      }
6722      else {      else {
6723      FPRINTF(ASCERR,"\n");            FPRINTF(ASCERR,"\n");
6724      FPRINTF(ASCERR,      FPRINTF(ASCERR,
6725      "Error in WHEN statement. Name assigned to more than one %s \n",      "Error in WHEN statement. Name assigned to more than one %s \n",
6726      "instance type:");      "instance type:");
# Line 6988  int CheckWhenSetNode(struct Instance *re Line 6995  int CheckWhenSetNode(struct Instance *re
6995      FPRINTF(ASCERR,"Innapropriate value type in the list of %s\n",      FPRINTF(ASCERR,"Innapropriate value type in the list of %s\n",
6996          "values of a CASE of a WHEN statement");          "values of a CASE of a WHEN statement");
6997      FPRINTF(ASCERR,"Only symbols or integers and booleans are allowed\n");      FPRINTF(ASCERR,"Only symbols or integers and booleans are allowed\n");
6998      FPRINTF(ASCERR,"\n");          FPRINTF(ASCERR,"\n");
6999      return 0;      return 0;
7000    }    }
7001  }  }
# Line 7029  int CheckWhenVariableNode(struct Instanc Line 7036  int CheckWhenVariableNode(struct Instanc
7036        FPRINTF(ASCERR,"\n");        FPRINTF(ASCERR,"\n");
7037        FPRINTF(ASCERR,"Innapropriate index in the list of %s\n",        FPRINTF(ASCERR,"Innapropriate index in the list of %s\n",
7038            "variables of a WHEN statement");            "variables of a WHEN statement");
7039        FPRINTF(ASCERR,"only symbol or integer allowed\n");              FPRINTF(ASCERR,"only symbol or integer allowed\n");
7040        FPRINTF(ASCERR,"\n");        FPRINTF(ASCERR,"\n");
7041        return 0;        return 0;
7042      }      }
# Line 7108  int CheckWhenVariableNode(struct Instanc Line 7115  int CheckWhenVariableNode(struct Instanc
7115          FPRINTF(ASCERR,"\n");          FPRINTF(ASCERR,"\n");
7116          FPRINTF(ASCERR,"Inappropriate instance in the list of %s\n",          FPRINTF(ASCERR,"Inappropriate instance in the list of %s\n",
7117          "variables of a WHEN statement");          "variables of a WHEN statement");
7118          FPRINTF(ASCERR,"Only boolean, integer and symbols are allowed\n");          FPRINTF(ASCERR,"Only boolean, integer and symbols are allowed\n");
7119          WriteName(ASCERR,name);          WriteName(ASCERR,name);
7120          FPRINTF(ASCERR,"\n");            FPRINTF(ASCERR,"\n");
7121      return 0;      return 0;
7122        }        }
7123      } else {      } else {
# Line 7118  int CheckWhenVariableNode(struct Instanc Line 7125  int CheckWhenVariableNode(struct Instanc
7125        FPRINTF(ASCERR,"\n");        FPRINTF(ASCERR,"\n");
7126        FPRINTF(ASCERR,"Inappropriate instance in the list of %s\n",        FPRINTF(ASCERR,"Inappropriate instance in the list of %s\n",
7127            "variables of a WHEN statement");            "variables of a WHEN statement");
7128        FPRINTF(ASCERR,"Multiple instances of\n");        FPRINTF(ASCERR,"Multiple instances of\n");
7129        WriteName(ASCERR,name);        WriteName(ASCERR,name);
7130        FPRINTF(ASCERR,"\n");        FPRINTF(ASCERR,"\n");
7131        return 0;        return 0;
7132      }      }
7133    }    }
# Line 7260  int CheckWHEN(struct Instance *inst, str Line 7267  int CheckWHEN(struct Instance *inst, str
7267      WriteInstanceName(ASCERR,inst,NULL);      WriteInstanceName(ASCERR,inst,NULL);
7268      FPRINTF(ASCERR,"\n");      FPRINTF(ASCERR,"\n");
7269      WSEM(ASCERR,statement,"The following statement will not be executed: \n");      WSEM(ASCERR,statement,"The following statement will not be executed: \n");
7270      FPRINTF(ASCERR,"\n");        FPRINTF(ASCERR,"\n");
7271        return 0;        return 0;
7272      }      }
7273      if ( CheckWhenName(inst,wname) == -1) return 1;      if ( CheckWhenName(inst,wname) == -1) return 1;
# Line 7275  int CheckWHEN(struct Instance *inst, str Line 7282  int CheckWHEN(struct Instance *inst, str
7282      FPRINTF(ASCERR,"In ");      FPRINTF(ASCERR,"In ");
7283      WriteInstanceName(ASCERR,inst,NULL);      WriteInstanceName(ASCERR,inst,NULL);
7284      WSEM(ASCERR,statement," the following statement will not be executed:\n");      WSEM(ASCERR,statement," the following statement will not be executed:\n");
7285      FPRINTF(ASCERR,"\n");          FPRINTF(ASCERR,"\n");
7286      return 0;      return 0;
7287    }    }
7288    w1 = WhenStatCases(statement);    w1 = WhenStatCases(statement);
# Line 7291  int CheckWHEN(struct Instance *inst, str Line 7298  int CheckWHEN(struct Instance *inst, str
7298              WriteInstanceName(ASCERR,inst,NULL);              WriteInstanceName(ASCERR,inst,NULL);
7299              WSEM(ASCERR,statement,              WSEM(ASCERR,statement,
7300           " the following statement will not be executed: \n");           " the following statement will not be executed: \n");
7301              FPRINTF(ASCERR,"\n");                  FPRINTF(ASCERR,"\n");
7302          return 0;          return 0;
7303        }        }
7304            if (!CheckWhenSetList(inst,s,p2)) {            if (!CheckWhenSetList(inst,s,p2)) {
# Line 7300  int CheckWHEN(struct Instance *inst, str Line 7307  int CheckWHEN(struct Instance *inst, str
7307              WriteInstanceName(ASCERR,inst,NULL);              WriteInstanceName(ASCERR,inst,NULL);
7308              WSEM(ASCERR,statement,              WSEM(ASCERR,statement,
7309           " the following statement will not be executed: \n");           " the following statement will not be executed: \n");
7310              FPRINTF(ASCERR,"\n");                  FPRINTF(ASCERR,"\n");
7311          return 0;          return 0;
7312        }        }
7313            p1 = &vl[0];            p1 = &vl[0];
# Line 7313  int CheckWHEN(struct Instance *inst, str Line 7320  int CheckWHEN(struct Instance *inst, str
7320              WriteInstanceName(ASCERR,inst,NULL);              WriteInstanceName(ASCERR,inst,NULL);
7321              WSEM(ASCERR,statement,              WSEM(ASCERR,statement,
7322           " the following statement will not be executed: \n");           " the following statement will not be executed: \n");
7323              FPRINTF(ASCERR,"\n");                  FPRINTF(ASCERR,"\n");
7324          return 0;          return 0;
7325        }        }
7326        }        }
# Line 7326  int CheckWHEN(struct Instance *inst, str Line 7333  int CheckWHEN(struct Instance *inst, str
7333              WriteInstanceName(ASCERR,inst,NULL);              WriteInstanceName(ASCERR,inst,NULL);
7334              WSEM(ASCERR,statement,              WSEM(ASCERR,statement,
7335           " the following statement will not be executed: \n");           " the following statement will not be executed: \n");
7336              FPRINTF(ASCERR,"\n");                    FPRINTF(ASCERR,"\n");
7337          return 0;          return 0;
7338        }        }
7339        }        }
# Line 7337  int CheckWHEN(struct Instance *inst, str Line 7344  int CheckWHEN(struct Instance *inst, str
7344          WriteInstanceName(ASCERR,inst,NULL);          WriteInstanceName(ASCERR,inst,NULL);
7345          WSEM(ASCERR,statement,          WSEM(ASCERR,statement,
7346           " the following statement will not be executed: \n");           " the following statement will not be executed: \n");
7347          FPRINTF(ASCERR,"\n");            FPRINTF(ASCERR,"\n");
7348      return 0;      return 0;
7349        }        }
7350        w1 = NextWhenCase(w1); }        w1 = NextWhenCase(w1); }
# Line 7747  int Pass2CheckStatement(struct Instance Line 7754  int Pass2CheckStatement(struct Instance
7754    }    }
7755  }  }
7756    
7757  /*  /**
7758   * checking statementlist, as in a FOR loop check.   * checking statementlist, as in a FOR loop check.
7759   * BUG!: CheckStatement and New flavors of same ignore the   * @TODO FIXME BUG!: CheckStatement and New flavors of same ignore the
7760   * type EXT. We never use external relations inside a loop?!   * type EXT. We never use external relations inside a loop?!
7761   */   */
7762  static  static
# Line 8121  int Pass2ExecuteCondStatements(struct In Line 8128  int Pass2ExecuteCondStatements(struct In
8128    switch(StatementType(statement)){    switch(StatementType(statement)){
8129      case REL:      case REL:
8130  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
8131      error_reporter_start(ASC_PROG_NOTE,NULL,0);      ERROR_REPORTER_START_NOLINE(ASC_PROG_NOTE);
8132      FPRINTF(stderr,"Pass2ExecuteCondStatements: case REL");      FPRINTF(stderr,"Pass2ExecuteCondStatements: case REL");
8133      WriteStatement(stderr, statement, 3);      WriteStatement(stderr, statement, 3);
8134      error_reporter_end_flush();      error_reporter_end_flush();
# Line 8130  int Pass2ExecuteCondStatements(struct In Line 8137  int Pass2ExecuteCondStatements(struct In
8137      case FOR:      case FOR:
8138        if ( ForContainsRelations(statement) ) {        if ( ForContainsRelations(statement) ) {
8139  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
8140      error_reporter_start(ASC_PROG_NOTE,NULL,0);      ERROR_REPORTER_START_NOLINE(ASC_PROG_NOTE);
8141      FPRINTF(stderr,"Pass2ExecuteCondStatements: case FOR");      FPRINTF(stderr,"Pass2ExecuteCondStatements: case FOR");
8142      WriteStatement(stderr, statement, 3);      WriteStatement(stderr, statement, 3);
8143      error_reporter_end_flush();      error_reporter_end_flush();
# Line 8400  void MakeWhenReference(struct Instance * Line 8407  void MakeWhenReference(struct Instance *
8407      } else {      } else {
8408        gl_destroy(instances);        gl_destroy(instances);
8409        FPRINTF(ASCERR,"\n");        FPRINTF(ASCERR,"\n");
8410        WriteName(ASCERR,name);        WriteName(ASCERR,name);
8411        Asc_Panic(2, NULL,        Asc_Panic(2, NULL,
8412                  "Error in WHEN statement. Name assigned"                  "Error in WHEN statement. Name assigned"
8413                  " to more than one instance type\n");                  " to more than one instance type\n");
# Line 9656  void Pass2ExecuteForStatements(struct In Line 9663  void Pass2ExecuteForStatements(struct In
9663        return_value = 1;        return_value = 1;
9664        if ( ForContainsRelations(statement) ) {        if ( ForContainsRelations(statement) ) {
9665  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
9666        error_reporter_start(ASC_PROG_NOTE,NULL,0);        ERROR_REPORTER_START_NOLINE(ASC_PROG_NOTE);
9667        WriteStatement(stderr, statement, 6);        WriteStatement(stderr, statement, 6);
9668        error_reporter_end_flush();        error_reporter_end_flush();
9669  #endif  #endif
9670          Pass2RealExecuteFOR(inst,statement);          Pass2RealExecuteFOR(inst,statement);
9671          /* p2ref expected to succeed or fail permanently.          /* p2ref expected to succeed or fail permanently.
9672           * if it doesn't, this needs fixing.           * if it doesn't, this needs fixing.
9673           */           */
9674        }        }
9675        break;        break;
# Line 9673  void Pass2ExecuteForStatements(struct In Line 9680  void Pass2ExecuteForStatements(struct In
9680        break;        break;
9681      case REL:      case REL:
9682  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
9683        error_reporter_start(ASC_PROG_NOTE,NULL,0);            ERROR_REPORTER_START_NOLINE(ASC_PROG_NOTE);
9684        WriteStatement(stderr, statement, 6);        WriteStatement(stderr, statement, 6);
9685        error_reporter_end_flush();        error_reporter_end_flush();
9686  #endif  #endif
# Line 10232  int Pass2RealExecuteFOR(struct Instance Line 10239  int Pass2RealExecuteFOR(struct Instance
10239    case set_value:    case set_value:
10240      sptr = SetValue(value);      sptr = SetValue(value);
10241      switch(SetKind(sptr)){      switch(SetKind(sptr)){
10242      case empty_set:      case empty_set:
10243  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
10244        FPRINTF(stderr,"Pass2RealExecuteFOR empty_set.\n");        FPRINTF(stderr,"Pass2RealExecuteFOR empty_set.\n");
10245  #endif  #endif
# Line 10962  int Pass2ExecuteStatement(struct Instanc Line 10969  int Pass2ExecuteStatement(struct Instanc
10969    switch(StatementType(statement)){ /* should be an if relinstance */    switch(StatementType(statement)){ /* should be an if relinstance */
10970    case FOR:    case FOR:
10971  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
10972      error_reporter_start(ASC_PROG_NOTE,NULL,0);      ERROR_REPORTER_START_NOLINE(ASC_PROG_NOTE);
10973      WriteStatement(stderr, statement, 3);      WriteStatement(stderr, statement, 3);
10974      error_reporter_end_flush();      error_reporter_end_flush();
10975  #endif  #endif
10976      return Pass2ExecuteFOR(inst,statement);      return Pass2ExecuteFOR(inst,statement);
10977    case REL:    case REL:
10978  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
10979      error_reporter_start(ASC_PROG_NOTE,NULL,0);      ERROR_REPORTER_START_NOLINE(ASC_PROG_NOTE);
10980      WriteStatement(stderr, statement, 3);      WriteStatement(stderr, statement, 3);
10981      error_reporter_end_flush();      error_reporter_end_flush();
10982  #endif  #endif
10983      /* ER expected to succeed or fail permanently. this may change. */      /* ER expected to succeed or fail permanently. this may change. */
10984      return ExecuteREL(inst,statement);      return ExecuteREL(inst,statement);
10985    case EXT:    case EXT:
10986        CONSOLE_DEBUG("ABOUT TO EXECUTEEXT");
10987      return ExecuteEXT(inst,statement);      return ExecuteEXT(inst,statement);
10988    case COND:    case COND:
10989      return Pass2ExecuteCOND(inst,statement);      return Pass2ExecuteCOND(inst,statement);
10990    case LOGREL:    case LOGREL:
10991    case WHEN:    case WHEN:
10992  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
10993      error_reporter_start(ASC_PROG_NOTE,NULL,0);      ERROR_REPORTER_START_NOLINE(ASC_PROG_NOTE);
10994      FPRINTF(stderr,"-- IGNORING WHEN STAT\n");      FPRINTF(stderr,"-- IGNORING WHEN STAT\n");
10995      /* write statement */      /* write statement */
10996      WriteStatement(stderr, statement, 3);      WriteStatement(stderr, statement, 3);
# Line 11212  void Pass4ProcessPendingInstances(void) Line 11220  void Pass4ProcessPendingInstances(void)
11220          /* we do away with TryArrayExpansion because it doesn't do whens */          /* we do away with TryArrayExpansion because it doesn't do whens */
11221          if (BitListEmpty(blist)) {          if (BitListEmpty(blist)) {
11222            /*            /*
11223         * delete PENDING model.         * delete PENDING model.
11224         */         */
11225        RemoveInstance(PendingInstance(work));        RemoveInstance(PendingInstance(work));
11226          } else {          } else {
11227        /*        /*
11228         * bitlist is still unhappy, but there's nothing to do about it.         * bitlist is still unhappy, but there's nothing to do about it.
11229             * Move the instance to the bottom and increase the counter             * Move the instance to the bottom and increase the counter
11230         * so that we do not visit it again.         * so that we do not visit it again.
# Line 11314  void Pass3ProcessPendingInstances(void) Line 11322  void Pass3ProcessPendingInstances(void)
11322   * This is the singlepass phase2 with anontype sharing of   * This is the singlepass phase2 with anontype sharing of
11323   * relations implemented. If relations can depend on other   * relations implemented. If relations can depend on other
11324   * relations (as in future differential work) then this function   * relations (as in future differential work) then this function
11325   * Needs to be slightly more sophisticated.   * needs to be slightly more sophisticated.
11326   */   */
11327  static  static
11328  void Pass2ProcessPendingInstancesAnon(struct Instance *result)  void Pass2ProcessPendingInstancesAnon(struct Instance *result)
# Line 11330  void Pass2ProcessPendingInstancesAnon(st Line 11338  void Pass2ProcessPendingInstancesAnon(st
11338  #if TIMECOMPILER  #if TIMECOMPILER
11339    clock_t start,classt;    clock_t start,classt;
11340  #endif  #endif
11341      CONSOLE_DEBUG("...");
11342    
11343    /* pending will have at least one instance, or quick return. */    /* pending will have at least one instance, or quick return. */
11344    assert(PASS2MAXNUMBER==1);    assert(PASS2MAXNUMBER==1);
# Line 11354  void Pass2ProcessPendingInstancesAnon(st Line 11363  void Pass2ProcessPendingInstancesAnon(st
11363        proto = Asc_GetAnonPrototype(at);        proto = Asc_GetAnonPrototype(at);
11364        if (InstanceKind(proto) == MODEL_INST && InstanceInList(proto)) {        if (InstanceKind(proto) == MODEL_INST && InstanceInList(proto)) {
11365  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
11366          error_reporter_start(ASC_PROG_NOTE,NULL,0);          ERROR_REPORTER_START_NOLINE(ASC_PROG_NOTE);
11367          FPRINTF(stderr,"Rels in model: ");          FPRINTF(stderr,"Rels in model: ");
11368          WriteInstanceName(stderr,proto,NULL); FPRINTF(stderr,"\n");          WriteInstanceName(stderr,proto,NULL); FPRINTF(stderr,"\n");
11369          error_reporter_end_flush();          error_reporter_end_flush();
# Line 11986  static Line 11995  static
11995  struct Instance *Pass2InstantiateModel(struct Instance *result,  struct Instance *Pass2InstantiateModel(struct Instance *result,
11996                                         unsigned long *pcount)                                         unsigned long *pcount)
11997  {  {
11998      CONSOLE_DEBUG("starting...");
11999    /* do we need a ForTable on the stack here? don't think so. np2ppi does it */    /* do we need a ForTable on the stack here? don't think so. np2ppi does it */
12000    if (result!=NULL) {    if (result!=NULL) {
12001        CONSOLE_DEBUG("result!=NULL...");
12002      /* pass2 pendings already set by visit */      /* pass2 pendings already set by visit */
12003      if (ANONFORCE || g_use_copyanon != 0) {      if (ANONFORCE || g_use_copyanon != 0) {
12004  #if TIMECOMPILER  #if TIMECOMPILER
# Line 12011  struct Instance *Pass2InstantiateModel(s Line 12022  struct Instance *Pass2InstantiateModel(s
12022      }      }
12023      ClearList();      ClearList();
12024    }    }
12025      CONSOLE_DEBUG("...done");
12026    return result;    return result;
12027  }  }
12028    
# Line 12021  void Pass2SetRelationBits(struct Instanc Line 12033  void Pass2SetRelationBits(struct Instanc
12033    if (inst != NULL && InstanceKind(inst)==MODEL_INST) {    if (inst != NULL && InstanceKind(inst)==MODEL_INST) {
12034      struct BitList *blist;      struct BitList *blist;
12035  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
12036      error_reporter_start(ASC_PROG_NOTE,NULL,0);      ERROR_REPORTER_START_NOLINE(ASC_PROG_NOTE);
12037      FPRINTF(stderr,"P2SRB: ");      FPRINTF(ASCERR,"P2SRB: ");
12038      WriteInstanceName(ASCERR,inst,debug_rels_work);      WriteInstanceName(ASCERR,inst,debug_rels_work);
12039        FPRINTF(ASCERR,"\n");
12040      error_reporter_end_flush();      error_reporter_end_flush();
12041  #endif  #endif
12042    
# Line 12064  void Pass2SetRelationBits(struct Instanc Line 12077  void Pass2SetRelationBits(struct Instanc
12077          AddBelow(NULL,inst);          AddBelow(NULL,inst);
12078          /* add PENDING model */          /* add PENDING model */
12079  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
12080          error_reporter_start(ASC_PROG_NOTE,NULL,0);          ERROR_REPORTER_START_NOLINE(ASC_PROG_NOTE);
12081          FPRINTF(stderr,"Changed: ");          FPRINTF(stderr,"Changed: ");
12082          WriteInstanceName(ASCERR,inst,debug_rels_work);          WriteInstanceName(ASCERR,inst,debug_rels_work);
12083          error_reporter_end_flush();          error_reporter_end_flush();
# Line 12175  struct Instance *NewInstantiateModel(str Line 12188  struct Instance *NewInstantiateModel(str
12188    /* At this point, there may be unexecuted non-relation    /* At this point, there may be unexecuted non-relation
12189     * statements, but they can never be executed. The     * statements, but they can never be executed. The
12190     * pending list is therefore empty. We know how many.     * pending list is therefore empty. We know how many.
12191     * The bitlists know which ones.     * The bitlists know which ones.
12192     */     */
12193    if (result!=NULL) {    if (result!=NULL) {
12194  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
# Line 12201  struct Instance *NewInstantiateModel(str Line 12214  struct Instance *NewInstantiateModel(str
12214    FPRINTF(ASCERR,"Phase 2 relations \t\t%lu\n",    FPRINTF(ASCERR,"Phase 2 relations \t\t%lu\n",
12215      (unsigned long)(phase2t-phase1t));      (unsigned long)(phase2t-phase1t));
12216  #endif  #endif
12217      CONSOLE_DEBUG("Starting phase 3...");
12218    /* at this point, there may be unexecuted non-logical relation    /* at this point, there may be unexecuted non-logical relation
12219     * statements, but they can never be executed. The     * statements, but they can never be executed. The
12220     * pending list is therefore empty. We know how many.     * pending list is therefore empty. We know how many.
# Line 12209  struct Instance *NewInstantiateModel(str Line 12223  struct Instance *NewInstantiateModel(str
12223    if (result!=NULL) {    if (result!=NULL) {
12224      /* now set the bits for relation statements and add pending models */      /* now set the bits for relation statements and add pending models */
12225      SilentVisitInstanceTree(result,Pass3SetLogRelBits,0,0);      SilentVisitInstanceTree(result,Pass3SetLogRelBits,0,0);
12226      /* note, the order of the visit might be better 1 than 0. don't know      /* note, the order of the visit might be better 1 than 0. don't know
12227       * at present order 0, so we do lower models before those near root       * at present order 0, so we do lower models before those near root
12228       */       */
12229      result = Pass3InstantiateModel(result,&pass3pendings);      result = Pass3InstantiateModel(result,&pass3pendings);
12230     /* result will not move as currently implemented */     /* result will not move as currently implemented */
# Line 12242  struct Instance *NewInstantiateModel(str Line 12256  struct Instance *NewInstantiateModel(str
12256        DefaultInstanceTree(result);        DefaultInstanceTree(result);
12257      }      }
12258      else{      else{
12259        error_reporter(ASC_USER_WARNING,NULL,0,"There are unexecuted statements "        ERROR_REPORTER_NOLINE(ASC_USER_WARNING,"There are unexecuted statements "
12260          "in the instance.\nDefault assignments not executed.");          "in the instance.\nDefault assignments not executed.");
12261      }      }
12262    }    }
# Line 12323  struct Instance *NewRealInstantiate(stru Line 12337  struct Instance *NewRealInstantiate(stru
12337                                   int intset)                                   int intset)
12338  {  {
12339    struct Instance *result;    struct Instance *result;
12340      CONSOLE_DEBUG("...");
12341    
12342    result = ShortCutMakeUniversalInstance(def); /*does quick Universal check */    result = ShortCutMakeUniversalInstance(def); /*does quick Universal check */
12343    if (result) return result;    if (result) return result;

Legend:
Removed from v.183  
changed lines
  Added in v.373

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22