1 |
/* ASCEND modelling environment |
2 |
Copyright (C) 2006 Carnegie Mellon University |
3 |
Copyright (C) 1996 Benjamin Andrew Allan |
4 |
Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly |
5 |
|
6 |
This program is free software; you can redistribute it and/or |
7 |
modify it under the terms of the GNU General Public License |
8 |
as published by the Free Software Foundation; either version 2 |
9 |
of the License, or (at your option) any later version. |
10 |
|
11 |
This program is distributed in the hope that it will be useful, |
12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
GNU General Public License for more details. |
15 |
|
16 |
You should have received a copy of the GNU General Public License |
17 |
along with this program; if not, write to the Free Software |
18 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
19 |
*//** |
20 |
@file |
21 |
Ascend Instance Tree Type Definitions |
22 |
|
23 |
We have three types of 'scalar data' instances: |
24 |
|
25 |
- *_INST, |
26 |
- *_ATOM_INST, and |
27 |
- *_CONSTANT_INST, |
28 |
|
29 |
where * is REAL, INTEGER, BOOLEAN, SYMBOL and SET. |
30 |
|
31 |
(Sets are a little weird and should perhaps not be grouped under this |
32 |
wildcard) |
33 |
|
34 |
The word 'atom' is used a little loosely in naming of functions in |
35 |
this file. Many places it implies any of these types, but in some |
36 |
it implies exclusively *_ATOM_INST types. So read your headers carefully. |
37 |
|
38 |
Atoms are the 'variables' in the ASCEND language. |
39 |
|
40 |
*_INST are the children of Atoms. |
41 |
|
42 |
Constants are the 'structural variables' and 'real constants'. |
43 |
Constants do not have children and cannot be children of Atoms. |
44 |
Constants may be refined up until they are actually assigned |
45 |
a value (and in the case of reals a dimensionality). |
46 |
Constants in a clique (bad style, IMHO) all have the same value/dims: |
47 |
assigning one assigns them all. ARE_THE_SAME is usually a better style. |
48 |
|
49 |
@TODO Future work: |
50 |
LIST replaces SET in the Atom group; the atomic SET becoming the |
51 |
constant SET. |
52 |
REAL_ATOM_INST becomes the parametric reals of a model and |
53 |
a new SOLVER_ATOM_INST becomes the real variables of a model. |
54 |
|
55 |
-- BAA. |
56 |
|
57 |
Requires: |
58 |
none |
59 |
*//* |
60 |
by Ben Allan |
61 |
6/02/96 |
62 |
Last in CVS: $Revision: 1.8 $ $Date: 1997/07/18 12:30:11 $ $Author: mthomas $ |
63 |
*/ |
64 |
|
65 |
#ifndef ASC_INSTANCE_ENUM_H |
66 |
#define ASC_INSTANCE_ENUM_H |
67 |
|
68 |
/** addtogroup compiler Compiler |
69 |
@{ |
70 |
*/ |
71 |
|
72 |
#define IREAL 0x1 |
73 |
#define IINT 0x2 |
74 |
#define IBOOL 0x4 |
75 |
#define ISYM 0x8 |
76 |
#define ISET 0x10 |
77 |
#define IARR 0x20 |
78 |
#define IENUM 0x40 |
79 |
#define IFUND 0x80 |
80 |
#define ICONS 0x100 |
81 |
#define IATOM 0x200 |
82 |
#define ICOMP 0x400 |
83 |
#define IMOD 0x800 |
84 |
#define IRELN 0x1000 |
85 |
#define ILRELN 0x2000 |
86 |
#define IWHEN 0x4000 |
87 |
#define IAUTO 0x8000 |
88 |
#define IDUMB 0x10000 |
89 |
|
90 |
/** @todo future work */ |
91 |
|
92 |
#define ICHILDLESS (IFUND | ICONS | IWHEN | IDUMB) |
93 |
/* constants and fundamental types have no child list */ |
94 |
/* when's have no children. Better way of doing this? */ |
95 |
|
96 |
#define IERRINST ~(IREAL|IINT|IBOOL|ISYM|ISET|IARR|IENUM|IFUND|ICONS|IATOM| \ |
97 |
ICOMP|IMOD|IRELN|ILRELN|IWHEN|IAUTO|IDUMB) |
98 |
/**< |
99 |
any of these bits on is an error |
100 |
@TODO explain this |
101 |
*/ |
102 |
|
103 |
/** |
104 |
Values for use in declaration of enum inst_t. |
105 |
|
106 |
@NOTE these enum declarations are done using the '#define list trick' so that |
107 |
ASC_ENUM_DECLS can be re-purposed to give an string enum lookup table in |
108 |
instance_io.h. |
109 |
*/ |
110 |
#define ASC_ENUM_DECLS(D,X) \ |
111 |
D( ERROR_INST, 0) X /**< Deleted instance (error). */ \ |
112 |
D( SIM_INST, ICOMP) X /**< Simulation instance. */ \ |
113 |
D( MODEL_INST, ICOMP | IMOD) X /**< Model instance. */ \ |
114 |
D( REL_INST, IRELN) X /**< Relation(equality or inequality). */ \ |
115 |
D( LREL_INST, ILRELN) X /**< Logical relation( == || != ). */ \ |
116 |
D( WHEN_INST, IWHEN) X /**< WHEN instance */ \ |
117 |
D( ARRAY_INT_INST, ICOMP | IARR | IINT) X/**< Array instance integer */ \ |
118 |
D( ARRAY_ENUM_INST, ICOMP | IARR | ISYM) X/**< Array instance enumed */ \ |
119 |
D( REAL_INST, IFUND | IREAL) X /**< Real instance. */ \ |
120 |
D( INTEGER_INST, IFUND | IINT) X /**< Int instance. */ \ |
121 |
D( BOOLEAN_INST, IFUND | IBOOL) X /**< Boolean instance. */ \ |
122 |
D( SYMBOL_INST, IFUND | ISYM) X /**< Symbol instance. */ \ |
123 |
D( SET_INST, IFUND | ISET) X /**< Set instance. */ \ |
124 |
D( REAL_ATOM_INST, IATOM | IREAL) X /**< Real atomic instance. */ \ |
125 |
D( INTEGER_ATOM_INST, IATOM | IINT) X /**< Int atomic instance. */ \ |
126 |
D( BOOLEAN_ATOM_INST, IATOM | IBOOL) X /**< Boolean atomic instance. */ \ |
127 |
D( SYMBOL_ATOM_INST, IATOM | ISYM) X /**< Symbol atomic instance. */ \ |
128 |
D( SET_ATOM_INST, IATOM | ISET) X /**< Set atomic instance. */ \ |
129 |
D( REAL_CONSTANT_INST, ICONS | IREAL) X /**< Real constant instance. */ \ |
130 |
D( BOOLEAN_CONSTANT_INST,ICONS | IINT) X /**< Boolean constant instance. */ \ |
131 |
D( INTEGER_CONSTANT_INST,ICONS | IBOOL) X /**< Int constant instance. */ \ |
132 |
D( SYMBOL_CONSTANT_INST, ICONS | ISYM) X /**< Symbol constant instance. */ \ |
133 |
D( DUMMY_INST, IDUMB) /**< Dummy instance - unselected IS_A children. */ |
134 |
/* AUTO_INST = ICOMP | IMOD | IAUTO, */ /* future stack instance, would come after 'MODEL_INST' */ |
135 |
|
136 |
/** |
137 |
Instance types, see also comments at head of instance_enum.h. |
138 |
|
139 |
There are 'fundamental instances' which include REAL, INTEGER, BOOLEAN, |
140 |
SYMBOL and SET (suffixed with _INST). |
141 |
|
142 |
There are nonfundamental 'atomic' instances, REAL, INTEGER, BOOLEAR, SYMBOL |
143 |
and SET, (this time suffixed with _ATOM_INST). |
144 |
|
145 |
There are nonfundamental constant instances, REAL, BOOLEAR, INTEGER and |
146 |
SYMBOL (suffixed with _CONSTANT_INST). |
147 |
|
148 |
Then there are some special instances: |
149 |
- ERROR_INST -- a deleted instance |
150 |
- SIM_INST -- a simulation |
151 |
- MODEL_INST -- a model instance (used where...) |
152 |
- REL_INST -- a 'relation' i.e. equality or inequality (real-valued LHS and RHS) |
153 |
- LREL_INST -- a logical relation (true or false) (An '==' or '!=' between LHS and RHS). |
154 |
- WHEN_INST -- ... |
155 |
- ARRAY_INT_INST -- 'array instance integer'... |
156 |
- ARRAY_ENUM_INST -- 'array instance enumed'... |
157 |
- DUMMY_INST -- dummy instance - unselected 'IS_A' children. |
158 |
|
159 |
@see InstanceEnumLookup in instance_io.c |
160 |
*/ |
161 |
enum inst_t { |
162 |
#define ENUM_D(NAME,VALUE) NAME = VALUE |
163 |
#define ENUM_X , |
164 |
ASC_ENUM_DECLS(ENUM_D,ENUM_X) |
165 |
#undef ENUM_D |
166 |
#undef ENUM_X |
167 |
}; |
168 |
|
169 |
/** |
170 |
@NOTE *NEVER* allocate either one of these types! See instead the file |
171 |
instance_types.h. Note that all 'struct Instance *' types share the |
172 |
leading 't' member, but other than that they are not unionised so they |
173 |
are not all of the same length. So you need to be careful when making |
174 |
assumptions about the type of Instance (eg RealAtomInstance, etc) that you |
175 |
have. |
176 |
*/ |
177 |
struct Instance { |
178 |
enum inst_t t; |
179 |
}; |
180 |
|
181 |
/* @} */ |
182 |
|
183 |
#endif /* ASC_INSTANCE_ENUM_H */ |