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