1 |
/* ASCEND modelling environment |
2 |
Copyright (C) 2006 Carnegie Mellon University |
3 |
Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly |
4 |
|
5 |
This program is free software; you can redistribute it and/or modify |
6 |
it under the terms of the GNU General Public License as published by |
7 |
the Free Software Foundation; either version 2, or (at your option) |
8 |
any later version. |
9 |
|
10 |
This program is distributed in the hope that it will be useful, |
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
GNU General Public License for more details. |
14 |
|
15 |
You should have received a copy of the GNU General Public License |
16 |
along with this program; if not, write to the Free Software |
17 |
Foundation, Inc., 59 Temple Place - Suite 330, |
18 |
Boston, MA 02111-1307, USA. |
19 |
*//* |
20 |
by Tom Epperly |
21 |
Last in CVS: $Revision: 1.26 $ $Date: 2000/01/25 02:26:02 $ $Author: ballan $ |
22 |
*//** @file |
23 |
Basic Definitions for Ascend |
24 |
|
25 |
@NOTE |
26 |
This header and tcl/tk headers are known to conflict. This header |
27 |
should be included AFTER tcl.h or tk.h, not before. |
28 |
|
29 |
This module defines the fundamental constants used by the rest of |
30 |
Ascend and pulls in system headers. There is not a corresponding |
31 |
compiler.c. The variables declared in this header are defined |
32 |
in ascParse.y. |
33 |
*/ |
34 |
|
35 |
#ifndef ASC_COMPILER_H |
36 |
#define ASC_COMPILER_H |
37 |
|
38 |
#include <utilities/ascConfig.h> |
39 |
|
40 |
/* some influential defines and where to set them: |
41 |
ATDEBUG anontype.c -- controls anon type/relation sharing spew |
42 |
ASC_NO_POOL -- compiler -D flag. Turn off many memory recycles of small objects. |
43 |
ASC_NO_TRAPS -- compiler -D flag. Turn off traps/setjmp/longjump. |
44 |
*/ |
45 |
|
46 |
#ifndef TIMECOMPILER |
47 |
#define TIMECOMPILER 1 |
48 |
/**< Set to 1 for timing spew or 0 for not. */ |
49 |
#endif |
50 |
|
51 |
#ifndef CHECK_SYMBOL_USE |
52 |
#ifdef NDEBUG |
53 |
#define CHECK_SYMBOL_USE 0 |
54 |
#else |
55 |
#define CHECK_SYMBOL_USE 1 |
56 |
#endif |
57 |
#endif |
58 |
/**< |
59 |
* Define to check internal and client compliance with symbol |
60 |
* table requirements. 0 for production code. |
61 |
*/ |
62 |
|
63 |
#if CHECK_SYMBOL_USE |
64 |
|
65 |
#ifndef __GNUC__ |
66 |
/** strcmp() is dumb in string.h. We want it to whine a lot. */ |
67 |
extern int strcmp(CONST char *s1, CONST char *s2); |
68 |
#endif /* __GNU__ */ |
69 |
typedef CONST double symchar; |
70 |
#else /* !CHECK_SYMBOL_USE */ |
71 |
/* This is the real definition for production builds. */ |
72 |
typedef CONST char symchar; |
73 |
#endif /* CHECK_SYMBOL_USE */ |
74 |
/**< |
75 |
* Symchar exists so we can be very clear about strings coming from |
76 |
* symbol tables. If it's a pair of symchar *, it is a sufficient |
77 |
* comparison to compare the pointers if only equality is sought. |
78 |
* Sorting functions should use CmpSymchar. <br><br> |
79 |
* |
80 |
* WARNING: this typedef may change in the future when we get a |
81 |
* real symbol table. Avoid treating symchar directly as char *, |
82 |
* or your code will most likely not compile and not run.<br><br> |
83 |
* |
84 |
* Compile with CHECK_SYMBOL_USE defined to check for proper symchar |
85 |
* usage. This non-integral typedef forces all the whines on |
86 |
* virtually all compilers. The only way to shut it up is to use |
87 |
* AddSymbol() , symchars, and SCP() correctly. The visible typedef |
88 |
* does not change the actual symchar semantics, which is just a |
89 |
* string. Dereferencing a symchar when typedef'd as double will |
90 |
* usually cause a bus error unless the string happens to |
91 |
* occur at an 8-byte round address. It's very easy to spot |
92 |
* code which abuses our symbol table conventions now. |
93 |
*/ |
94 |
|
95 |
#define SCP(s) ((CONST char *)(s)) |
96 |
/**< |
97 |
* Returns the string ptr from a symchar ptr, whatever a symchar is. |
98 |
* If you need a just plain (char *) for I/O (tcl perhaps) just write |
99 |
* (char *)SCP(foo) |
100 |
*/ |
101 |
|
102 |
#define SCLEN(s) (*(int *)(((char *)s)-sizeof(int))) |
103 |
/**< |
104 |
* Returns, at considerably less expense, strlen(SCP(s)). |
105 |
* This macro looks up the length of the string in an int stored |
106 |
* just before the character string itself. |
107 |
*/ |
108 |
|
109 |
/** bracedtext atomic type. see braced.h */ |
110 |
struct bracechar; |
111 |
|
112 |
/* globals from ascParse.y that yacc won't put in ascParse.h generated. */ |
113 |
|
114 |
ASC_DLLSPEC int g_compiler_warnings; |
115 |
/**< |
116 |
* Flag to turn on ASCEND instantiation whinings in various ways. |
117 |
* higher values mean more spew. 0 = no warnings. |
118 |
* Variable is declared in ascParse.y. |
119 |
*/ |
120 |
|
121 |
ASC_DLLSPEC int g_parser_warnings; |
122 |
/**< |
123 |
* Flag to turn on lint-like ASCEND whinings in various ways. |
124 |
* higher values mean less spew. 0 = no warnings. |
125 |
* Variable is declared in typelint.c. |
126 |
*/ |
127 |
|
128 |
extern int g_parse_relns; |
129 |
/**< |
130 |
* Flag to abandon relation productions. |
131 |
* A very bad idea, but useful for benchmarking sometimes. |
132 |
*/ |
133 |
|
134 |
ASC_DLLSPEC int g_simplify_relations; |
135 |
/**< |
136 |
* Turn on or off relation simplification as noted in |
137 |
* relation.h. This variable is defined in relation.c and |
138 |
* headered here for UI exports. |
139 |
*/ |
140 |
|
141 |
ASC_DLLSPEC int g_use_copyanon; |
142 |
/**< |
143 |
* Turn on/off relation sharing. |
144 |
* |
145 |
* If TRUE, anonymous type detection is used to enable relation |
146 |
* sharing. This variable is defined in instantiate.c and |
147 |
* headered for export in compiler.h. |
148 |
*/ |
149 |
|
150 |
/* Simple types eligible to be ATOM children. */ |
151 |
#define BASE_REAL_NAME "real" |
152 |
#define BASE_INTEGER_NAME "integer" |
153 |
#define BASE_SYMBOL_NAME "symbol" |
154 |
#define BASE_BOOLEAN_NAME "boolean" |
155 |
#define BASE_SET_NAME "set" |
156 |
/* Simple types NOT eligible to be ATOM children. */ |
157 |
#define BASE_CON_REAL_NAME "real_constant" |
158 |
#define BASE_CON_INTEGER_NAME "integer_constant" |
159 |
#define BASE_CON_BOOLEAN_NAME "boolean_constant" |
160 |
#define BASE_CON_SYMBOL_NAME "symbol_constant" |
161 |
/* relation, etc names */ |
162 |
#define BASE_REL_NAME "relation" |
163 |
#define BASE_LOGREL_NAME "logic_relation" |
164 |
#define BASE_WHEN_NAME "when" |
165 |
#define BASE_EXT_NAME "EXTERNAL_MODEL" |
166 |
#define BASE_UNSELECTED "unSELECTed_part" |
167 |
/* |
168 |
* Don't randomly change these, as ASCEND MODEL code assumes they |
169 |
* are what they are. Changing these constitutes requiring a global |
170 |
* revision of ASCEND models. |
171 |
* |
172 |
* Don't strcmp with these to a SCP(symchar) string: use |
173 |
* CmpSymchar(GetBaseTypeName(enum type_kind),symchar) instead from |
174 |
* type_descio.h instead. |
175 |
*/ |
176 |
|
177 |
#endif /* ASC_COMPILER_H */ |
178 |
|