1 |
jds |
54 |
/* |
2 |
aw0a |
1 |
* Real Ascend Instance Types |
3 |
|
|
* by Tom Epperly |
4 |
|
|
* Version: $Revision: 1.29 $ |
5 |
|
|
* Version control file: $RCSfile: instance_types.h,v $ |
6 |
|
|
* Date last modified: $Date: 1998/02/05 16:36:22 $ |
7 |
|
|
* Last modified by: $Author: ballan $ |
8 |
|
|
* |
9 |
|
|
* This file is part of the Ascend Language Interpreter. |
10 |
|
|
* |
11 |
|
|
* Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly |
12 |
|
|
* Copyright (C) 1996 Benjamin Andrew Allan |
13 |
|
|
* |
14 |
|
|
* The Ascend Language Interpreter is free software; you can redistribute |
15 |
|
|
* it and/or modify it under the terms of the GNU General Public License as |
16 |
|
|
* published by the Free Software Foundation; either version 2 of the |
17 |
|
|
* License, or (at your option) any later version. |
18 |
|
|
* |
19 |
|
|
* The Ascend Language Interpreter is distributed in hope that it will be |
20 |
|
|
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
22 |
|
|
* General Public License for more details. |
23 |
|
|
* |
24 |
|
|
* You should have received a copy of the GNU General Public License |
25 |
|
|
* along with the program; if not, write to the Free Software Foundation, |
26 |
|
|
* Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check the file named |
27 |
|
|
* COPYING. |
28 |
jds |
54 |
*/ |
29 |
|
|
|
30 |
johnpye |
256 |
#ifndef ASC_INSTANCE_TYPES_H |
31 |
|
|
#define ASC_INSTANCE_TYPES_H |
32 |
jds |
54 |
|
33 |
johnpye |
1066 |
/** addtogroup compiler Compiler |
34 |
|
|
@{ |
35 |
|
|
*/ |
36 |
|
|
|
37 |
johnpye |
1039 |
#include "instance_enum.h" |
38 |
|
|
#include "fractions.h" |
39 |
|
|
#include "dimen.h" |
40 |
|
|
#include "type_desc.h" |
41 |
|
|
#include <general/list.h> |
42 |
|
|
#include "logical_relation.h" |
43 |
|
|
|
44 |
jds |
54 |
/** @file |
45 |
|
|
* Real Ascend Instance Types. |
46 |
|
|
* <pre> |
47 |
|
|
* When #including instance_types.h, make sure these files are #included first: |
48 |
|
|
* #include "instance_enum.h" |
49 |
aw0a |
1 |
* |
50 |
|
|
* Fields not to be accessed by any client program |
51 |
|
|
* except by the read-only functions in headers. |
52 |
|
|
* The write functions in atomvalue.h are also reasonable for |
53 |
|
|
* clients to use. |
54 |
|
|
* Clients should never have to include much beyond instance_enum.h. |
55 |
jds |
54 |
* |
56 |
aw0a |
1 |
* All of the following structures should be a multiple of *8*; |
57 |
|
|
* being a multiple of 4 is not sufficient. Pad if necessary. |
58 |
jds |
54 |
* RealInstance |
59 |
aw0a |
1 |
* IntegerInstance |
60 |
|
|
* BooleanInstance |
61 |
|
|
* SymbolInstance |
62 |
|
|
* SetInstance |
63 |
|
|
* and in fact any new instances that will be atom children. |
64 |
|
|
* Remember that these get *packed* in together and the order of |
65 |
|
|
* packing is not predictable in any way. If each is a multiple |
66 |
|
|
* of 8, then everybody will be properly aligned. |
67 |
|
|
* *AtomInstance and *Rel*Instance also need to be 8 byte |
68 |
|
|
* aligned so that we |
69 |
|
|
* start children in an 8 byte. |
70 |
|
|
* |
71 |
|
|
* This has to hold for both 4 and 8 byte ptr/long machines. |
72 |
jds |
54 |
* </pre> |
73 |
aw0a |
1 |
*/ |
74 |
|
|
|
75 |
|
|
#if SIZEOF_VOID_P == 8 |
76 |
|
|
#define LONGCHILDREN 1 |
77 |
|
|
#else |
78 |
|
|
#define LONGCHILDREN 0 |
79 |
|
|
#endif |
80 |
ben.allan |
33 |
/**< if LONGCHILDREN, then pointers are 8 bytes */ |
81 |
aw0a |
1 |
|
82 |
jds |
54 |
/* at present, I don't believe the following define is needed */ |
83 |
|
|
/* # if defined(_HPUX_SOURCE) || defined(_SGI_SOURCE) */ |
84 |
|
|
/* # define ALIGNSTUPID 1 */ |
85 |
|
|
/* # endif */ |
86 |
|
|
/* if ALIGNSTUPID, then 4 byte ptrs must fall on 8 byte boundaries */ |
87 |
|
|
/* any architecture with such a restrict should be summarily torched */ |
88 |
aw0a |
1 |
|
89 |
|
|
|
90 |
jds |
54 |
/* FUNDAMENTAL INSTANCES */ |
91 |
aw0a |
1 |
|
92 |
jds |
54 |
/** this aligns to 8 bytes with 4 or 8 byte pointers. size 32/40 */ |
93 |
aw0a |
1 |
struct RealInstance { |
94 |
jds |
54 |
enum inst_t t; /**< must always be first */ |
95 |
|
|
unsigned assigned; /**< the number of times it has been assigned */ |
96 |
aw0a |
1 |
struct Instance *parent_offset; |
97 |
|
|
CONST dim_type *dimen; |
98 |
|
|
double value; |
99 |
jds |
54 |
unsigned depth; /**< the depth of the assignment */ |
100 |
|
|
int padding; /**< required for either type of pointer */ |
101 |
aw0a |
1 |
}; |
102 |
|
|
|
103 |
jds |
54 |
/** this aligns to 8 bytes with 4 or 8 byte pointers. size 24/32 */ |
104 |
aw0a |
1 |
struct IntegerInstance { |
105 |
jds |
54 |
enum inst_t t; /**< must always be first */ |
106 |
|
|
unsigned assigned; /**< the number of times it has been assigned */ |
107 |
aw0a |
1 |
struct Instance *parent_offset; |
108 |
|
|
long value; |
109 |
jds |
54 |
unsigned depth; /**< the depth of the last assignment */ |
110 |
|
|
int padding; /**< required for either type of pointer */ |
111 |
aw0a |
1 |
}; |
112 |
|
|
|
113 |
jds |
54 |
/** size 24/24 */ |
114 |
aw0a |
1 |
struct BooleanInstance { |
115 |
|
|
enum inst_t t; |
116 |
jds |
54 |
unsigned assigned; /**< the number of times it has been assigned */ |
117 |
aw0a |
1 |
struct Instance *parent_offset; |
118 |
jds |
54 |
unsigned value; /**< 0 false, 1 true */ |
119 |
|
|
unsigned depth; /**< the depth of the last assignment */ |
120 |
aw0a |
1 |
#if (LONGCHILDREN == 0) |
121 |
|
|
int padding; |
122 |
|
|
#endif |
123 |
|
|
}; |
124 |
|
|
|
125 |
jds |
54 |
/** this aligns to 8 bytes with 4 or 8 byte pointers. size 16/24 */ |
126 |
aw0a |
1 |
struct SetInstance { |
127 |
|
|
enum inst_t t; |
128 |
jds |
54 |
unsigned int_set; /**< 0 indicates string set, |
129 |
|
|
1 indicates an integer set */ |
130 |
aw0a |
1 |
struct Instance *parent_offset; |
131 |
jds |
54 |
struct set_t *list; /**< list of enumerated values, NULL |
132 |
|
|
indicates that it has not been assigned |
133 |
|
|
if HP_sUX 9/10 or SGI is stupid enough to misalign |
134 |
|
|
this structure, we will have to pad it with an int |
135 |
|
|
on both sides of *list */ |
136 |
aw0a |
1 |
}; |
137 |
|
|
|
138 |
jds |
54 |
/** this aligns to 8 bytes with 4 or 8 byte pointers. size 16/24 */ |
139 |
aw0a |
1 |
struct SymbolInstance { |
140 |
|
|
enum inst_t t; |
141 |
ben.allan |
33 |
unsigned assigned; /**< the number of times it has been assigned */ |
142 |
aw0a |
1 |
struct Instance *parent_offset; |
143 |
jds |
54 |
symchar *value; /**< NULL indicates unassigned */ |
144 |
aw0a |
1 |
}; |
145 |
|
|
|
146 |
|
|
|
147 |
jds |
54 |
/* TRUE ATOM INSTANCES */ |
148 |
|
|
/** the first one is a dummy of some importance. All the atomic |
149 |
aw0a |
1 |
* variable types should be conformable to this structure. It |
150 |
|
|
* is not by itself a structure that should ever exist. |
151 |
|
|
*/ |
152 |
|
|
struct CommonAtomInstance { |
153 |
|
|
enum inst_t t; |
154 |
|
|
VOIDPTR interface_ptr; |
155 |
jds |
54 |
struct gl_list_t *parents; /**< link to parents */ |
156 |
|
|
struct Instance *alike_ptr; /**< circular linked list of clique members */ |
157 |
|
|
struct TypeDescription *desc; /**< list of children pointers */ |
158 |
|
|
unsigned long visited; /**< visited counter */ |
159 |
|
|
unsigned long tmp_num; /**< used when an instance tree is being copied*/ |
160 |
|
|
unsigned int anon_flags; /**< anonymous field to be manipulated */ |
161 |
aw0a |
1 |
}; |
162 |
|
|
|
163 |
jds |
54 |
/** |
164 |
aw0a |
1 |
* The RealAtomInstance should be reimplemented with a number of |
165 |
|
|
* supported attributes (bounds, nominal, several boolean flags) |
166 |
|
|
* and then an explicit pointer to the child space since children |
167 |
|
|
* are expected to be rare. Making this pointer explicit will allow |
168 |
|
|
* the real atoms (of which there are a lot) to be pooled and save |
169 |
jds |
54 |
* a fair amount of memory on large problems.<br><br> |
170 |
|
|
* |
171 |
|
|
* aligns to 8 byte boundaries on 4 or 8 byte machines. size 56/96 |
172 |
aw0a |
1 |
*/ |
173 |
|
|
struct RealAtomInstance { |
174 |
|
|
enum inst_t t; |
175 |
|
|
VOIDPTR interface_ptr; |
176 |
jds |
54 |
struct gl_list_t *parents; /**< link to parents */ |
177 |
|
|
struct Instance *alike_ptr; /**< circular linked list of clique members */ |
178 |
|
|
struct TypeDescription *desc; /**< list of children pointers */ |
179 |
|
|
unsigned long visited; /**< visited counter */ |
180 |
|
|
unsigned long tmp_num; /**< used when an instance tree is being copied*/ |
181 |
|
|
unsigned int anon_flags; /**< anonymous field to be manipulated */ |
182 |
|
|
/* above should match with CommonAtomInstance */ |
183 |
|
|
/* atom value part */ |
184 |
|
|
double value; /**< value of real variable */ |
185 |
|
|
CONST dim_type *dimen; /**< dimensions */ |
186 |
|
|
struct gl_list_t *relations; /**< relations where this real appears */ |
187 |
|
|
unsigned int assigned; /**< the number of times it has been assigned */ |
188 |
|
|
unsigned int depth; /**< the depth of the last assignment */ |
189 |
|
|
/* An even number of child pointers are packed here, the last of which |
190 |
aw0a |
1 |
* may not be valid because the number of children may be odd. |
191 |
|
|
* This extra should be eliminated for LONG pointer machines. |
192 |
|
|
*/ |
193 |
jds |
54 |
/* After the child pointers comes the data space for the actual |
194 |
aw0a |
1 |
* children. |
195 |
|
|
*/ |
196 |
|
|
}; |
197 |
|
|
|
198 |
jds |
54 |
/** future work. |
199 |
|
|
* needs parser and interpretter support. Not yet used. |
200 |
|
|
* @todo Implement SolverAtomInstance. |
201 |
|
|
*/ |
202 |
aw0a |
1 |
struct SolverAtomInstance { |
203 |
|
|
enum inst_t t; |
204 |
|
|
VOIDPTR interface_ptr; |
205 |
jds |
54 |
struct gl_list_t *parents; /**< link to parents */ |
206 |
|
|
struct Instance *alike_ptr; /**< circular linked list of clique members */ |
207 |
|
|
struct TypeDescription *desc; /**< list of slow children pointers, by name */ |
208 |
|
|
unsigned long visited; /**< visited counter */ |
209 |
|
|
unsigned long tmp_num; /**< used when an instance tree is being copied */ |
210 |
|
|
/* above should match with CommonAtomInstance */ |
211 |
|
|
/* atom value part */ |
212 |
|
|
struct gl_list_t *relations; /**< relations where this real appears */ |
213 |
|
|
double value; /**< value of variable |
214 |
|
|
fast children, all sharing dimens */ |
215 |
|
|
double nominal; /**< value of variable scaling */ |
216 |
|
|
double lower; /**< value of variable lower bound */ |
217 |
|
|
double upper; /**< value of variable upper bound */ |
218 |
|
|
CONST dim_type *dimen; /**< dimensions */ |
219 |
|
|
struct Instance **carray; /**< array of pointers to slow children. |
220 |
|
|
Keep slow children in pools by type. |
221 |
|
|
This should be NULL most of the time. */ |
222 |
|
|
unsigned int flags; /**< boolean flags of the variable, both |
223 |
|
|
internal and external. must be at least |
224 |
|
|
32 bit int */ |
225 |
|
|
unsigned int depth; /**< the depth of the last assignment */ |
226 |
|
|
/* |
227 |
aw0a |
1 |
* An even number of child pointers are packed here, the last of which |
228 |
|
|
* may not be real because the number of children may be odd. |
229 |
|
|
* This extra should be eliminated for LONG pointer machines. |
230 |
|
|
*/ |
231 |
jds |
54 |
/* After the child pointers comes the data space for the actual |
232 |
aw0a |
1 |
* children. |
233 |
|
|
*/ |
234 |
|
|
}; |
235 |
jds |
54 |
|
236 |
|
|
/* |
237 |
aw0a |
1 |
* Bit field definition for boolean attributes. room to grow. |
238 |
|
|
* Define all these fields so that a default value of (0,OFF,FALSE) |
239 |
|
|
* is the appropriate setting for 'typical' uses of ASCEND. |
240 |
|
|
*/ |
241 |
jds |
54 |
/* internal flags (compiler use) for solveratominstances: */ |
242 |
|
|
#define SOL_ASSIGNED 0x1 /**< atom value ever assigned */ |
243 |
|
|
/* external flags (user interface/solver use) for solveratominstances: */ |
244 |
|
|
#define SOL_FIXED 0x2 /**< variable fixed for solvers */ |
245 |
|
|
#define SOL_INACTIVELB 0x4 /**< lower bound to be ignored in solving */ |
246 |
|
|
#define SOL_INACTIVEUB 0x8 /**< upper bound to be ignored in solving */ |
247 |
|
|
#define SOL_ODESTATE 0x10 /**< variable state for ivp solver */ |
248 |
|
|
#define SOL_ODEOBSERVE 0x20 /**< variable recording for ivp */ |
249 |
|
|
#define SOL_ISZERO 0x40 /**< semicontinuous set 0 for sciconic */ |
250 |
|
|
#define SOL_INTEGER 0x80 /**< integer variable */ |
251 |
|
|
#define SOL_RELAXEDINT 0x100 /**< integer variable treat as relaxed */ |
252 |
|
|
#define SOL_INTERVAL 0x200 /**< interval real variable */ |
253 |
|
|
#define SOL_COMPLEX 0x400 /**< complex variable. lower -> imaginary part |
254 |
|
|
upper -> magnitude bound. ASCEND -> pot */ |
255 |
|
|
#define SOL_DOMAIN 0x800 /**< continuous variable defines domain */ |
256 |
|
|
#define SOL_ODEINDEP 0x1000 /**< independent variable in ODE/BVP */ |
257 |
|
|
#define SOL_NODOF 0x2000 /**< user doesn't want to see var in DOF */ |
258 |
|
|
#define SOL_PARAMETRIC 0x4000 /**< whatever that means to a solver */ |
259 |
|
|
#define SOL_INTENSIVE 0x8000 /**< physics/che intensive property variable */ |
260 |
|
|
#define SOL_NONBASIC 0x10000 /**< in DOF of optimization problem |
261 |
|
|
2,4,8-0000 reserved for future */ |
262 |
|
|
/* external flags (solver/interface tool use) for solveratominstances: */ |
263 |
|
|
#define SOL_TIGHTLB 0x100000 /**< value at or near lower */ |
264 |
|
|
#define SOL_TIGHTUB 0x200000 /**< value at or near upper */ |
265 |
|
|
#define SOL_NOELIG 0x400000 /**< variable not eligible to be fixed in DOF */ |
266 |
johnpye |
256 |
|
267 |
jds |
54 |
/* note that the above bit positions need to be settled on still. */ |
268 |
aw0a |
1 |
|
269 |
jds |
54 |
/** aligns to 8 on 4 and 8 byte compilers with compiler pad after t, depth */ |
270 |
aw0a |
1 |
struct IntegerAtomInstance { |
271 |
|
|
enum inst_t t; |
272 |
|
|
VOIDPTR interface_ptr; |
273 |
jds |
54 |
struct gl_list_t *parents; /**< link to parents */ |
274 |
aw0a |
1 |
struct Instance *alike_ptr; |
275 |
jds |
54 |
struct TypeDescription *desc; /**< usefull type description information */ |
276 |
aw0a |
1 |
unsigned long visited; |
277 |
jds |
54 |
unsigned long tmp_num; /**< used when an instance tree is being copied*/ |
278 |
|
|
unsigned int anon_flags; /**< anonymous field to be manipulated */ |
279 |
|
|
/* above should match with CommonAtomInstance */ |
280 |
|
|
/* atom value part */ |
281 |
|
|
unsigned int assigned; /**< the number of times it has been assigned */ |
282 |
|
|
struct gl_list_t *whens; /**< link to whens on which it appears */ |
283 |
|
|
unsigned int depth; /**< the depth of the last assignment */ |
284 |
|
|
long value; /**< integer value */ |
285 |
|
|
/* |
286 |
aw0a |
1 |
* An even number of child pointers are packed here, the last of which |
287 |
|
|
* may not be real because the number of children may be odd. |
288 |
|
|
* This extra should be eliminated for LONG pointer machines. |
289 |
|
|
*/ |
290 |
jds |
54 |
/* After the child pointers comes the data space for the actual |
291 |
aw0a |
1 |
* children. |
292 |
|
|
*/ |
293 |
|
|
}; |
294 |
|
|
|
295 |
jds |
54 |
/** this structure aligns (with compiler generated pad after t and flags |
296 |
|
|
* on 4 or 8 byte ptr machines. */ |
297 |
aw0a |
1 |
struct BooleanAtomInstance { |
298 |
|
|
enum inst_t t; |
299 |
|
|
VOIDPTR interface_ptr; |
300 |
jds |
54 |
struct gl_list_t *parents; /**< link to parent instances */ |
301 |
aw0a |
1 |
struct Instance *alike_ptr; |
302 |
jds |
54 |
struct TypeDescription *desc; /**< description of name,children, and size */ |
303 |
aw0a |
1 |
unsigned long visited; |
304 |
jds |
54 |
unsigned long tmp_num; /**< used when an instance tree is being copied*/ |
305 |
|
|
unsigned int anon_flags; /**< anonymous field to be manipulated */ |
306 |
|
|
/* above should match with CommonAtomInstance */ |
307 |
|
|
/* atom value part */ |
308 |
ben.allan |
33 |
struct gl_list_t *logrelations; /**< logrelations where this boolean appears */ |
309 |
|
|
struct gl_list_t *whens; /**< whens where this boolean appears*/ |
310 |
jds |
54 |
unsigned assigned; /**< the number of times it has been assigned */ |
311 |
|
|
unsigned depth; /**< the depth of the assignment */ |
312 |
|
|
unsigned value; /**< 0 false, 1 true */ |
313 |
|
|
int padding; /**< so that children have a square address */ |
314 |
|
|
/* |
315 |
aw0a |
1 |
* An even number of child pointers are packed here, the last of which |
316 |
|
|
* may not be real because the number of children may be odd. |
317 |
|
|
* This extra should be eliminated for LONG pointer machines. |
318 |
|
|
*/ |
319 |
jds |
54 |
/* After the child pointers comes the data space for the actual |
320 |
aw0a |
1 |
* children. |
321 |
|
|
*/ |
322 |
|
|
}; |
323 |
|
|
|
324 |
jds |
54 |
/** this aligns to 8 on 4 or 8 byte compilers with compiler pad after t */ |
325 |
aw0a |
1 |
struct SetAtomInstance { |
326 |
jds |
54 |
enum inst_t t; /**< type */ |
327 |
aw0a |
1 |
VOIDPTR interface_ptr; |
328 |
jds |
54 |
struct gl_list_t *parents; /**< link to parents instances */ |
329 |
aw0a |
1 |
struct Instance *alike_ptr; |
330 |
jds |
54 |
struct TypeDescription *desc; /**< description of name,children, and size */ |
331 |
aw0a |
1 |
unsigned long visited; |
332 |
jds |
54 |
unsigned long tmp_num; /**< used when an instance tree is being copied */ |
333 |
|
|
unsigned int anon_flags; /**< anonymous field to be manipulated */ |
334 |
|
|
/* above should match with CommonAtomInstance */ |
335 |
|
|
/* atom value part */ |
336 |
|
|
unsigned int_set; /**< 0 indicates string set, |
337 |
|
|
1 indicates integer set */ |
338 |
|
|
struct set_t *list; /**< list of enumerated values NULL indicates |
339 |
|
|
that is has not been assigned */ |
340 |
|
|
/* |
341 |
aw0a |
1 |
* An even number of child pointers are packed here, the last of which |
342 |
|
|
* may not be real because the number of children may be odd. |
343 |
|
|
* This extra should be eliminated for LONG pointer machines. |
344 |
|
|
*/ |
345 |
jds |
54 |
/* After the child pointers comes the data space for the actual |
346 |
aw0a |
1 |
* children. |
347 |
|
|
*/ |
348 |
|
|
}; |
349 |
|
|
|
350 |
jds |
54 |
/** this aligns to 8 on 4 or 8 byte compilers with compiler pad after t, flags */ |
351 |
aw0a |
1 |
struct SymbolAtomInstance { |
352 |
jds |
54 |
enum inst_t t; /**< type */ |
353 |
aw0a |
1 |
VOIDPTR interface_ptr; |
354 |
jds |
54 |
struct gl_list_t *parents; /**< link to parent instances */ |
355 |
|
|
struct Instance *alike_ptr; /**< ALIKE clique link */ |
356 |
|
|
struct TypeDescription *desc; /**< description of name, children, and size */ |
357 |
aw0a |
1 |
unsigned long visited; |
358 |
jds |
54 |
unsigned long tmp_num; /**< used when an instance is being copied */ |
359 |
|
|
unsigned int anon_flags; /**< anonymous field to be manipulated */ |
360 |
|
|
/* above should match with CommonAtomInstance */ |
361 |
|
|
struct gl_list_t *whens; /**< link to whens on which it appears */ |
362 |
|
|
/* atom value part */ |
363 |
|
|
symchar *value; /**< NULL indicates unassigned */ |
364 |
|
|
/* |
365 |
aw0a |
1 |
* An even number of child pointers are packed here, the last of which |
366 |
|
|
* may not be real because the number of children may be odd. |
367 |
|
|
* This extra should be eliminated for LONG pointer machines. |
368 |
|
|
*/ |
369 |
jds |
54 |
/* After the child pointers comes the data space for the actual |
370 |
aw0a |
1 |
* children. |
371 |
|
|
*/ |
372 |
|
|
}; |
373 |
|
|
|
374 |
jds |
54 |
/* CONSTANT INSTANCES */ |
375 |
|
|
/** The first one is a dummy of some importance. All the Constant |
376 |
aw0a |
1 |
* types should be conformable to this structure. It |
377 |
|
|
* is not by itself a structure that should ever exist. |
378 |
|
|
*/ |
379 |
|
|
struct CommonConstantInstance { |
380 |
|
|
enum inst_t t; |
381 |
|
|
unsigned int vflag; |
382 |
jds |
54 |
unsigned long visited; /**< visited counter */ |
383 |
|
|
unsigned long tmp_num; /**< used when an instance tree is being copied*/ |
384 |
aw0a |
1 |
VOIDPTR interface_ptr; |
385 |
jds |
54 |
unsigned int anon_flags; /**< anonymous field to be manipulated |
386 |
|
|
vflag is 32 bits with particular meanings: */ |
387 |
|
|
#define ci_ASSIGNED 0x1 /**< instance assigned yet? */ |
388 |
|
|
#define ci_BVAL 0x2 /**< boolean const instance value, reserved */ |
389 |
|
|
/* other binary flags constants need to be added here. */ |
390 |
aw0a |
1 |
}; |
391 |
|
|
|
392 |
jds |
54 |
/** @todo RealConstantInstance should probably be pooled, but isn't yet */ |
393 |
aw0a |
1 |
struct RealConstantInstance { |
394 |
|
|
enum inst_t t; |
395 |
jds |
54 |
unsigned vflag; /**< assigned? */ |
396 |
|
|
unsigned long visited; /**< visited counter */ |
397 |
|
|
unsigned long tmp_num; /**< used when an instance tree is being copied*/ |
398 |
aw0a |
1 |
VOIDPTR interface_ptr; |
399 |
jds |
54 |
unsigned int anon_flags; /**< anonymous field to be manipulated */ |
400 |
|
|
/* above should match with CommonConstantInstance */ |
401 |
aw0a |
1 |
double value; |
402 |
jds |
54 |
struct gl_list_t *parents; /**< link to parents */ |
403 |
|
|
struct Instance *alike_ptr; /**< circular linked list of clique members?*/ |
404 |
|
|
struct TypeDescription *desc; /**< description of name, size */ |
405 |
aw0a |
1 |
CONST dim_type *dimen; |
406 |
|
|
}; |
407 |
|
|
|
408 |
|
|
struct IntegerConstantInstance { |
409 |
|
|
enum inst_t t; |
410 |
jds |
54 |
unsigned vflag; /**< assigned? */ |
411 |
|
|
unsigned long visited; /**< visited counter */ |
412 |
|
|
unsigned long tmp_num; /**< used when an instance tree is being copied*/ |
413 |
aw0a |
1 |
VOIDPTR interface_ptr; |
414 |
jds |
54 |
unsigned int anon_flags; /**< anonymous field to be manipulated */ |
415 |
|
|
/* above should match with CommonConstantInstance */ |
416 |
aw0a |
1 |
long value; |
417 |
jds |
54 |
struct gl_list_t *parents; /**< link to parents */ |
418 |
ben.allan |
33 |
struct gl_list_t *whens; /**< whens where this integer appears*/ |
419 |
jds |
54 |
struct Instance *alike_ptr; /**< circular linked list of clique members?*/ |
420 |
|
|
struct TypeDescription *desc; /**< description of name, size */ |
421 |
aw0a |
1 |
}; |
422 |
|
|
|
423 |
|
|
struct BooleanConstantInstance { |
424 |
|
|
enum inst_t t; |
425 |
jds |
54 |
unsigned vflag; /**< assigned? */ |
426 |
|
|
unsigned long visited; /**< visited counter */ |
427 |
|
|
unsigned long tmp_num; /**< used when an instance tree is being copied*/ |
428 |
aw0a |
1 |
VOIDPTR interface_ptr; |
429 |
jds |
54 |
/* above should match with CommonConstantInstance */ |
430 |
|
|
unsigned int anon_flags; /**< anonymous field to be manipulated */ |
431 |
|
|
struct gl_list_t *parents; /**< link to parents */ |
432 |
ben.allan |
33 |
struct gl_list_t *whens; /**< whens where this boolean appears*/ |
433 |
jds |
54 |
struct Instance *alike_ptr; /**< circular linked list of clique members?*/ |
434 |
|
|
struct TypeDescription *desc; /**< description of name, size */ |
435 |
aw0a |
1 |
}; |
436 |
|
|
|
437 |
|
|
struct SymbolConstantInstance { |
438 |
|
|
enum inst_t t; |
439 |
jds |
54 |
unsigned vflag; /**< assigned */ |
440 |
|
|
unsigned long visited; /**< visited counter */ |
441 |
|
|
unsigned long tmp_num; /**< used when an instance tree is being copied*/ |
442 |
aw0a |
1 |
VOIDPTR interface_ptr; |
443 |
jds |
54 |
unsigned int anon_flags; /**< anonymous field to be manipulated */ |
444 |
|
|
/* above should match with CommonConstantInstance */ |
445 |
|
|
struct gl_list_t *parents; /**< link to parents */ |
446 |
ben.allan |
33 |
struct gl_list_t *whens; /**< whens where this symbol appears*/ |
447 |
jds |
54 |
struct Instance *alike_ptr; /**< circular linked list of clique members?*/ |
448 |
|
|
struct TypeDescription *desc; /**< description of name, size */ |
449 |
aw0a |
1 |
symchar *value; |
450 |
|
|
}; |
451 |
|
|
|
452 |
jds |
54 |
/** aligns on 4 or 8 byte ptr machines. size 48/88 |
453 |
|
|
* |
454 |
|
|
* @todo RelationInstance should probably be pooled, as RealAtomInstance, |
455 |
|
|
* but isn't yet for the same reasons. |
456 |
aw0a |
1 |
*/ |
457 |
|
|
struct RelationInstance { |
458 |
|
|
enum inst_t t; |
459 |
jds |
54 |
/* on long pointer machines, we expect C compiler to pad 4 bytes here */ |
460 |
aw0a |
1 |
VOIDPTR interface_ptr; |
461 |
jds |
54 |
struct Instance *parent[2]; /**< relations can have only two parents and |
462 |
|
|
normally they only have one. They have |
463 |
|
|
two only during an ARE_THE_SAME */ |
464 |
|
|
struct TypeDescription *desc; /**< holds the child list stuff */ |
465 |
aw0a |
1 |
unsigned long visited; |
466 |
jds |
54 |
unsigned long tmp_num; /**< used when an instance tree is being copied*/ |
467 |
|
|
unsigned int anon_flags; /**< anonymous field to be manipulated */ |
468 |
|
|
enum Expr_enum type; /**< what kind of the 5 possible types of reln |
469 |
|
|
type should be down in union RelationUnion*/ |
470 |
|
|
struct relation *ptr; /**< pointer to an instance relation */ |
471 |
|
|
struct gl_list_t *whens; /**< link to whens on which the rel appears */ |
472 |
|
|
struct gl_list_t *logrels; /**< link to satified's on which rel appears */ |
473 |
|
|
/* So child insts start packing on 8byte address after child ptrs, of |
474 |
aw0a |
1 |
* which there are (currently, 2/97) always an even number. |
475 |
|
|
*/ |
476 |
jds |
54 |
/* Not required anymore: |
477 |
aw0a |
1 |
* |
478 |
|
|
* #if (LONGCHILDREN == 0) |
479 |
|
|
* int padding; |
480 |
|
|
* #endif |
481 |
|
|
* |
482 |
|
|
* Not valid anymore: |
483 |
|
|
* |
484 |
|
|
* An even number of child pointers are packed here, the last of which |
485 |
|
|
* may not be real because the number of children may be odd. |
486 |
|
|
* This extra should be eliminated for LONG pointer machines. |
487 |
|
|
*/ |
488 |
|
|
|
489 |
jds |
54 |
/* After the child pointers comes the data space for the actual |
490 |
aw0a |
1 |
* children. |
491 |
|
|
*/ |
492 |
|
|
}; |
493 |
|
|
|
494 |
jds |
54 |
/** this aligns to 8 bytes with 4 or 8 byte pointers. size 48/88 */ |
495 |
aw0a |
1 |
struct LogRelInstance { |
496 |
|
|
enum inst_t t; |
497 |
jds |
54 |
/* on long pointer machines, we expect C compiler to pad 4 bytes here */ |
498 |
aw0a |
1 |
VOIDPTR interface_ptr; |
499 |
jds |
54 |
struct Instance *parent[2]; /**< log relations can have only two parents |
500 |
|
|
and normally they only have one.They have |
501 |
|
|
two only during an ARE_THE_SAME */ |
502 |
|
|
struct TypeDescription *desc; /**< holds the child list stuff */ |
503 |
aw0a |
1 |
unsigned long visited; |
504 |
jds |
54 |
unsigned long tmp_num; /**< used when an instance tree is being copied*/ |
505 |
|
|
struct logrelation *ptr; /**< pointer to an instance logical relation */ |
506 |
|
|
struct gl_list_t *whens; /**< link to whens on which the logrel appears */ |
507 |
|
|
struct gl_list_t *logrels; /**< link to satified's on which lrel appears */ |
508 |
|
|
unsigned int anon_flags; /**< anonymous field to be manipulated */ |
509 |
|
|
int padding; /**< so child insts start packing on 8byte |
510 |
|
|
address after child ptrs */ |
511 |
|
|
/* |
512 |
aw0a |
1 |
* All logrelations are the same type/size, because we require |
513 |
|
|
* exactly 1 refinement of the base definition. |
514 |
|
|
*/ |
515 |
jds |
54 |
/* After the child pointers comes the data space for the actual |
516 |
aw0a |
1 |
* children. This space must start on an 8 byte address. |
517 |
|
|
*/ |
518 |
|
|
}; |
519 |
|
|
|
520 |
jds |
54 |
/** Never, ever, allocate either one of these types. it's a dummy for the |
521 |
aw0a |
1 |
* instantiator. |
522 |
|
|
*/ |
523 |
|
|
struct PendInstance { |
524 |
|
|
enum inst_t t; |
525 |
|
|
VOIDPTR p; |
526 |
|
|
}; |
527 |
|
|
|
528 |
|
|
|
529 |
jds |
54 |
/* COMPOUND INSTANCES */ |
530 |
|
|
/* Note: All the compound instance structs, except ArrayChild, |
531 |
aw0a |
1 |
* and Automatic should have |
532 |
|
|
enum inst_t t; |
533 |
|
|
VOIDPTR pending_entry; |
534 |
|
|
* as the first two lines to match PendInstance above. |
535 |
|
|
* Relations of any type are NOT compound, other errors in |
536 |
|
|
* this file not withstanding. |
537 |
|
|
*/ |
538 |
jds |
54 |
/** this structure doesn't have to align on 4 byte ptr machines. size 48/88 */ |
539 |
aw0a |
1 |
struct ModelInstance { |
540 |
|
|
enum inst_t t; |
541 |
jds |
54 |
VOIDPTR pending_entry; /**< hold a word only pending.c can touch */ |
542 |
aw0a |
1 |
VOIDPTR interface_ptr; |
543 |
jds |
54 |
struct gl_list_t *parents; /**< link to parent instances */ |
544 |
|
|
struct gl_list_t *whens; /**< link to whens on which the model appears */ |
545 |
aw0a |
1 |
struct TypeDescription *desc; |
546 |
|
|
struct Instance *alike_ptr; |
547 |
jds |
54 |
struct BitList *executed; /**< bit list to keep track of which |
548 |
|
|
statements have been executed */ |
549 |
aw0a |
1 |
unsigned long visited; |
550 |
jds |
54 |
unsigned long tmp_num; /**< used when an instance tree is being copied*/ |
551 |
|
|
unsigned int anon_flags; /**< anonymous field to be manipulated */ |
552 |
aw0a |
1 |
#if (LONGCHILDREN == 1) |
553 |
jds |
54 |
int padding; /**< so ptrs start packing on 8byte address */ |
554 |
aw0a |
1 |
#endif |
555 |
jds |
54 |
/* The child pointers of model instances are packed here, but each is |
556 |
aw0a |
1 |
* different and there may not even be children. They are not |
557 |
|
|
* accessible through the struct, but only through InstanceChild. |
558 |
|
|
*/ |
559 |
|
|
}; |
560 |
|
|
|
561 |
jds |
54 |
/** This struct not in use anywhere yet, pending more semantics */ |
562 |
aw0a |
1 |
struct AutomaticInstance { |
563 |
|
|
enum inst_t t; |
564 |
jds |
54 |
/* this object never pending since it has no statements */ |
565 |
aw0a |
1 |
VOIDPTR interface_ptr; |
566 |
ben.allan |
33 |
struct Instance *sim_parent; /**< exactly one of these */ |
567 |
|
|
struct TypeDescription *desc; /**< UNIVERSAL and made at startup */ |
568 |
aw0a |
1 |
unsigned long visited; |
569 |
jds |
54 |
unsigned long tmp_num; /**< used when an instance tree is being copied*/ |
570 |
|
|
unsigned int anon_flags; /**< anonymous field to be manipulated */ |
571 |
aw0a |
1 |
|
572 |
jds |
54 |
struct gl_list_t *children; /**< unique unsorted list of child insts */ |
573 |
aw0a |
1 |
|
574 |
jds |
54 |
/* struct hashtable *childdata; |
575 |
aw0a |
1 |
* hash lookup of children. |
576 |
|
|
*/ |
577 |
jds |
54 |
/* note that in table there may be multiple names for a child that |
578 |
aw0a |
1 |
* occurs once in childdata. |
579 |
|
|
*/ |
580 |
jds |
54 |
/* HANDS OFF! --Ben */ |
581 |
aw0a |
1 |
}; |
582 |
|
|
|
583 |
jds |
54 |
/** First try of a WhenInstance needs to migrate toward the relations |
584 |
|
|
* |
585 |
|
|
* Would be nice to have a commoneqninstance type (CE_INST) |
586 |
aw0a |
1 |
* for rel,log,when. |
587 |
jds |
54 |
* |
588 |
|
|
* doesn't align as never has children. |
589 |
aw0a |
1 |
*/ |
590 |
|
|
struct WhenInstance { |
591 |
|
|
enum inst_t t; |
592 |
|
|
VOIDPTR interface_ptr; |
593 |
jds |
54 |
struct Instance *parent[2]; /**< relations can have only two parents and |
594 |
|
|
normally they only have one. They have |
595 |
|
|
two only during an ARE_THE_SAME */ |
596 |
ben.allan |
33 |
struct gl_list_t *whens; /**< used in case of nested whens */ |
597 |
|
|
struct gl_list_t *cases; /**< list of cases */ |
598 |
jds |
54 |
struct gl_list_t *bvar; /**< list of references to boolean variables */ |
599 |
|
|
struct TypeDescription *desc; /**< holds the child list stuff */ |
600 |
aw0a |
1 |
unsigned long visited; |
601 |
jds |
54 |
unsigned long tmp_num; /**< used when an instance tree is being copied*/ |
602 |
|
|
unsigned int anon_flags; /**< anonymous field to be manipulated */ |
603 |
aw0a |
1 |
}; |
604 |
|
|
|
605 |
jds |
54 |
/** are pooled, and therefore must align, but does so on its own */ |
606 |
aw0a |
1 |
struct ArrayChild { |
607 |
jds |
54 |
/* this object never pending, but member inst may be */ |
608 |
|
|
struct Instance *inst; /**< The instance. */ |
609 |
aw0a |
1 |
union { |
610 |
|
|
symchar *str; |
611 |
jds |
54 |
long index; /**< The name, may be string or index. */ |
612 |
aw0a |
1 |
} name; |
613 |
|
|
}; |
614 |
|
|
|
615 |
jds |
54 |
/** never has packed children. see gllist instead. */ |
616 |
aw0a |
1 |
struct ArrayInstance { |
617 |
|
|
enum inst_t t; |
618 |
jds |
54 |
VOIDPTR pending_entry; /**< hold a word only pending.c can touch */ |
619 |
aw0a |
1 |
VOIDPTR interface_ptr; |
620 |
jds |
54 |
struct TypeDescription *desc; /**< holds the child list stuff */ |
621 |
|
|
struct gl_list_t *parents; /**< link to parent instances */ |
622 |
|
|
struct gl_list_t *children; /**< link to children */ |
623 |
|
|
unsigned long indirected; /**< number of times of indirected */ |
624 |
aw0a |
1 |
unsigned long visited; |
625 |
jds |
54 |
unsigned long tmp_num; /**< used when an instance tree is being copied*/ |
626 |
|
|
unsigned int anon_flags; /**< anonymous field to be manipulated */ |
627 |
aw0a |
1 |
}; |
628 |
|
|
|
629 |
jds |
54 |
/** CONTAINER INSTANCE for interfaces. never pending. |
630 |
|
|
* no packed children, so never need align |
631 |
|
|
*/ |
632 |
|
|
struct SimulationInstance { |
633 |
|
|
/* these have *no* parents, yet */ |
634 |
aw0a |
1 |
enum inst_t t; |
635 |
|
|
VOIDPTR interface_ptr; |
636 |
jds |
54 |
struct TypeDescription *desc; /**< copy of the typedesc of its lone child */ |
637 |
|
|
symchar *name; /**< name of its lone child */ |
638 |
|
|
struct Instance **extvars; /**< external variables handles hack */ |
639 |
|
|
unsigned long tmp_num; /**< used when an instance tree is being copied*/ |
640 |
|
|
unsigned int anon_flags; /**< anonymous field to be manipulated */ |
641 |
|
|
/* add other interesting stuff here */ |
642 |
aw0a |
1 |
}; |
643 |
|
|
|
644 |
jds |
54 |
/** dummy instance for unselected children of models |
645 |
|
|
* no alignment issue |
646 |
|
|
*/ |
647 |
aw0a |
1 |
struct GlobalDummyInstance { |
648 |
|
|
enum inst_t t; |
649 |
jds |
54 |
/* never pending */ |
650 |
aw0a |
1 |
VOIDPTR interface_ptr; |
651 |
jds |
54 |
/**no link to parent instances */ |
652 |
|
|
/* when instances should ignore dummy completely */ |
653 |
aw0a |
1 |
struct TypeDescription *desc; |
654 |
jds |
54 |
/* all dummies are alike -- and the same */ |
655 |
|
|
/* dummy has not statements */ |
656 |
aw0a |
1 |
unsigned long visited; |
657 |
jds |
54 |
unsigned long ref_count; /**< mainly for debugging purposes */ |
658 |
|
|
unsigned long tmp_num; /**< used when an instance tree is being copied |
659 |
|
|
but CopyDummy==dummy always */ |
660 |
|
|
unsigned int anon_flags; /**< anonymous field to be manipulated */ |
661 |
|
|
/* why make life hell for the unsuspecting client? */ |
662 |
|
|
/* |
663 |
aw0a |
1 |
* In particular, the DUMMY_INST doesn't look like any category |
664 |
|
|
* (EQN,Compound,Atom,Constant) because a single statically allocated |
665 |
|
|
* instance of it stands in for all UNSELECTED_INSTANCEs that are |
666 |
|
|
* not compiled. |
667 |
|
|
* (This has nothing to do with the DummyIndexType.) |
668 |
|
|
*/ |
669 |
|
|
}; |
670 |
|
|
|
671 |
johnpye |
1066 |
/* @} */ |
672 |
|
|
|
673 |
johnpye |
256 |
#endif /* ASC_INSTANCE_TYPES_H */ |
674 |
jds |
54 |
|