/[ascend]/trunk/ascend/compiler/mathinst.c
ViewVC logotype

Diff of /trunk/ascend/compiler/mathinst.c

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

revision 2643 by jpye, Thu Jan 19 23:49:44 2012 UTC revision 2644 by jpye, Tue Oct 9 12:29:42 2012 UTC
# Line 70  Line 70 
70  #include "tmpnum.h"  #include "tmpnum.h"
71  #include "mathinst.h"  #include "mathinst.h"
72    
73  static const char panic_msg[]="Incorrect type passed";  static const char panic_msg[]="Incorrect type '%s' passed";
74  #define PANIC_INCORRECT_TYPE Asc_Panic(2,__FUNCTION__,panic_msg);  #define PANIC_INCORRECT_TYPE(i) ASC_PANIC(panic_msg,instance_typename(i))
75    
76  enum Expr_enum GetInstanceRelationType(CONST struct Instance *i)  enum Expr_enum GetInstanceRelationType(CONST struct Instance *i)
77  {  {
# Line 79  enum Expr_enum GetInstanceRelationType(C Line 79  enum Expr_enum GetInstanceRelationType(C
79    if (i->t == REL_INST) {    if (i->t == REL_INST) {
80      return RELN_INST(i)->type; /* the implementation kind */      return RELN_INST(i)->type; /* the implementation kind */
81    }else{    }else{
82      PANIC_INCORRECT_TYPE;      PANIC_INCORRECT_TYPE(i);
83    }    }
84  }  }
85    
# Line 89  CONST struct relation *GetInstanceRelati Line 89  CONST struct relation *GetInstanceRelati
89    if (i->t == REL_INST) {    if (i->t == REL_INST) {
90      return RELN_INST(i)->ptr;      return RELN_INST(i)->ptr;
91    }else{    }else{
92      PANIC_INCORRECT_TYPE;      PANIC_INCORRECT_TYPE(i);
93    }    }
94  }  }
95    
# Line 101  CONST struct relation *GetInstanceRelati Line 101  CONST struct relation *GetInstanceRelati
101      *type = RELN_INST(i)->type;      *type = RELN_INST(i)->type;
102      return RELN_INST(i)->ptr;      return RELN_INST(i)->ptr;
103    }else{    }else{
104      PANIC_INCORRECT_TYPE;      PANIC_INCORRECT_TYPE(i);
105    }    }
106  }  }
107    
# Line 113  struct relation *GetInstanceRelToModify( Line 113  struct relation *GetInstanceRelToModify(
113      *type = RELN_INST(i)->type;      *type = RELN_INST(i)->type;
114      return RELN_INST(i)->ptr;      return RELN_INST(i)->ptr;
115    }else{    }else{
116      PANIC_INCORRECT_TYPE;      PANIC_INCORRECT_TYPE(i);
117    
118    }    }
119  }  }
# Line 125  CONST struct logrelation *GetInstanceLog Line 125  CONST struct logrelation *GetInstanceLog
125    if (i->t == LREL_INST) {    if (i->t == LREL_INST) {
126      return LRELN_INST(i)->ptr;      return LRELN_INST(i)->ptr;
127    }else{    }else{
128      PANIC_INCORRECT_TYPE;      PANIC_INCORRECT_TYPE(i);
129    
130    }    }
131  }  }
# Line 136  struct logrelation *GetInstanceLogRelToM Line 136  struct logrelation *GetInstanceLogRelToM
136    if (i->t == LREL_INST) {    if (i->t == LREL_INST) {
137      return LRELN_INST(i)->ptr;      return LRELN_INST(i)->ptr;
138    }else{    }else{
139      PANIC_INCORRECT_TYPE;      PANIC_INCORRECT_TYPE(i);
140    
141    }    }
142  }  }
# Line 147  CONST struct logrelation *GetInstanceLog Line 147  CONST struct logrelation *GetInstanceLog
147    if (InstanceKind(i) == LREL_INST) {    if (InstanceKind(i) == LREL_INST) {
148      return LRELN_INST(i)->ptr;      return LRELN_INST(i)->ptr;
149    }else{    }else{
150      PANIC_INCORRECT_TYPE;      PANIC_INCORRECT_TYPE(i);
151    
152    }    }
153  }  }
# Line 218  struct gl_list_t *GetInstanceWhenVars(CO Line 218  struct gl_list_t *GetInstanceWhenVars(CO
218    if (i->t == WHEN_INST) {    if (i->t == WHEN_INST) {
219      return W_INST(i)->bvar;      return W_INST(i)->bvar;
220    }else{    }else{
221      PANIC_INCORRECT_TYPE;      PANIC_INCORRECT_TYPE(i);
222    
223    }    }
224  }  }
# Line 229  struct gl_list_t *GetInstanceWhenCases(C Line 229  struct gl_list_t *GetInstanceWhenCases(C
229    if (i->t == WHEN_INST) {    if (i->t == WHEN_INST) {
230      return W_INST(i)->cases;      return W_INST(i)->cases;
231    }else{    }else{
232      PANIC_INCORRECT_TYPE;      PANIC_INCORRECT_TYPE(i);
   
233    }    }
234  }  }
235    
# Line 259  struct gl_list_t *GetInstanceWhens(CONST Line 258  struct gl_list_t *GetInstanceWhens(CONST
258      case WHEN_INST:      case WHEN_INST:
259        return W_INST(i)->whens;        return W_INST(i)->whens;
260      default:      default:
261      PANIC_INCORRECT_TYPE;      PANIC_INCORRECT_TYPE(i);
262    }    }
263  }  }
264    
# Line 269  void SetWhenVarList(struct Instance *i,s Line 268  void SetWhenVarList(struct Instance *i,s
268    if (i->t == WHEN_INST) {    if (i->t == WHEN_INST) {
269      W_INST(i)->bvar = whenvars;      W_INST(i)->bvar = whenvars;
270    }else{    }else{
271      PANIC_INCORRECT_TYPE;      PANIC_INCORRECT_TYPE(i);
272    }    }
273  }  }
274    
# Line 279  void SetWhenCases(struct Instance *i,str Line 278  void SetWhenCases(struct Instance *i,str
278    if (i->t == WHEN_INST) {    if (i->t == WHEN_INST) {
279      W_INST(i)->cases = whencases;      W_INST(i)->cases = whencases;
280    }else{    }else{
281       PANIC_INCORRECT_TYPE;       PANIC_INCORRECT_TYPE(i);
282    }    }
283  }  }
284    
# Line 304  void SetInstanceRelation(struct Instance Line 303  void SetInstanceRelation(struct Instance
303        Asc_Panic(2, __FUNCTION__, "Attempt to reassign RelationPointer.");        Asc_Panic(2, __FUNCTION__, "Attempt to reassign RelationPointer.");
304      }      }
305    }else{    }else{
306      PANIC_INCORRECT_TYPE;      PANIC_INCORRECT_TYPE(i);
307    }    }
308  }  }
309    
# Line 317  void SetInstanceLogRel(struct Instance * Line 316  void SetInstanceLogRel(struct Instance *
316        Asc_Panic(2, __FUNCTION__, "Attempted reassignment to logrel ptr");        Asc_Panic(2, __FUNCTION__, "Attempted reassignment to logrel ptr");
317      }      }
318    }else{    }else{
319      PANIC_INCORRECT_TYPE;      PANIC_INCORRECT_TYPE(i);
320    }    }
321  }  }
322    
# Line 381  void AddRelation(struct Instance *i, str Line 380  void AddRelation(struct Instance *i, str
380      }      }
381      break;      break;
382    default:    default:
383      PANIC_INCORRECT_TYPE;      PANIC_INCORRECT_TYPE(i);
384    }    }
385  }  }
386    
# Line 401  void RemoveRelation(struct Instance *i, Line 400  void RemoveRelation(struct Instance *i,
400      }      }
401      break;      break;
402    default:    default:
403      PANIC_INCORRECT_TYPE;      PANIC_INCORRECT_TYPE(i);
404    }    }
405  }  }
406    
# Line 433  unsigned long LogRelationsCount(CONST st Line 432  unsigned long LogRelationsCount(CONST st
432        return 0;        return 0;
433      }      }
434    default:    default:
435      PANIC_INCORRECT_TYPE;      PANIC_INCORRECT_TYPE(i);
436    }    }
437  }  }
438    
# Line 462  struct Instance *LogRelationsForInstance Line 461  struct Instance *LogRelationsForInstance
461        ASC_PANIC("c out of bounds in LogRelationsForInstance.\n");        ASC_PANIC("c out of bounds in LogRelationsForInstance.\n");
462      }      }
463    default:    default:
464      PANIC_INCORRECT_TYPE;      PANIC_INCORRECT_TYPE(i);
465    }    }
466    exit(2);/* NOT REACHED.  Needed to keep gcc from whining */    exit(2);/* NOT REACHED.  Needed to keep gcc from whining */
467  }  }
# Line 504  void AddLogRel(struct Instance *i, struc Line 503  void AddLogRel(struct Instance *i, struc
503      }      }
504      break;      break;
505    default:    default:
506      PANIC_INCORRECT_TYPE;      PANIC_INCORRECT_TYPE(i);
507    }    }
508  }  }
509    
# Line 545  void RemoveLogRel(struct Instance *i, st Line 544  void RemoveLogRel(struct Instance *i, st
544      }      }
545      break;      break;
546    default:    default:
547      PANIC_INCORRECT_TYPE;      PANIC_INCORRECT_TYPE(i);
548    }    }
549  }  }
550    
# Line 619  unsigned long WhensCount(struct Instance Line 618  unsigned long WhensCount(struct Instance
618        return 0;        return 0;
619      }      }
620    default:    default:
621      PANIC_INCORRECT_TYPE;      PANIC_INCORRECT_TYPE(i);
622    }    }
623  }  }
624    
# Line 691  struct Instance *WhensForInstance(struct Line 690  struct Instance *WhensForInstance(struct
690        ASC_PANIC("c out of bounds in WhensForInstance.\n");        ASC_PANIC("c out of bounds in WhensForInstance.\n");
691      }      }
692    default:    default:
693      PANIC_INCORRECT_TYPE;      PANIC_INCORRECT_TYPE(i);
694    }    }
695    exit(2);/* NOT REACHED.  Needed to keep gcc from whining */    exit(2);/* NOT REACHED.  Needed to keep gcc from whining */
696  }  }
# Line 784  void AddWhen(struct Instance *i, struct Line 783  void AddWhen(struct Instance *i, struct
783        gl_append_ptr(W_INST(i)->whens,(VOIDPTR)when);        gl_append_ptr(W_INST(i)->whens,(VOIDPTR)when);
784      break;      break;
785    default:    default:
786      PANIC_INCORRECT_TYPE;      PANIC_INCORRECT_TYPE(i);
787    }    }
788  }  }
789    
# Line 855  void RemoveWhen(struct Instance *i, stru Line 854  void RemoveWhen(struct Instance *i, stru
854      if (c>0) gl_delete(W_INST(i)->whens,c,0);      if (c>0) gl_delete(W_INST(i)->whens,c,0);
855      break;      break;
856    default:    default:
857      PANIC_INCORRECT_TYPE;      PANIC_INCORRECT_TYPE(i);
858    }    }
859  }  }
860    

Legend:
Removed from v.2643  
changed lines
  Added in v.2644

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