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