/[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 838 by johnpye, Fri Jul 14 04:31:54 2006 UTC revision 839 by johnpye, Fri Sep 8 07:46:53 2006 UTC
# Line 174  long int g_compiler_counter = 1; Line 174  long int g_compiler_counter = 1;
174           changing the instance tree is executed.           changing the instance tree is executed.
175           At present the compiler cares nothing about this counter,           At present the compiler cares nothing about this counter,
176           but it is provided as a service to clients.           but it is provided as a service to clients.
177        
178      Real applications:      Real applications:
179      1) This variable is used for keeping track of calls to      1) This variable is used for keeping track of calls to
180      the compiler which will create the need for a total solver system      the compiler which will create the need for a total solver system
# Line 361  void WriteUnexecutedMessage(FILE *f, str Line 361  void WriteUnexecutedMessage(FILE *f, str
361    
362  /**  /**
363      Write Unexecuted Error Message in Pass 3 WUEMPASS3      Write Unexecuted Error Message in Pass 3 WUEMPASS3
364        
365      This code will emit error messages only on the last      This code will emit error messages only on the last
366      iteration of pass3 when trying to clear pending statements.      iteration of pass3 when trying to clear pending statements.
367      g_iteration is the global iteration counter, and PASS3MAXNUMBER      g_iteration is the global iteration counter, and PASS3MAXNUMBER
# Line 866  struct IndexType *MakeIndex(struct Insta Line 866  struct IndexType *MakeIndex(struct Insta
866      default:      default:
867        STATEMENT_ERROR(stat, "Unknown result value type in MakeIndex.\n");        STATEMENT_ERROR(stat, "Unknown result value type in MakeIndex.\n");
868        Asc_Panic(2, NULL, "Unknown result value type in MakeIndex.\n");        Asc_Panic(2, NULL, "Unknown result value type in MakeIndex.\n");
869          
870      }      }
871    } else { /* checking subscripts on dense ALIASES/param'd IS_A statement */    } else { /* checking subscripts on dense ALIASES/param'd IS_A statement */
872      if (sptr==NULL) {      if (sptr==NULL) {
# Line 894  struct IndexType *MakeIndex(struct Insta Line 894  struct IndexType *MakeIndex(struct Insta
894        DestroyValue(&value);        DestroyValue(&value);
895        STATEMENT_ERROR(stat, "Bad index to dense alias array");        STATEMENT_ERROR(stat, "Bad index to dense alias array");
896        Asc_Panic(2, NULL, "Bad index to dense alias array");        Asc_Panic(2, NULL, "Bad index to dense alias array");
897          
898      }      }
899      /* return NULL; */  /* unreachable */      /* return NULL; */  /* unreachable */
900    }    }
# Line 1062  struct Instance *DoNextArray(struct Inst Line 1062  struct Instance *DoNextArray(struct Inst
1062      return NULL;      return NULL;
1063    default:    default:
1064      Asc_Panic(2, NULL ,"Unknown result value type.\n");      Asc_Panic(2, NULL ,"Unknown result value type.\n");
1065        
1066    }    }
1067  }  }
1068    
# Line 1112  struct Instance *AddArrayChild(struct In Line 1112  struct Instance *AddArrayChild(struct In
1112    
1113      This function returns the child pointer because relation functions      This function returns the child pointer because relation functions
1114      need it, not because the child is unconnected.      need it, not because the child is unconnected.
1115        
1116      If rhsinst is not NULL, uses rhsinst instead of creating new one.      If rhsinst is not NULL, uses rhsinst instead of creating new one.
1117      If rhslist is not NULL, uses rhslist instead of rhsinst or creating.      If rhslist is not NULL, uses rhslist instead of rhsinst or creating.
1118    
# Line 1431  symchar *UniquifyString(char *s, struct Line 1431  symchar *UniquifyString(char *s, struct
1431      }      }
1432      Asc_Panic(2, NULL,      Asc_Panic(2, NULL,
1433                "Unable to generate unique compound alias subscript.\n");                "Unable to generate unique compound alias subscript.\n");
1434        
1435    } else {    } else {
1436      ascfree(s);      ascfree(s);
1437      return tmp;      return tmp;
# Line 1892  int ArgValuesUnassigned(struct Instance Line 1892  int ArgValuesUnassigned(struct Instance
1892      If needed, args will be expanded, but if you know the length      If needed, args will be expanded, but if you know the length
1893      to expect, make args of that size before calling and this      to expect, make args of that size before calling and this
1894      will be faster.      will be faster.
1895        
1896      This does not go into the expressions (which may contain other      This does not go into the expressions (which may contain other
1897      sets themselves) of the set nodes and disassemble them.      sets themselves) of the set nodes and disassemble them.
1898      The list may be safely destroyed, but its contents should not      The list may be safely destroyed, but its contents should not
1899      be destroyed with it as they belong to something else in all      be destroyed with it as they belong to something else in all
1900      likelihood.      likelihood.
1901        
1902      @TODO This function should be moved into a set header someplace.      @TODO This function should be moved into a set header someplace.
1903  */  */
1904  static  static
# Line 2220  int ArgValueCorrect(struct Instance *ins Line 2220  int ArgValueCorrect(struct Instance *ins
2220    
2221  /**  /**
2222      evaluate a logical or real relation and see that it is satisfied.      evaluate a logical or real relation and see that it is satisfied.
2223        
2224      @BUG baa. needs to be exception safe and is not.      @BUG baa. needs to be exception safe and is not.
2225    
2226      returns MPIOK (satisfied)      returns MPIOK (satisfied)
# Line 2229  int ArgValueCorrect(struct Instance *ins Line 2229  int ArgValueCorrect(struct Instance *ins
2229      returns MPIWAIT (not yet determinable)      returns MPIWAIT (not yet determinable)
2230      returns MPIEXCEP (evaluation is impossible due to float/other error)      returns MPIEXCEP (evaluation is impossible due to float/other error)
2231      returns MPINOTBOOL (dissatisfied- nonboolean result)      returns MPINOTBOOL (dissatisfied- nonboolean result)
2232        
2233      @param statement should be a rel or logrel.      @param statement should be a rel or logrel.
2234  */  */
2235  static  static
# Line 2368  int InsertParameterInst(struct Instance Line 2368  int InsertParameterInst(struct Instance
2368    } else {          /* unknown name */    } else {          /* unknown name */
2369      STATEMENT_ERROR(statement, "Unknown parameter name.  Never should happen");      STATEMENT_ERROR(statement, "Unknown parameter name.  Never should happen");
2370      Asc_Panic(2, NULL, "Unknown parameter name.  Never should happen");      Asc_Panic(2, NULL, "Unknown parameter name.  Never should happen");
2371        
2372    }    }
2373  }  }
2374    
# Line 2384  void DestroyParameterInst(struct Instanc Line 2384  void DestroyParameterInst(struct Instanc
2384    DestroyInstance(i,NULL);    DestroyInstance(i,NULL);
2385  }  }
2386    
2387  /**  /**
2388      destroys everything you send it. If you send some arguments in      destroys everything you send it. If you send some arguments in
2389      as null, we don't mind.      as null, we don't mind.
2390  */  */
# Line 2550  int MPIMakeSimple(struct Instance *paren Line 2550  int MPIMakeSimple(struct Instance *paren
2550      the more likely to fail steps first.      the more likely to fail steps first.
2551    
2552      A successful return value is 1.      A successful return value is 1.
2553        
2554      A failure possibly to succeed later is 0.      A failure possibly to succeed later is 0.
2555      Possible causes will be detailed via the WriteUnexecutedMessage      Possible causes will be detailed via the WriteUnexecutedMessage
2556      facility.      facility.
# Line 2559  int MPIMakeSimple(struct Instance *paren Line 2559  int MPIMakeSimple(struct Instance *paren
2559      Causes will be detailed via the WSEM facility, in addition return      Causes will be detailed via the WSEM facility, in addition return
2560      values < 0 have the interpretations given in g_mpi_message[-value]      values < 0 have the interpretations given in g_mpi_message[-value]
2561      above.      above.
2562        
2563      @NOTE assumes statement is well formed, in terms of      @NOTE assumes statement is well formed, in terms of
2564      arglist of IS_A/IS_REFINED_TO (if there is one) being of correct length.      arglist of IS_A/IS_REFINED_TO (if there is one) being of correct length.
2565      returns fairly quickly for nonmodel and nonparametric      returns fairly quickly for nonmodel and nonparametric
# Line 3216  struct parpendingentry { Line 3216  struct parpendingentry {
3216  /**  /**
3217      returns a single instance, if such can be properly derived      returns a single instance, if such can be properly derived
3218      from the name given.      from the name given.
3219        
3220      Returns NULL if too many or no instances are found.      Returns NULL if too many or no instances are found.
3221      Probably ought to have a return code, but doesn't.      Probably ought to have a return code, but doesn't.
3222  */  */
# Line 3698  void ConfigureInstFromArgs(struct Instan Line 3698  void ConfigureInstFromArgs(struct Instan
3698      At this point there can be no alias children -- all      At this point there can be no alias children -- all
3699      are either WILL_BE or IS_A of constants/arrays, so far as      are either WILL_BE or IS_A of constants/arrays, so far as
3700      arginst is concerned.      arginst is concerned.
3701        
3702      This must only be called with models when arginst !=NULL.      This must only be called with models when arginst !=NULL.
3703      arginst == NULL --> immediate, no action return.      arginst == NULL --> immediate, no action return.
3704      inst is expected to be of same type as arginst.      inst is expected to be of same type as arginst.
# Line 4134  void MakeDummyInstance(CONST struct Name Line 4134  void MakeDummyInstance(CONST struct Name
4134      Used for IS_A statement inside a non-matching CASE of a      Used for IS_A statement inside a non-matching CASE of a
4135      SELECT statement.      SELECT statement.
4136    
4137      Make a dummy instance for each name in vlisti, but arrays are not expanded      Make a dummy instance for each name in vlisti, but arrays are not expanded
4138      over subscripts. The dummy instance is UNIVERSAL.      over subscripts. The dummy instance is UNIVERSAL.
4139  */  */
4140  static  static
# Line 4217  int ExecuteREF(struct Instance *inst, st Line 4217  int ExecuteREF(struct Instance *inst, st
4217      If problem, returns NULL and err should be consulted.      If problem, returns NULL and err should be consulted.
4218      Note this may have some angst around FOR vars, as it      Note this may have some angst around FOR vars, as it
4219      should since forvars are not instances.      should since forvars are not instances.
4220        
4221      Lint is precluding passing a forvar where an instance is required.      Lint is precluding passing a forvar where an instance is required.
4222      err should only be consulted if result comes back NULL.      err should only be consulted if result comes back NULL.
4223    
# Line 4250  struct gl_list_t *FindArgInsts(struct In Line 4250  struct gl_list_t *FindArgInsts(struct In
4250  }  }
4251    
4252  /**  /**
4253      Find instances: Make sure at least one thing is found for each name item      Find instances: Make sure at least one thing is found for each name item
4254      on list (else returned list will be NULL) and return the collected instances.      on list (else returned list will be NULL) and return the collected instances.
4255  */  */
4256  static  static
# Line 4875  int ExecuteREL(struct Instance *inst, st Line 4875  int ExecuteREL(struct Instance *inst, st
4875          Asc_Panic(2, NULL, "Incorrect error response.\n");/*NOTREACHED*/          Asc_Panic(2, NULL, "Incorrect error response.\n");/*NOTREACHED*/
4876        default:        default:
4877          Asc_Panic(2, NULL, "Unknown error response.\n");/*NOTREACHED*/          Asc_Panic(2, NULL, "Unknown error response.\n");/*NOTREACHED*/
4878            
4879        }        }
4880      }      }
4881  #ifdef DEBUG_RELS  #ifdef DEBUG_RELS
# Line 5166  int ExecuteLOGREL(struct Instance *inst, Line 5166  int ExecuteLOGREL(struct Instance *inst,
5166            return 0;            return 0;
5167        case lokay:        case lokay:
5168          Asc_Panic(2, NULL, "Incorrect error response.\n");/*NOTREACHED*/          Asc_Panic(2, NULL, "Incorrect error response.\n");/*NOTREACHED*/
5169            
5170        default:        default:
5171          Asc_Panic(2, NULL, "Unknown error response.\n");/*NOTREACHED*/          Asc_Panic(2, NULL, "Unknown error response.\n");/*NOTREACHED*/
5172            
5173        }        }
5174      }      }
5175    } else{    } else{
# Line 5402  static struct Instance *CheckExtCallData Line 5402  static struct Instance *CheckExtCallData
5402  }  }
5403    
5404  /**  /**
5405      This function does the job of creating an instance of a 'black box'      This function does the job of creating an instance of a 'black box'
5406      external relation or set of relations.      external relation or set of relations.
5407  */  */
5408  static int ExecuteBlackBoxEXT(struct Instance *inst  static int ExecuteBlackBoxEXT(struct Instance *inst
# Line 6811  int CheckFNAME(struct Instance *inst, st Line 6811  int CheckFNAME(struct Instance *inst, st
6811  /**  /**
6812      Only logrelations and FOR loops of logrelations are allowed inside a      Only logrelations and FOR loops of logrelations are allowed inside a
6813      conditional statement in Pass3. This function ask for recursively      conditional statement in Pass3. This function ask for recursively
6814      checking these statements      checking these statements
6815  */  */
6816  static  static
6817  int Pass3CheckCondStatements(struct Instance *inst,  int Pass3CheckCondStatements(struct Instance *inst,
# Line 6849  int Pass3CheckCondStatements(struct Inst Line 6849  int Pass3CheckCondStatements(struct Inst
6849  }  }
6850    
6851  /**  /**
6852      Checking the statement list inside a CONDITIONAL statement in Pass3      Checking the statement list inside a CONDITIONAL statement in Pass3
6853  */  */
6854  static  static
6855  int Pass3CheckCOND(struct Instance *inst, struct Statement *statement)  int Pass3CheckCOND(struct Instance *inst, struct Statement *statement)
# Line 7386  int CheckWHEN(struct Instance *inst, str Line 7386  int CheckWHEN(struct Instance *inst, str
7386  }  }
7387    
7388    
7389  /* - - - - - - - - - - - - -  /* - - - - - - - - - - - - -
7390      Check SELECT Functions      Check SELECT Functions
7391  */  */
7392    
# Line 7463  int CheckSelectStatementList(struct Inst Line 7463  int CheckSelectStatementList(struct Inst
7463    
7464  /**  /**
7465      Current checking of the Select statement starts here.      Current checking of the Select statement starts here.
7466        
7467      Checking that the values of the set of values of each CASE of a      Checking that the values of the set of values of each CASE of a
7468      SELECT statement are appropriate. This is, they      SELECT statement are appropriate. This is, they
7469      are symbol, integer or boolean. The first part of the      are symbol, integer or boolean. The first part of the
# Line 8467  void MakeWhenReference(struct Instance * Line 8467  void MakeWhenReference(struct Instance *
8467    
8468  /**  /**
8469      creating list of reference for each CASE in a WHEN: (3) nested WHENs,      creating list of reference for each CASE in a WHEN: (3) nested WHENs,
8470      nested FOR loops etc.      nested FOR loops etc.
8471  */  */
8472  static  static
8473  void MakeWhenCaseReferences(struct Instance *inst,  void MakeWhenCaseReferences(struct Instance *inst,
# Line 9494  void ExecuteDefaultsInSELECTStat(struct Line 9494  void ExecuteDefaultsInSELECTStat(struct
9494      the possibility of different assignments to the same variable in      the possibility of different assignments to the same variable in
9495      different cases of the select. I need to execute only those in      different cases of the select. I need to execute only those in
9496      cases mathing the selection variables.      cases mathing the selection variables.
9497        
9498      @TODO It is becoming annoying to have so similar functions, I need      @TODO It is becoming annoying to have so similar functions, I need
9499      to create a robust and general function which considers all the      to create a robust and general function which considers all the
9500      possible applications.      possible applications.
# Line 9682  int Pass3ExecuteForStatements(struct Ins Line 9682  int Pass3ExecuteForStatements(struct Ins
9682  /**  /**
9683      @NOTE this function must not be called until all the rel,ext      @NOTE this function must not be called until all the rel,ext
9684      statements in sl pass their checks.      statements in sl pass their checks.
9685        
9686      This is because if any of the Executes fail      This is because if any of the Executes fail
9687      (returning 0) we abort (at least when assert is active).      (returning 0) we abort (at least when assert is active).
9688        
9689      @TODO This should be changed.      @TODO This should be changed.
9690  */  */
9691  static  static
# Line 10712  int Pass3RealCheckFOR (struct Instance * Line 10712  int Pass3RealCheckFOR (struct Instance *
10712  }  }
10713    
10714    
10715  /**  /**
10716      a currently unused function, with therefore unused subsidiary functions      a currently unused function, with therefore unused subsidiary functions
10717  */  */
10718  static  static
# Line 12374  struct Instance *NewInstantiateModel(str Line 12374  struct Instance *NewInstantiateModel(str
12374    
12375    
12376  /**  /**
12377      @return 1 if the type is uninstantiable as a sim or 0 otherwise      @return 1 if the type is uninstantiable as a sim or 0 otherwise
12378  */  */
12379  static  static
12380  int ValidRealInstantiateType(struct TypeDescription *def)  int ValidRealInstantiateType(struct TypeDescription *def)
# Line 12410  int ValidRealInstantiateType(struct Type Line 12410  int ValidRealInstantiateType(struct Type
12410      return 1;      return 1;
12411    default:    default:
12412      Asc_Panic(2, NULL, "Unknown definition type.\n");           /*NOTREACHED*/      Asc_Panic(2, NULL, "Unknown definition type.\n");           /*NOTREACHED*/
12413        
12414    }    }
12415  }  }
12416    
# Line 12457  struct Instance *NewRealInstantiate(stru Line 12457  struct Instance *NewRealInstantiate(stru
12457      return NULL; /* how did we get here? */      return NULL; /* how did we get here? */
12458    default:    default:
12459      Asc_Panic(2, NULL, "Unknown definition type.\n");   /*NOTREACHED*/      Asc_Panic(2, NULL, "Unknown definition type.\n");   /*NOTREACHED*/
12460        
12461    }    }
12462  }  }
12463    

Legend:
Removed from v.838  
changed lines
  Added in v.839

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