1 |
/* |
/**< |
2 |
* Ascend Instance Tree Type Implementation Macros |
* Ascend Instance Tree Type Implementation Macros |
3 |
* by Tom Epperly & Ben Allan |
* by Tom Epperly & Ben Allan |
4 |
* 9/3/89 |
* 9/3/89 |
32 |
#ifndef __INSTMACRO_H_SEEN__ |
#ifndef __INSTMACRO_H_SEEN__ |
33 |
#define __INSTMACRO_H_SEEN__ |
#define __INSTMACRO_H_SEEN__ |
34 |
|
|
35 |
/* |
/**< |
36 |
*--------------------------------------------------------------------------- |
*--------------------------------------------------------------------------- |
37 |
* This header for instance and instantiator consumption only. |
* This header for instance and instantiator consumption only. |
38 |
* Clients keep your hands off! |
* Clients keep your hands off! |
39 |
*--------------------------------------------------------------------------- |
*--------------------------------------------------------------------------- |
40 |
*/ |
*/ |
41 |
|
|
42 |
/* temporary global variables used for debugging only */ |
/**< temporary global variables used for debugging only */ |
43 |
#ifndef NDEBUG |
#ifndef NDEBUG |
44 |
/* fundies */ |
/**< fundies */ |
45 |
extern struct RealInstance *g_r_inst; |
extern struct RealInstance *g_r_inst; |
46 |
extern struct IntegerInstance *g_i_inst; |
extern struct IntegerInstance *g_i_inst; |
47 |
extern struct BooleanInstance *g_b_inst; |
extern struct BooleanInstance *g_b_inst; |
48 |
extern struct SetInstance *g_s_inst; |
extern struct SetInstance *g_s_inst; |
49 |
extern struct SymbolInstance *g_sym_inst; |
extern struct SymbolInstance *g_sym_inst; |
50 |
/* constants */ |
/**< constants */ |
51 |
extern struct RealConstantInstance *g_rc_inst; |
extern struct RealConstantInstance *g_rc_inst; |
52 |
extern struct IntegerConstantInstance *g_ic_inst; |
extern struct IntegerConstantInstance *g_ic_inst; |
53 |
extern struct BooleanConstantInstance *g_bc_inst; |
extern struct BooleanConstantInstance *g_bc_inst; |
54 |
extern struct SetConstantInstance *g_sc_inst; |
extern struct SetConstantInstance *g_sc_inst; |
55 |
extern struct SymbolConstantInstance *g_symc_inst; |
extern struct SymbolConstantInstance *g_symc_inst; |
56 |
/* atoms */ |
/**< atoms */ |
57 |
extern struct RealAtomInstance *g_ra_inst; |
extern struct RealAtomInstance *g_ra_inst; |
58 |
extern struct IntegerAtomInstance *g_ia_inst; |
extern struct IntegerAtomInstance *g_ia_inst; |
59 |
extern struct BooleanAtomInstance *g_ba_inst; |
extern struct BooleanAtomInstance *g_ba_inst; |
60 |
extern struct SetAtomInstance *g_sa_inst; |
extern struct SetAtomInstance *g_sa_inst; |
61 |
extern struct SymbolAtomInstance *g_syma_inst; |
extern struct SymbolAtomInstance *g_syma_inst; |
62 |
/* other */ |
/**< other */ |
63 |
extern struct ModelInstance *g_mod_inst; |
extern struct ModelInstance *g_mod_inst; |
64 |
extern struct RelationInstance *g_rel_inst; |
extern struct RelationInstance *g_rel_inst; |
65 |
extern struct LogRelInstance *g_lrel_inst; |
extern struct LogRelInstance *g_lrel_inst; |
66 |
extern struct WhenInstance *g_when_inst; |
extern struct WhenInstance *g_when_inst; |
67 |
#endif |
#endif |
68 |
|
|
69 |
/* init parent list size */ |
/**< init parent list size */ |
70 |
#define AVG_CONSTANT_PARENTS 2L /* size to which all parent lists are */ |
#define AVG_CONSTANT_PARENTS 2L /**< size to which all parent lists are */ |
71 |
/* initialized for real constants */ |
/**< initialized for real constants */ |
72 |
#define AVG_ICONSTANT_PARENTS 20L /* size to which all parent lists are */ |
#define AVG_ICONSTANT_PARENTS 20L /**< size to which all parent lists are */ |
73 |
/* initialized for int constants */ |
/**< initialized for int constants */ |
74 |
#define AVG_PARENTS 2L /* size to which all parent lists are */ |
#define AVG_PARENTS 2L /**< size to which all parent lists are */ |
75 |
/* initialized */ |
/**< initialized */ |
76 |
#define AVG_CASES 2L /* size to which all cases lists are */ |
#define AVG_CASES 2L /**< size to which all cases lists are */ |
77 |
/* initialized (WHEN instance) */ |
/**< initialized (WHEN instance) */ |
78 |
#define AVG_WHEN 2L /* size to which all when lists are */ |
#define AVG_WHEN 2L /**< size to which all when lists are */ |
79 |
/* initialized (models, relations) */ |
/**< initialized (models, relations) */ |
80 |
#define AVG_RELATIONS 7L /* size to which all relation lists are */ |
#define AVG_RELATIONS 7L /**< size to which all relation lists are */ |
81 |
/* initialized */ |
/**< initialized */ |
82 |
#define AVG_LOGRELS 7L /* size to which all logical relation */ |
#define AVG_LOGRELS 7L /**< size to which all logical relation */ |
83 |
/* lists are initialized */ |
/**< lists are initialized */ |
84 |
#define AVG_ARY_CHILDREN 7L /* size to which all array children lists */ |
#define AVG_ARY_CHILDREN 7L /**< size to which all array children lists */ |
85 |
/* are initialized */ |
/**< are initialized */ |
86 |
#define UNDEFAULTEDREAL 0.0 |
#define UNDEFAULTEDREAL 0.0 |
87 |
|
|
88 |
#define MAX_EXTRELATIONS 20 /* maximum number of different ext relations */ |
#define MAX_EXTRELATIONS 20 /**< maximum number of different ext relations */ |
89 |
/* for a given simulation */ |
/**< for a given simulation */ |
90 |
|
|
91 |
/* type coercion definitions */ |
/**< type coercion definitions */ |
92 |
/* any */ |
/**< any */ |
93 |
#define INST(i) ((struct Instance *)(i)) |
#define INST(i) ((struct Instance *)(i)) |
94 |
/* other */ |
/**< other */ |
95 |
#define SIM_INST(i) ((struct SimulationInstance *)(i)) |
#define SIM_INST(i) ((struct SimulationInstance *)(i)) |
96 |
#define RELN_INST(i) ((struct RelationInstance *)(i)) |
#define RELN_INST(i) ((struct RelationInstance *)(i)) |
97 |
#define LRELN_INST(i) ((struct LogRelInstance *)(i)) |
#define LRELN_INST(i) ((struct LogRelInstance *)(i)) |
98 |
#define ARY_INST(i) ((struct ArrayInstance *)(i)) |
#define ARY_INST(i) ((struct ArrayInstance *)(i)) |
99 |
#define MOD_INST(i) ((struct ModelInstance *)(i)) |
#define MOD_INST(i) ((struct ModelInstance *)(i)) |
100 |
#define W_INST(i) ((struct WhenInstance *)(i)) |
#define W_INST(i) ((struct WhenInstance *)(i)) |
101 |
/* fundies */ |
/**< fundies */ |
102 |
#define R_INST(i) ((struct RealInstance *)(i)) |
#define R_INST(i) ((struct RealInstance *)(i)) |
103 |
#define I_INST(i) ((struct IntegerInstance *)(i)) |
#define I_INST(i) ((struct IntegerInstance *)(i)) |
104 |
#define B_INST(i) ((struct BooleanInstance *)(i)) |
#define B_INST(i) ((struct BooleanInstance *)(i)) |
105 |
#define S_INST(i) ((struct SetInstance *)(i)) |
#define S_INST(i) ((struct SetInstance *)(i)) |
106 |
#define SYM_INST(i) ((struct SymbolInstance *)(i)) |
#define SYM_INST(i) ((struct SymbolInstance *)(i)) |
107 |
/* constants */ |
/**< constants */ |
108 |
#define CI_INST(i) ((struct CommonConstantInstance *)(i)) |
#define CI_INST(i) ((struct CommonConstantInstance *)(i)) |
109 |
#define RC_INST(i) ((struct RealConstantInstance *)(i)) |
#define RC_INST(i) ((struct RealConstantInstance *)(i)) |
110 |
#define IC_INST(i) ((struct IntegerConstantInstance *)(i)) |
#define IC_INST(i) ((struct IntegerConstantInstance *)(i)) |
111 |
#define BC_INST(i) ((struct BooleanConstantInstance *)(i)) |
#define BC_INST(i) ((struct BooleanConstantInstance *)(i)) |
112 |
#define SYMC_INST(i) ((struct SymbolConstantInstance *)(i)) |
#define SYMC_INST(i) ((struct SymbolConstantInstance *)(i)) |
113 |
/* atoms */ |
/**< atoms */ |
114 |
#define CA_INST(i) ((struct CommonAtomInstance *)(i)) |
#define CA_INST(i) ((struct CommonAtomInstance *)(i)) |
115 |
#define RA_INST(i) ((struct RealAtomInstance *)(i)) |
#define RA_INST(i) ((struct RealAtomInstance *)(i)) |
116 |
#define BA_INST(i) ((struct BooleanAtomInstance *)(i)) |
#define BA_INST(i) ((struct BooleanAtomInstance *)(i)) |
120 |
#define SOL_INST(i) ((struct SolverAtomInstance *)(i)) |
#define SOL_INST(i) ((struct SolverAtomInstance *)(i)) |
121 |
|
|
122 |
#define D_INST(i) ((struct GlobalDummyInstance *)(i)) |
#define D_INST(i) ((struct GlobalDummyInstance *)(i)) |
123 |
/* constant inst assigned? */ |
/**< constant inst assigned? */ |
124 |
#define CIASS(i) (CI_INST(i)->vflag & ci_ASSIGNED) |
#define CIASS(i) (CI_INST(i)->vflag & ci_ASSIGNED) |
125 |
/* boolean constant value */ |
/**< boolean constant value */ |
126 |
#define BCV(i) ((BC_INST(i)->vflag & ci_BVAL) == ci_BVAL) |
#define BCV(i) ((BC_INST(i)->vflag & ci_BVAL) == ci_BVAL) |
127 |
|
|
128 |
/* parent macros for fundamental atoms real, integer, boolean, and set */ |
/**< parent macros for fundamental atoms real, integer, boolean, and set */ |
129 |
#define R_PARENT(i) \ |
#define R_PARENT(i) \ |
130 |
INST((unsigned long)i-(unsigned long)R_INST(i)->parent_offset) |
INST((unsigned long)i-(unsigned long)R_INST(i)->parent_offset) |
131 |
#define I_PARENT(i) \ |
#define I_PARENT(i) \ |
137 |
#define SYM_PARENT(i) \ |
#define SYM_PARENT(i) \ |
138 |
INST((unsigned long)i-(unsigned long)SYM_INST(i)->parent_offset) |
INST((unsigned long)i-(unsigned long)SYM_INST(i)->parent_offset) |
139 |
|
|
140 |
/* this should probably be conditionally defined by LONGCHILDREN |
/**< this should probably be conditionally defined by LONGCHILDREN |
141 |
* so that if LONGCHILDREN, just returns ivalue. |
* so that if LONGCHILDREN, just returns ivalue. |
142 |
*/ |
*/ |
143 |
#define NextHighestEven(ivalue) (((ivalue) & 1) ? ((ivalue)+1) : (ivalue)) |
#define NextHighestEven(ivalue) (((ivalue) & 1) ? ((ivalue)+1) : (ivalue)) |
144 |
|
|
145 |
/* child array macros */ |
/**< child array macros */ |
146 |
#define CHILD_ADR(iptr,type,c)\ |
#define CHILD_ADR(iptr,type,c)\ |
147 |
((struct Instance **)((unsigned long)iptr+(unsigned long)sizeof(type))+c) |
((struct Instance **)((unsigned long)iptr+(unsigned long)sizeof(type))+c) |
148 |
#define SIM_CHILD(i,c) CHILD_ADR(i,struct SimulationInstance,c) |
#define SIM_CHILD(i,c) CHILD_ADR(i,struct SimulationInstance,c) |
158 |
#define CLIST(in,type) (struct Instance **)((unsigned long)(in)+sizeof(type)) |
#define CLIST(in,type) (struct Instance **)((unsigned long)(in)+sizeof(type)) |
159 |
#define BASE_ADDR(in,num,type) INST((CLIST(in,type)) + NextHighestEven(num)) |
#define BASE_ADDR(in,num,type) INST((CLIST(in,type)) + NextHighestEven(num)) |
160 |
|
|
161 |
/* the whole use of BASE_ADDR needs to be reinvestigated. in particular |
/**< the whole use of BASE_ADDR needs to be reinvestigated. in particular |
162 |
* we need RealInstance children to be aligned to 8 bytes, not 2 bytes |
* we need RealInstance children to be aligned to 8 bytes, not 2 bytes |
163 |
* which is all NextHighestEven gives us. |
* which is all NextHighestEven gives us. |
164 |
*/ |
*/ |
169 |
#define NotAtom(i) NotAtomF(i) |
#define NotAtom(i) NotAtomF(i) |
170 |
#endif |
#endif |
171 |
extern int NotAtomF(struct Instance *); |
extern int NotAtomF(struct Instance *); |
172 |
/* |
/**< |
173 |
* macro NotAtom(i) |
* macro NotAtom(i) |
174 |
* NotAtomF(i) |
* NotAtomF(i) |
175 |
* Returns 1 if instance is compound (i.e. not relation, ATOM, constant, |
* Returns 1 if instance is compound (i.e. not relation, ATOM, constant, |
177 |
*/ |
*/ |
178 |
|
|
179 |
#endif |
#endif |
180 |
/* __INSTMACRO_H_SEEN__ */ |
/**< __INSTMACRO_H_SEEN__ */ |