/[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

trunk/ascend4/compiler/instantiate.c revision 1 by aw0a, Fri Oct 29 20:54:12 2004 UTC trunk/base/generic/compiler/instantiate.c revision 183 by johnpye, Fri Jan 13 02:35:00 2006 UTC
# Line 133  Line 133 
133    
134  static int g_iteration = 0; /* the current iteration. */  static int g_iteration = 0; /* the current iteration. */
135    
136    /* moved from tcltk98/generic/interface/SimsProc.c */
137    struct Instance *g_cursim;
138    
139  /*************************************************************************\  /*************************************************************************\
140  variable to check agreement in the number of boolean, integer or symbol  variable to check agreement in the number of boolean, integer or symbol
# Line 175  long int g_compiler_counter = 1; Line 177  long int g_compiler_counter = 1;
177   * which changes the instance tree is called.   * which changes the instance tree is called.
178   */   */
179    
180  #define DEBUG_RELS 1  /* #define DEBUG_RELS */
181  /* undef DEBUG_RELS if you want less spew in pass 2 */  /* undef DEBUG_RELS if you want less spew in pass 2 */
182    
183  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
# Line 869  struct IndexType *MakeIndex(struct Insta Line 871  struct IndexType *MakeIndex(struct Insta
871        Asc_Panic(2, NULL, "Bad index to dense alias array");        Asc_Panic(2, NULL, "Bad index to dense alias array");
872        exit(2);/* Needed to keep gcc from whining */        exit(2);/* Needed to keep gcc from whining */
873      }      }
874      return NULL;      /* return NULL; */  /* unreachable */
875    }    }
876  }  }
877    
# Line 1103  struct Instance *MakeSparseArray(struct Line 1105  struct Instance *MakeSparseArray(struct
1105                                   struct Instance *arginst,                                   struct Instance *arginst,
1106                                   struct gl_list_t *rhslist)                                   struct gl_list_t *rhslist)
1107  {  {
1108    struct TypeDescription *desc;    struct TypeDescription *desc = NULL;
1109    struct Instance *aryinst;    struct Instance *aryinst;
1110    struct gl_list_t *indices;    struct gl_list_t *indices;
1111    indices = MakeIndices(parent,NextName(name),stat);    indices = MakeIndices(parent,NextName(name),stat);
# Line 1385  symchar *UniquifyString(char *s, struct Line 1387  symchar *UniquifyString(char *s, struct
1387      while ( (oldlen+1) < maxlen) {      while ( (oldlen+1) < maxlen) {
1388        new[oldlen+1] = '\0';        new[oldlen+1] = '\0';
1389        for(c = 'a'; c <= 'z'; c++){        for(c = 'a'; c <= 'z'; c++){
1390          new[oldlen] = c;          new[oldlen] = (char)c;
1391          tmp = AddSymbol(new);          tmp = AddSymbol(new);
1392          if (StrMember(tmp,strset)==0) {          if (StrMember(tmp,strset)==0) {
1393            ascfree(new);            ascfree(new);
# Line 2908  int MPICheckWBTS(struct Instance *tmpins Line 2910  int MPICheckWBTS(struct Instance *tmpins
2910    struct gl_list_t *instances;    struct gl_list_t *instances;
2911    unsigned long c,len;    unsigned long c,len;
2912    enum find_errors err;    enum find_errors err;
2913    struct Instance *head;    struct Instance *head = NULL;
2914    
2915    instances = FindInsts(tmpinst,GetStatVarList(statement),&err);    instances = FindInsts(tmpinst,GetStatVarList(statement),&err);
2916    if (instances==NULL) {    if (instances==NULL) {
# Line 3530  int DigestArguments( Line 3532  int DigestArguments(
3532      case pp_DONE:      case pp_DONE:
3533        msg = NULL;        msg = NULL;
3534        break;        break;
3535        default:
3536          msg = NULL;
3537      }      }
3538      if (msg != NULL) {      if (msg != NULL) {
3539        WriteUnexecutedMessage(ASCERR,statement,msg);        WriteUnexecutedMessage(ASCERR,statement,msg);
# Line 4226  void MissingInsts(struct Instance *inst, Line 4230  void MissingInsts(struct Instance *inst,
4230      while(list!=NULL){      while(list!=NULL){
4231        temp = FindInstances(inst,NamePointer(list),&err);        temp = FindInstances(inst,NamePointer(list),&err);
4232        if (temp==NULL){        if (temp==NULL){
4233            error_reporter_start(ASC_USER_ERROR,NULL,0);
4234          FPRINTF(ASCERR,"Problem finding instance(s): \n");          FPRINTF(ASCERR,"Problem finding instance(s): \n");
4235          WriteName(ASCERR,NamePointer(list));          WriteName(ASCERR,NamePointer(list));
4236          FPRINTF(ASCERR,"\n");          FPRINTF(ASCERR,"\n");
4237            error_reporter_end_flush();
4238        } else {        } else {
4239          gl_destroy(temp);          gl_destroy(temp);
4240        }        }
# Line 4574  int ExecuteAA(struct Instance *inst, str Line 4580  int ExecuteAA(struct Instance *inst, str
4580  {  {
4581    struct gl_list_t *instances;    struct gl_list_t *instances;
4582    enum find_errors err;    enum find_errors err;
4583    struct TypeDescription *mostrefined;    struct TypeDescription *mostrefined = NULL;
4584    unsigned long c,len;    unsigned long c,len;
4585    struct Instance *inst1,*inst2;    struct Instance *inst1,*inst2;
4586    instances = FindInsts(inst,GetStatVarList(statement),&err);    instances = FindInsts(inst,GetStatVarList(statement),&err);
# Line 4744  int ExecuteREL(struct Instance *inst, st Line 4750  int ExecuteREL(struct Instance *inst, st
4750    if (GetInstanceRelation(child,&reltype)==NULL) {    if (GetInstanceRelation(child,&reltype)==NULL) {
4751      if ( (g_instantiate_relns & TOKRELS) ==0) {      if ( (g_instantiate_relns & TOKRELS) ==0) {
4752  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
4753          WSEM(ASCERR,statement, "TOKRELS 0 found in compiling relation.");          WSNM(ASCERR,statement, "TOKRELS 0 found in compiling relation.");
4754  #endif  #endif
4755        return 1;        return 1;
4756      }      }
# Line 4756  int ExecuteREL(struct Instance *inst, st Line 4762  int ExecuteREL(struct Instance *inst, st
4762      if (reln != NULL){      if (reln != NULL){
4763        SetInstanceRelation(child,reln,e_token);        SetInstanceRelation(child,reln,e_token);
4764  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
4765        WSEM(ASCERR,statement, "   Created relation.");        WSNM(ASCERR,statement, "Created relation.");
4766  #endif  #endif
4767        return 1;        return 1;
4768      } else {      } else {
# Line 4811  int ExecuteREL(struct Instance *inst, st Line 4817  int ExecuteREL(struct Instance *inst, st
4817        }        }
4818      }      }
4819  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
4820      WSEM(ASCERR,statement, "   Failed relation -- unexpected scenario.");      WSNM(ASCERR,statement, "   Failed relation -- unexpected scenario.");
4821  #endif  #endif
4822    } else{    } else{
4823      /*  Do nothing, somebody already completed the relation.  */      /*  Do nothing, somebody already completed the relation.  */
4824  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
4825          WSEM(ASCERR,statement, "Already compiled in compiling relation?!.");          WSNM(ASCERR,statement, "Already compiled in compiling relation?!.");
4826  #endif  #endif
4827      return 1;      return 1;
4828    }    }
4829  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
4830    WSEM(ASCERR,statement, "End of ExecuteREL. huh?");    WSNM(ASCERR,statement, "End of ExecuteREL. huh?");
4831  #endif  #endif
4832  }  }
4833    
# Line 4927  int ExecuteUnSelectedEQN(struct Instance Line 4933  int ExecuteUnSelectedEQN(struct Instance
4933      break;      break;
4934    default:    default:
4935      Asc_Panic(2, NULL, "Incorrect argument passed to ExecuteUnSelectedEQN\n");      Asc_Panic(2, NULL, "Incorrect argument passed to ExecuteUnSelectedEQN\n");
4936        name = NULL;
4937    }    }
4938    instances = FindInstances(inst,name,&ferr);    instances = FindInstances(inst,name,&ferr);
4939    /* see if the relation is there already */    /* see if the relation is there already */
# Line 4965  struct Instance *MakeLogRelInstance(stru Line 4972  struct Instance *MakeLogRelInstance(stru
4972    if ((childname=SimpleNameIdPtr(name))!=NULL){ /* simple name */    if ((childname=SimpleNameIdPtr(name))!=NULL){ /* simple name */
4973      SetInstanceNameType(rec,StrName);      SetInstanceNameType(rec,StrName);
4974      SetInstanceNameStrPtr(rec,childname);      SetInstanceNameStrPtr(rec,childname);
4975      if((pos = ChildSearch(parent,&rec))){      if(0 != (pos = ChildSearch(parent,&rec))){
4976        /* following assertion should be true */        /* following assertion should be true */
4977        assert(InstanceChild(parent,pos)==NULL);        assert(InstanceChild(parent,pos)==NULL);
4978        child = CreateLogRelInstance(def);        child = CreateLogRelInstance(def);
# Line 4978  struct Instance *MakeLogRelInstance(stru Line 4985  struct Instance *MakeLogRelInstance(stru
4985      childname = NameIdPtr(name);      childname = NameIdPtr(name);
4986      SetInstanceNameType(rec,StrName);      SetInstanceNameType(rec,StrName);
4987      SetInstanceNameStrPtr(rec,childname);      SetInstanceNameStrPtr(rec,childname);
4988      if((pos = ChildSearch(parent,&rec))){      if(0 != (pos = ChildSearch(parent,&rec))){
4989        if (InstanceChild(parent,pos)==NULL){ /* need to make array */        if (InstanceChild(parent,pos)==NULL){ /* need to make array */
4990          child = MakeSparseArray(parent,name,stat,NULL,0,NULL,NULL,NULL);          child = MakeSparseArray(parent,name,stat,NULL,0,NULL,NULL,NULL);
4991        } else {          /* need to add array element */        } else {          /* need to add array element */
# Line 5351  int ExecuteBlackBoxEXT(struct Instance * Line 5358  int ExecuteBlackBoxEXT(struct Instance *
5358    struct ExternalFunc *efunc;    struct ExternalFunc *efunc;
5359    CONST char *funcname;    CONST char *funcname;
5360    
5361      CONSOLE_DEBUG("ENTERED ExecuteBlackBoxExt\n");
5362    
5363    /* make or find the array head */    /* make or find the array head */
5364    name = ExternalStatName(statement);    name = ExternalStatName(statement);
5365    aryinst = MakeExtRelationArray(inst,name,statement);    aryinst = MakeExtRelationArray(inst,name,statement);
5366    if (aryinst==NULL) {    if (aryinst==NULL) {
5367      WriteStatementLocation(ASCERR,statement);      WriteStatementLocation(ASCERR,statement);
5368      FPRINTF(ASCERR,"Unable to create external expression structure.\n");      CONSOLE_DEBUG("Unable to create external expression structure.\n");
5369      return 1;      return 1;
5370    }    }
5371    /* we now have an array head */    /* we now have an array head */
# Line 5403  int ExecuteBlackBoxEXT(struct Instance * Line 5412  int ExecuteBlackBoxEXT(struct Instance *
5412       * loaded at this stage or report an error.       * loaded at this stage or report an error.
5413       */       */
5414      funcname = ExternalStatFuncName(statement);      funcname = ExternalStatFuncName(statement);
5415        FPRINTF(ASCERR,">>>>>> ExecuteBlackBoxEXT %s\n",funcname);
5416    
5417      efunc = LookupExtFunc(funcname);      efunc = LookupExtFunc(funcname);
5418      if (!efunc) {      if (!efunc) {
5419        FPRINTF(ASCERR,"External function %s was not loaded\n",funcname);        FPRINTF(ASCERR,"External function %s was not loaded\n",funcname);
# Line 5911  int AssignStructuralValue(struct Instanc Line 5922  int AssignStructuralValue(struct Instanc
5922      }      }
5923      return 0;      return 0;
5924    default:    default:
5925      WSEM(ASCERR,statement, "Error.  Unknown value type");      WSEM(ASCERR,statement, "Error: Unknown value type");
5926      return 0;      return 0;
5927    }    }
5928  }  }
# Line 6006  static Line 6017  static
6017  int NameContainsName(CONST struct Name *n,CONST struct Name *sub)  int NameContainsName(CONST struct Name *n,CONST struct Name *sub)
6018  {  {
6019    struct gl_list_t *nl;    struct gl_list_t *nl;
6020    unsigned long c,len;    unsigned long c,len;                  
6021    struct Expr en;    struct Expr *en;
6022    
6023    assert(n!=NULL);    assert(n!=NULL);
6024    assert(sub!=NULL);    assert(sub!=NULL);
6025    InitVarExpr(&en,n);    en = (struct Expr *)ascmalloc(sizeof(struct Expr));
6026    nl = EvaluateNamesNeededShallow(&en,NULL,NULL);    InitVarExpr(en,n);
6027      nl = EvaluateNamesNeededShallow(en,NULL,NULL);
6028    /* should this function be checking deep instead? can't tell yet. */    /* should this function be checking deep instead? can't tell yet. */
6029    if (nl==NULL || gl_length(nl)==0) {    if (nl==NULL || gl_length(nl)==0) {
6030      return 0; /* should never happen */      return 0; /* should never happen */
# Line 6024  int NameContainsName(CONST struct Name * Line 6036  int NameContainsName(CONST struct Name *
6036      }      }
6037    }    }
6038    gl_destroy(nl);    gl_destroy(nl);
6039      ascfree(en);
6040    return 0;    return 0;
6041  }  }
6042  /*  /*
# Line 6931  int CheckWhenSetNode(struct Instance *re Line 6944  int CheckWhenSetNode(struct Instance *re
6944      *p2=2;      *p2=2;
6945      return 1;      return 1;
6946    case e_var:    case e_var:
6947      if (GetEvaluationForTable() != NULL &&      if ((GetEvaluationForTable() != NULL) &&
6948        (str = SimpleNameIdPtr(ExprName(expr)))&&          (NULL != (str = SimpleNameIdPtr(ExprName(expr)))) &&
6949        (fvp=FindForVar(GetEvaluationForTable(),str))){          (NULL != (fvp=FindForVar(GetEvaluationForTable(),str)))) {
6950        if (GetForKind(fvp)==f_integer){        if (GetForKind(fvp)==f_integer){
6951          *p2=0;          *p2=0;
6952          return 1;          return 1;
# Line 7438  int CheckSelectSetNode(struct Instance * Line 7451  int CheckSelectSetNode(struct Instance *
7451         *p2=2;         *p2=2;
7452         return 1;         return 1;
7453      case e_var:      case e_var:
7454        if (GetEvaluationForTable() &&        if ((NULL != GetEvaluationForTable()) &&
7455           (str = SimpleNameIdPtr(ExprName(expr)))&&            (NULL != (str = SimpleNameIdPtr(ExprName(expr)))) &&
7456           (fvp=FindForVar(GetEvaluationForTable(),str))){            (NULL != (fvp=FindForVar(GetEvaluationForTable(),str)))) {
7457          if (GetForKind(fvp)==f_integer){          if (GetForKind(fvp)==f_integer){
7458            *p2=0;            *p2=0;
7459            return 1;            return 1;
# Line 8108  int Pass2ExecuteCondStatements(struct In Line 8121  int Pass2ExecuteCondStatements(struct In
8121    switch(StatementType(statement)){    switch(StatementType(statement)){
8122      case REL:      case REL:
8123  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
8124        error_reporter_start(ASC_PROG_NOTE,NULL,0);
8125      FPRINTF(stderr,"Pass2ExecuteCondStatements: case REL");      FPRINTF(stderr,"Pass2ExecuteCondStatements: case REL");
8126      WriteStatement(stderr, statement, 3);      WriteStatement(stderr, statement, 3);
8127        error_reporter_end_flush();
8128  #endif  #endif
8129        return ExecuteREL(inst,statement);        return ExecuteREL(inst,statement);
8130      case FOR:      case FOR:
8131        if ( ForContainsRelations(statement) ) {        if ( ForContainsRelations(statement) ) {
8132  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
8133        error_reporter_start(ASC_PROG_NOTE,NULL,0);
8134      FPRINTF(stderr,"Pass2ExecuteCondStatements: case FOR");      FPRINTF(stderr,"Pass2ExecuteCondStatements: case FOR");
8135      WriteStatement(stderr, statement, 3);      WriteStatement(stderr, statement, 3);
8136        error_reporter_end_flush();
8137  #endif  #endif
8138          return Pass2ExecuteFOR(inst,statement);          return Pass2ExecuteFOR(inst,statement);
8139        }        }
# Line 8185  int ExecuteUnSelectedCOND(struct Instanc Line 8202  int ExecuteUnSelectedCOND(struct Instanc
8202    struct Statement *stat;    struct Statement *stat;
8203    unsigned long c,len;    unsigned long c,len;
8204    struct gl_list_t *list;    struct gl_list_t *list;
8205    int return_value;    int return_value = 0;
8206    
8207    sl = CondStatList(statement);    sl = CondStatList(statement);
8208    list = GetList(sl);    list = GetList(sl);
# Line 8486  struct Instance *MakeWhenInstance(struct Line 8503  struct Instance *MakeWhenInstance(struct
8503    if ((when_name=SimpleNameIdPtr(name))!=NULL){    if ((when_name=SimpleNameIdPtr(name))!=NULL){
8504      SetInstanceNameType(rec,StrName);      SetInstanceNameType(rec,StrName);
8505      SetInstanceNameStrPtr(rec,when_name);      SetInstanceNameStrPtr(rec,when_name);
8506      if((pos = ChildSearch(parent,&rec))){      if(0 != (pos = ChildSearch(parent,&rec))){
8507        assert(InstanceChild(parent,pos)==NULL);        assert(InstanceChild(parent,pos)==NULL);
8508        desc = FindWhenType();        desc = FindWhenType();
8509        child = CreateWhenInstance(desc);        child = CreateWhenInstance(desc);
# Line 8498  struct Instance *MakeWhenInstance(struct Line 8515  struct Instance *MakeWhenInstance(struct
8515      when_name = NameIdPtr(name);      when_name = NameIdPtr(name);
8516      SetInstanceNameType(rec,StrName);      SetInstanceNameType(rec,StrName);
8517      SetInstanceNameStrPtr(rec,when_name);      SetInstanceNameStrPtr(rec,when_name);
8518      if((pos = ChildSearch(parent,&rec))){      if(0 != (pos = ChildSearch(parent,&rec))){
8519        if (InstanceChild(parent,pos)==NULL){ /* need to make array */        if (InstanceChild(parent,pos)==NULL){ /* need to make array */
8520          child = MakeSparseArray(parent,name,stat,NULL,0,NULL,NULL,NULL);          child = MakeSparseArray(parent,name,stat,NULL,0,NULL,NULL,NULL);
8521        } else {          /* need to add array element */        } else {          /* need to add array element */
# Line 8522  void ExecuteWhenStatements(struct Instan Line 8539  void ExecuteWhenStatements(struct Instan
8539  {  {
8540    struct Statement *statement;    struct Statement *statement;
8541    unsigned long c,len;    unsigned long c,len;
8542    int return_value;    int return_value = 0;
8543    struct gl_list_t *list;    struct gl_list_t *list;
8544    list = GetList(sl);    list = GetList(sl);
8545    len = gl_length(list);    len = gl_length(list);
# Line 8621  void RealExecuteWHEN(struct Instance *in Line 8638  void RealExecuteWHEN(struct Instance *in
8638        WSEM(ASCERR,statement, "Expression name refers to more than one object");        WSEM(ASCERR,statement, "Expression name refers to more than one object");
8639        gl_destroy(instances);        gl_destroy(instances);
8640        Asc_Panic(2, NULL, "Expression name refers to more than one object");        Asc_Panic(2, NULL, "Expression name refers to more than one object");
8641          child = NULL;
8642      }      }
8643    }    }
8644    vlist = WhenStatVL(statement);    vlist = WhenStatVL(statement);
# Line 8662  void ExecuteUnSelectedWhenStatements(str Line 8680  void ExecuteUnSelectedWhenStatements(str
8680  {  {
8681    struct Statement *statement;    struct Statement *statement;
8682    unsigned long c,len;    unsigned long c,len;
8683    int return_value;    int return_value = 0;
8684    struct gl_list_t *list;    struct gl_list_t *list;
8685    list = GetList(sl);    list = GetList(sl);
8686    len = gl_length(list);    len = gl_length(list);
# Line 9601  void Pass2ExecuteForStatements(struct In Line 9619  void Pass2ExecuteForStatements(struct In
9619  {  {
9620    struct Statement *statement;    struct Statement *statement;
9621    unsigned long c,len;    unsigned long c,len;
9622    int return_value;    int return_value = 0;
9623    struct gl_list_t *list;    struct gl_list_t *list;
9624    list = GetList(sl);    list = GetList(sl);
9625    len = gl_length(list);    len = gl_length(list);
# Line 9638  void Pass2ExecuteForStatements(struct In Line 9656  void Pass2ExecuteForStatements(struct In
9656        return_value = 1;        return_value = 1;
9657        if ( ForContainsRelations(statement) ) {        if ( ForContainsRelations(statement) ) {
9658  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
9659          error_reporter_start(ASC_PROG_NOTE,NULL,0);
9660        WriteStatement(stderr, statement, 6);        WriteStatement(stderr, statement, 6);
9661          error_reporter_end_flush();
9662  #endif  #endif
9663          Pass2RealExecuteFOR(inst,statement);          Pass2RealExecuteFOR(inst,statement);
9664          /* p2ref expected to succeed or fail permanently.          /* p2ref expected to succeed or fail permanently.
# Line 9653  void Pass2ExecuteForStatements(struct In Line 9673  void Pass2ExecuteForStatements(struct In
9673        break;        break;
9674      case REL:      case REL:
9675  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
9676          error_reporter_start(ASC_PROG_NOTE,NULL,0);    
9677        WriteStatement(stderr, statement, 6);        WriteStatement(stderr, statement, 6);
9678          error_reporter_end_flush();
9679  #endif  #endif
9680        return_value = ExecuteREL(inst,statement);        return_value = ExecuteREL(inst,statement);
9681        /* ER expected to succeed or fail permanently,returning 1.        /* ER expected to succeed or fail permanently,returning 1.
# Line 9687  void Pass1ExecuteForStatements(struct In Line 9709  void Pass1ExecuteForStatements(struct In
9709  {  {
9710    struct Statement *statement;    struct Statement *statement;
9711    unsigned long c,len;    unsigned long c,len;
9712    int return_value;    int return_value = 0;
9713    struct gl_list_t *list;    struct gl_list_t *list;
9714    list = GetList(sl);    list = GetList(sl);
9715    len = gl_length(list);    len = gl_length(list);
# Line 10940  int Pass2ExecuteStatement(struct Instanc Line 10962  int Pass2ExecuteStatement(struct Instanc
10962    switch(StatementType(statement)){ /* should be an if relinstance */    switch(StatementType(statement)){ /* should be an if relinstance */
10963    case FOR:    case FOR:
10964  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
10965        error_reporter_start(ASC_PROG_NOTE,NULL,0);
10966      WriteStatement(stderr, statement, 3);      WriteStatement(stderr, statement, 3);
10967        error_reporter_end_flush();
10968  #endif  #endif
10969      return Pass2ExecuteFOR(inst,statement);      return Pass2ExecuteFOR(inst,statement);
10970    case REL:    case REL:
10971  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
10972        error_reporter_start(ASC_PROG_NOTE,NULL,0);
10973      WriteStatement(stderr, statement, 3);      WriteStatement(stderr, statement, 3);
10974        error_reporter_end_flush();
10975  #endif  #endif
10976      /* ER expected to succeed or fail permanently. this may change. */      /* ER expected to succeed or fail permanently. this may change. */
10977      return ExecuteREL(inst,statement);      return ExecuteREL(inst,statement);
# Line 10956  int Pass2ExecuteStatement(struct Instanc Line 10982  int Pass2ExecuteStatement(struct Instanc
10982    case LOGREL:    case LOGREL:
10983    case WHEN:    case WHEN:
10984  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
10985        error_reporter_start(ASC_PROG_NOTE,NULL,0);
10986      FPRINTF(stderr,"-- IGNORING WHEN STAT\n");      FPRINTF(stderr,"-- IGNORING WHEN STAT\n");
10987      /* write statement */      /* write statement */
10988      WriteStatement(stderr, statement, 3);      WriteStatement(stderr, statement, 3);
10989        error_reporter_end_flush();
10990  #endif  #endif
10991      return 1; /* assumed done  */      return 1; /* assumed done  */
10992    case FNAME:    case FNAME:
# Line 11176  void Pass4ProcessPendingInstances(void) Line 11204  void Pass4ProcessPendingInstances(void)
11204          blist = InstanceBitList(inst);          blist = InstanceBitList(inst);
11205        } else {        } else {
11206          blist = NULL;   /* this shouldn't be necessary, but is */          blist = NULL;   /* this shouldn't be necessary, but is */
11207            inst = NULL;
11208        }        }
11209        if ((blist!=NULL)&&!BitListEmpty(blist)){        if ((blist!=NULL)&&!BitListEmpty(blist)){
11210          /* only models get here */          /* only models get here */
# Line 11238  void Pass3ProcessPendingInstances(void) Line 11267  void Pass3ProcessPendingInstances(void)
11267          blist = InstanceBitList(inst);          blist = InstanceBitList(inst);
11268        } else {        } else {
11269          blist = NULL; /* this shouldn't be necessary, but is */          blist = NULL; /* this shouldn't be necessary, but is */
11270            inst = NULL;
11271        }        }
11272        if ((blist!=NULL)&&!BitListEmpty(blist)){        if ((blist!=NULL)&&!BitListEmpty(blist)){
11273          /* only models get here */          /* only models get here */
# Line 11324  void Pass2ProcessPendingInstancesAnon(st Line 11354  void Pass2ProcessPendingInstancesAnon(st
11354        proto = Asc_GetAnonPrototype(at);        proto = Asc_GetAnonPrototype(at);
11355        if (InstanceKind(proto) == MODEL_INST && InstanceInList(proto)) {        if (InstanceKind(proto) == MODEL_INST && InstanceInList(proto)) {
11356  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
11357          FPRINTF(stderr,"Rels in model: ");          error_reporter_start(ASC_PROG_NOTE,NULL,0);
11358            FPRINTF(stderr,"Rels in model: ");
11359          WriteInstanceName(stderr,proto,NULL); FPRINTF(stderr,"\n");          WriteInstanceName(stderr,proto,NULL); FPRINTF(stderr,"\n");
11360            error_reporter_end_flush();
11361  #endif  #endif
11362          blist = InstanceBitList(proto);          blist = InstanceBitList(proto);
11363          if ((blist!=NULL) && !BitListEmpty(blist)) {          if ((blist!=NULL) && !BitListEmpty(blist)) {
# Line 11396  void Pass2ProcessPendingInstances(void) Line 11428  void Pass2ProcessPendingInstances(void)
11428          blist = InstanceBitList(inst);          blist = InstanceBitList(inst);
11429        } else {        } else {
11430          blist = NULL; /* this shouldn't be necessary, but is */          blist = NULL; /* this shouldn't be necessary, but is */
11431            inst = NULL;
11432        }        }
11433        if ((blist!=NULL)&&!BitListEmpty(blist)){        if ((blist!=NULL)&&!BitListEmpty(blist)){
11434          /* only models get here */          /* only models get here */
# Line 11832  void Pass4SetWhenBits(struct Instance *i Line 11865  void Pass4SetWhenBits(struct Instance *i
11865      blist = InstanceBitList(inst);      blist = InstanceBitList(inst);
11866      if (blist!=NULL){      if (blist!=NULL){
11867        unsigned long c;        unsigned long c;
11868        struct gl_list_t *statements;        struct gl_list_t *statements = NULL;
11869        enum stat_t st;        enum stat_t st;
11870        int changed;        int changed;
11871    
# Line 11903  void Pass3SetLogRelBits(struct Instance Line 11936  void Pass3SetLogRelBits(struct Instance
11936      blist = InstanceBitList(inst);      blist = InstanceBitList(inst);
11937      if (blist!=NULL){      if (blist!=NULL){
11938        unsigned long c;        unsigned long c;
11939        struct gl_list_t *statements;        struct gl_list_t *statements = NULL;
11940        enum stat_t st;        enum stat_t st;
11941        int changed;        int changed;
11942    
# Line 11988  void Pass2SetRelationBits(struct Instanc Line 12021  void Pass2SetRelationBits(struct Instanc
12021    if (inst != NULL && InstanceKind(inst)==MODEL_INST) {    if (inst != NULL && InstanceKind(inst)==MODEL_INST) {
12022      struct BitList *blist;      struct BitList *blist;
12023  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
12024        error_reporter_start(ASC_PROG_NOTE,NULL,0);
12025      FPRINTF(stderr,"P2SRB: ");      FPRINTF(stderr,"P2SRB: ");
12026      WriteInstanceName(ASCERR,inst,debug_rels_work);      WriteInstanceName(ASCERR,inst,debug_rels_work);
12027      FPRINTF(stderr,"\n");      error_reporter_end_flush();
12028  #endif  #endif
12029    
12030      blist = InstanceBitList(inst);      blist = InstanceBitList(inst);
12031      if (blist!=NULL){      if (blist!=NULL){
12032        unsigned long c;        unsigned long c;
12033        struct gl_list_t *statements;        struct gl_list_t *statements = NULL;
12034        enum stat_t st;        enum stat_t st;
12035        int changed;        int changed;
12036    
# Line 12030  void Pass2SetRelationBits(struct Instanc Line 12064  void Pass2SetRelationBits(struct Instanc
12064          AddBelow(NULL,inst);          AddBelow(NULL,inst);
12065          /* add PENDING model */          /* add PENDING model */
12066  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
12067            error_reporter_start(ASC_PROG_NOTE,NULL,0);
12068          FPRINTF(stderr,"Changed: ");          FPRINTF(stderr,"Changed: ");
12069          WriteInstanceName(ASCERR,inst,debug_rels_work);          WriteInstanceName(ASCERR,inst,debug_rels_work);
12070          FPRINTF(stderr,"\n");          error_reporter_end_flush();
12071  #endif  #endif
12072        }        }
12073      }      }
# Line 12207  struct Instance *NewInstantiateModel(str Line 12242  struct Instance *NewInstantiateModel(str
12242        DefaultInstanceTree(result);        DefaultInstanceTree(result);
12243      }      }
12244      else{      else{
12245        FPRINTF(ASCERR,"There are unexecuted statements in the instance.\n");        error_reporter(ASC_USER_WARNING,NULL,0,"There are unexecuted statements "
12246        FPRINTF(ASCERR,"Default assignments not executed.\n");          "in the instance.\nDefault assignments not executed.");
12247      }      }
12248    }    }
12249  #if TIMECOMPILER  #if TIMECOMPILER
# Line 12569  void UpdateInstance(struct Instance *roo Line 12604  void UpdateInstance(struct Instance *roo
12604          if (instances) {          if (instances) {
12605            if (gl_length(instances)!=1) {            if (gl_length(instances)!=1) {
12606              FPRINTF(ASCERR,"More than 1 scope instance found !!\n");              FPRINTF(ASCERR,"More than 1 scope instance found !!\n");
12607                scope = NULL;
12608            }            }
12609            else{            else{
12610              scope = (struct Instance *)gl_fetch(instances,1L);              scope = (struct Instance *)gl_fetch(instances,1L);

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

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