/[ascend]/trunk/base/generic/compiler/types.h
ViewVC logotype

Contents of /trunk/base/generic/compiler/types.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 67 - (show annotations) (download) (as text)
Wed Nov 30 16:31:29 2005 UTC (14 years, 10 months ago) by johnpye
File MIME type: text/x-chdr
File size: 8292 byte(s)
Standardised the "if seen" #defines to [ASC|ASCTK|ASCPY|ASCXX]_FILENAME_H
Fixed compile on FC3
1 /*
2 * Name, set and expr type definitions
3 * by Tom Epperly
4 * July 31, 1989
5 * Version: $Revision: 1.17 $
6 * Version control file: $RCSfile: types.h,v $
7 * Date last modified: $Date: 1998/03/25 00:32:31 $
8 * Last modified by: $Author: ballan $
9 *
10 * This file is part of the Ascend Language Interpreter.
11 *
12 * Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly
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 along
25 * with the program; if not, write to the Free Software Foundation, Inc., 675
26 * Mass Ave, Cambridge, MA 02139 USA. Check the file named COPYING.
27 */
28
29 /** @file
30 * Name, set and expr type definitions.
31 * <pre>
32 * When #including types.h, make sure these files are #included first:
33 * #include <limits.h>
34 * #include "fractions.h"
35 * #include "compiler.h"
36 * #include "dimen.h"
37 * #include "list.h"
38 * #include "functype.h"
39 * </pre>
40 * @todo Complete documentation of types.h.
41 */
42
43 #ifndef ASC_TYPES_H
44 #define ASC_TYPES_H
45
46 /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
47 * Please see usage notes at top of Expr_enum before modifying it.
48 * In particular, if you mess with it, make sure the defines still work.
49 */
50 #define NUM_EXPR_ENUMS 44
51 /**
52 * Expression token types. Note that several have
53 * multiple uses. Where more than 1 use is listed, only the first
54 * can be encountered in real valued equations.
55 * If you must add a type, do so after e_ipower.
56 * If you explicitly use the values of the enum instead of the
57 * symbolic name, put the string TOKEN_ENUM in a comment at
58 * the top of the function so that dependent code is easy to find
59 * in the event of drastic changes. If appropriate, also put in header.
60 * If you assign explicit values, do so without leaving a gap anywhere
61 * as the statistics code in check.c depends on values being 0-NUM_EXPR_ENUMS-1
62 */
63 enum Expr_enum {
64 /* shouldn't be seen, but just in case */
65 e_nop = 0, /**< null instruction */
66
67 /**< relation implementation kinds */
68 e_undefined = 1, /**< relation type undefined */
69 e_glassbox = 2, /**< glassbox relation type */
70 e_blackbox = 3, /**< blackbox relation type */
71 e_opcode = 4, /**< unimplemented opcode relation type. not seen */
72 e_token = 5, /**< token array infix/postfix relation type */
73
74 e_zero = 6, /**< symbolic processing <==> quiet wild real 0.0 */
75 e_real = 7, /**< real constant invariant across for loops */
76 e_int = 8, /**< integer constant invariant across for loops */
77 /* two types only to be seen in fully compiled token relations, and not
78 yet seen at all. These are the types for RelationRealConst terms and
79 RelationIntegerConst terms.
80 e_realconst = 7a,
81 e_intconst = 8a,
82 */
83 e_var = 9, /**< real variable */
84
85 e_uminus = 10, /**< unary minus */
86 e_func = 11, /**< unary real function */
87
88 e_plus = 12, /**< addition, set union */
89 e_minus = 13, /**< subtraction, set difference */
90 e_times = 14, /**< multiplication, set intersection */
91 e_divide = 15, /**< division */
92 e_power = 16, /**< a^x */
93 e_ipower = 17, /**< a^n */
94 /* Don't mess with the ordering of the above items */
95
96 /* Boolean Relations */
97 e_bol_token,
98
99 /* relational operators, at present somewhat overloaded. may be in any kind*/
100 e_notequal, /**< <> strict real inequality */
101 e_equal, /**< =, rather overloaded */
102 e_less, /**< < strict real inequality */
103 e_greater, /**< > strict real inequality */
104 e_lesseq, /**< <=, =< tolerant real inequality */
105 e_greatereq, /**< >=, => tolerant real inequality */
106 e_maximize, /**< MAXIMIZE by convention implies a unary minus, we minimize */
107 e_minimize, /**< MINIMIZE objective function. max and min both become lhs */
108 e_boolean_eq, /**< boolean equality */
109 e_boolean_neq, /**< boolean inequality */
110
111 /* ALL following are never encountered in compiled real relations */
112 e_boolean, /**< boolean constant */
113 /*e_var_bool, unimplemented boolean variable */
114 e_or, /**< OR */
115 e_and, /**< AND, ",", + */
116 e_not, /**< NOT */
117 e_satisfied, /**< Operator for boolean relations */
118
119 /* ALL following are never encountered in compiled bool relations */
120 e_subexpr, /**< intermediate symbolic processing */
121 e_const, /**< intermediate symbolic processing */
122 e_par, /**< intermediate symbolic processing */
123 e_sum, /**< unexpanded summation */
124 e_prod, /**< unexpanded product */
125
126 e_symbol, /**< symbol constant, symbol variable. needs to be fixed*/
127 /*e_var_sym unimplemented symbol variable */
128 e_set, /**< [set definition] */
129 e_in, /**< IN */
130 e_st, /**< | (such that) */
131 e_card, /**< CARD (set cardinality) */
132 e_choice, /**< CHOICE (set pick one arbitrary but consistent) */
133 e_union, /**< UNION (set union aka ",") */
134 e_inter, /**< INTERSECTION (set intersection, aka "*") */
135
136 /* miscellany */
137 e_qstring /**< a quoted string */
138 };
139
140 #define TOK_SCALAR_LOW e_zero
141 #define TOK_SCALAR_HIGH e_var
142 #define TOK_CONSTANT_LOW e_zero
143 #define TOK_CONSTANT_HIGH e_int
144 #define TOK_XARY_LOW e_uminus
145 #define TOK_XARY_HIGH e_ipower
146 #define TOK_BINARY_LOW e_plus
147 #define TOK_BINARY_HIGH e_ipower
148 #define TOK_UNARY_LOW e_uminus
149 #define TOK_UNARY_HIGH e_func
150 #define TOK_REAL_REL_LOW e_zero
151 #define TOK_REAL_REL_HIGH e_ipower
152 #define TOK_REL_TYPE_LOW e_glassbox
153 #define TOK_REL_TYPE_HIGH e_token
154
155 struct ExprReal {
156 double rvalue;
157 CONST dim_type *dimensions;
158 };
159
160 struct SatisfiedExpr {
161 struct ExprReal ser;
162 struct Name *sen;
163 };
164
165 union ExprUnion {
166 struct Name *nptr;
167 long ivalue;
168 symchar *sym_ptr; /**< symbol pointer */
169 struct Set *s;
170 struct ExprReal r;
171 CONST struct Func *fptr;
172 unsigned bvalue; /**< boolean value true or false */
173 struct SatisfiedExpr se;
174 };
175
176 struct Expr {
177 struct Expr *next;
178 enum Expr_enum t;
179 union ExprUnion v;
180 };
181
182 struct Range {
183 struct Expr *lower,*upper;
184 };
185
186 union SetUnion {
187 struct Expr *e; /**< single value */
188 struct Range r; /**< range of values lower..upper */
189 };
190
191 struct Set {
192 struct Set *next;
193 unsigned range; /**< 0 single expression, 1 range */
194 union SetUnion val;
195 unsigned long ref_count;
196 };
197
198 union NameUnion {
199 symchar *id; /**< symbol table member */
200 struct Set *s;
201 int attribute; /**< supported attribute name index */
202 };
203
204 struct Name {
205 /* this element info */
206 unsigned int bits;
207 /**<
208 * if NAMEBIT_IDTY 1,
209 * this name is an identifier (id) name. if 0, it's a set.
210 * if NAMEBIT_ATTR 1,
211 * this name is a supported attribute id that should be
212 * printed with a $ in front of it.
213 * if NAMEBIT_CHAT 1,
214 * chain this is part of contains a supported attribute
215 * element. This is determinable at parse time and it costs no
216 * more to store that fact here for all elements in the chain.
217 * This makes it possible to test conditionals much earlier,
218 * perhaps at parse stage.
219 * if NAMEBIT_AUTO 1,
220 * this name element is system generated.
221 */
222 #define NAMEBIT_IDTY 0x1
223 #define NAMEBIT_ATTR 0x2
224 #define NAMEBIT_CHAT 0x4
225 #define NAMEBIT_AUTO 0x8
226 struct Name *next;
227 union NameUnion val;
228 };
229
230 /**
231 * MAXINTREAL
232 * This is the largest e_real number we will convert to an e_int
233 * in certain relation simplifications.
234 * Note that there is an upper limit beyond which double precision
235 * floating point numbers cannot map uniquely to ints and back again.
236 * On DEC alphas (ieee 64 bit), this was found to be near 130000.
237 * The IEEE gurus will tell you OTHERWISE, of course.
238 */
239 #define MAXINTREAL 100000
240
241 #endif /* ASC_TYPES_H */
242

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22