1 |
/* |
2 |
* Set routine external definitions |
3 |
* by Tom Epperly |
4 |
* July 31, 1989 |
5 |
* Version: $Revision: 1.13 $ |
6 |
* Version control file: $RCSfile: sets.h,v $ |
7 |
* Date last modified: $Date: 1998/01/06 12:05:34 $ |
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 |
* Set routine external definitions. |
31 |
* <pre> |
32 |
* When #including sets.h, make sure these files are #included first: |
33 |
* #include "utilities/ascConfig.h" |
34 |
* #include "fractions.h" |
35 |
* #include "compiler.h" |
36 |
* #include "dimen.h" |
37 |
* #include "expr_types.h" |
38 |
* #include "list.h" |
39 |
* </pre> |
40 |
*/ |
41 |
|
42 |
#ifndef ASC_SETS_H |
43 |
#define ASC_SETS_H |
44 |
|
45 |
/** addtogroup compiler Compiler |
46 |
@{ |
47 |
*/ |
48 |
|
49 |
extern struct Set *CreateSingleSet(struct Expr *ex); |
50 |
/**< |
51 |
* <!-- struct Set *CreateSingleSet(ex) --> |
52 |
* <!-- struct Expr *ex; --> |
53 |
* Create a set node of type single with ex as its expression. |
54 |
*/ |
55 |
|
56 |
extern struct Set *CreateRangeSet(struct Expr *lower, struct Expr *upper); |
57 |
/**< |
58 |
* <!-- struct Set *CreateRangeSet(lower,upper) --> |
59 |
* <!-- struct Expr *lower,*upper; --> |
60 |
* Create a set node of type range with lower as its lower bound and |
61 |
* upper as its upper bound. |
62 |
*/ |
63 |
|
64 |
extern void LinkSets(struct Set *cur, struct Set *next); |
65 |
/**< |
66 |
* <!-- void LinkSets(cur,next) --> |
67 |
* <!-- struct Set *cur, *next; --> |
68 |
* Sets the next field of cur to next. |
69 |
*/ |
70 |
|
71 |
#ifdef NDEBUG |
72 |
#define NextSet(s) ((s)->next) |
73 |
#else |
74 |
#define NextSet(s) NextSetF(s) |
75 |
#endif |
76 |
/**< |
77 |
* Return the next set. (if in an expression of Set) |
78 |
* @param s CONST struct Set*, the set to query. |
79 |
* @return The next set as a struct Set*. |
80 |
* @see NextSetF() |
81 |
*/ |
82 |
extern struct Set *NextSetF(CONST struct Set *s); |
83 |
/**< |
84 |
* <!-- macro NextSet(s) --> |
85 |
* <!-- struct Set *NextSetF(s) --> |
86 |
* <!-- const struct Set *s; --> |
87 |
* <!-- Return the next set. (if in an expression of Set) --> |
88 |
* Implementation function for NextSet(). Do not call this |
89 |
* function directly - use NextSet() instead. |
90 |
*/ |
91 |
|
92 |
#ifdef NDEBUG |
93 |
#define SetType(s) ((s)->range) |
94 |
#else |
95 |
#define SetType(s) SetTypeF(s) |
96 |
#endif |
97 |
/**< |
98 |
* Return the type of the set. Single expression or range (..). |
99 |
* @param s CONST struct Set*, the set to query. |
100 |
* @return The type as an int. |
101 |
* @see SetTypeF() |
102 |
*/ |
103 |
extern int SetTypeF(CONST struct Set *s); |
104 |
/**< |
105 |
* <!-- macro SetType(s) --> |
106 |
* <!-- const int SetTypeF(s) --> |
107 |
* <!-- struct Set *s; --> |
108 |
* <!-- return the type of the set. (single expression or range (..))--> |
109 |
* Implementation function for SetType(). Do not call this |
110 |
* function directly - use SetType() instead. |
111 |
*/ |
112 |
|
113 |
#ifdef NDEBUG |
114 |
#define GetSingleExpr(s) ((s)->val.e) |
115 |
#else |
116 |
#define GetSingleExpr(s) GetSingleExprF(s) |
117 |
#endif |
118 |
/**< |
119 |
* Returns the expression for the single value. |
120 |
* Assumes that s is not a range. |
121 |
* @param s CONST struct Set*, the set to query. |
122 |
* @return The expression as an CONST struct Expr*. |
123 |
* @see GetSingleExprF() |
124 |
*/ |
125 |
extern CONST struct Expr *GetSingleExprF(CONST struct Set *s); |
126 |
/**< |
127 |
* <!-- macro GetSingleExpr(s) --> |
128 |
* <!-- const struct Expr *GetSingleExprF(s) --> |
129 |
* <!-- const struct Set *s; --> |
130 |
* <!-- Returns the expression for the single value. --> |
131 |
* <!-- Assumes that s is not a range. --> |
132 |
* Implementation function for GetSingleExpr(). Do not call this |
133 |
* function directly - use GetSingleExpr() instead. |
134 |
*/ |
135 |
|
136 |
#ifdef NDEBUG |
137 |
#define GetLowerExpr(s) ((s)->val.r.lower) |
138 |
#else |
139 |
#define GetLowerExpr(s) GetLowerExprF(s) |
140 |
#endif |
141 |
/**< |
142 |
* Returns the lower value expression. Assumes that s is a range. |
143 |
* @param s CONST struct Set*, the set to query. |
144 |
* @return The expression as an CONST struct Expr*. |
145 |
* @see GetLowerExprF() |
146 |
*/ |
147 |
extern CONST struct Expr *GetLowerExprF(CONST struct Set *s); |
148 |
/**< |
149 |
* <!-- macro GetLowerExpr(s) --> |
150 |
* <!-- const struct Expr *GetLowerExprF(s) --> |
151 |
* <!-- const struct Set *s; --> |
152 |
* <!-- Assumes that s is a range. Returns the lower value expression. --> |
153 |
* Implementation function for GetLowerExpr(). Do not call this |
154 |
* function directly - use GetLowerExpr() instead. |
155 |
*/ |
156 |
|
157 |
#ifdef NDEBUG |
158 |
#define GetUpperExpr(s) ((s)->val.r.upper) |
159 |
#else |
160 |
#define GetUpperExpr(s) GetUpperExprF(s) |
161 |
#endif |
162 |
/**< |
163 |
* Returns the upper value expression. Assumes that s is a range. |
164 |
* @param s CONST struct Set*, the set to query. |
165 |
* @return The expression as an CONST struct Expr*. |
166 |
* @see GetUpperExprF() |
167 |
*/ |
168 |
extern CONST struct Expr *GetUpperExprF(CONST struct Set *s); |
169 |
/**< |
170 |
* <!-- macro GetUpperExpr(s) --> |
171 |
* <!-- const struct Expr *GetUpperExprF(s) --> |
172 |
* <!-- const struct Set *s; --> |
173 |
* <!-- Assumes that s is a range. Returns the upper value expression. --> |
174 |
* Implementation function for GetUpperExpr(). Do not call this |
175 |
* function directly - use GetUpperExpr() instead. |
176 |
*/ |
177 |
|
178 |
extern struct Set *CopySetNode(CONST struct Set *s); |
179 |
/**< |
180 |
* <!-- struct Set *CopySetNode(s) --> |
181 |
* <!-- const struct Set *s; --> |
182 |
* Return a copy of s, but not anything pointed at by s->next. |
183 |
* copy->next = NULL. |
184 |
* Handles NULL input gracefully, returning NULL. |
185 |
*/ |
186 |
|
187 |
extern struct Set *CopySetList(CONST struct Set *s); |
188 |
/**< |
189 |
* <!-- struct Set *CopySetList(s) --> |
190 |
* <!-- const struct Set *s; --> |
191 |
* Return a copy of s. |
192 |
* Handles NULL input gracefully. |
193 |
*/ |
194 |
|
195 |
extern void DestroySetNode(struct Set *s); |
196 |
/**< |
197 |
* <!-- void DestroySetNode(s) --> |
198 |
* <!-- struct Set *s; --> |
199 |
* Destroys Set node given and the expression contents of the sets. |
200 |
* Pays not the slightest attention to the ref_count B.S. |
201 |
*/ |
202 |
|
203 |
extern void DestroySetList(struct Set *s); |
204 |
/**< |
205 |
* <!-- void DestroySetList(s) --> |
206 |
* <!-- struct Set *s; --> |
207 |
* Destroys Set chain given and the expression contents of the sets. |
208 |
* Handles NULL input gracefully. |
209 |
* Pays not the slightest attention to the ref_count B.S. |
210 |
*/ |
211 |
|
212 |
extern void DestroySetHead(struct Set *s); |
213 |
/**< |
214 |
* <!-- void DestroySetHead(s) --> |
215 |
* <!-- struct Set *s; --> |
216 |
* Destroys Set node given but not the expression contents of the node. |
217 |
* Normally should not be used. |
218 |
*/ |
219 |
|
220 |
extern struct Set *CopySetByReference(struct Set *s); |
221 |
/**< |
222 |
* <!-- struct Set *CopySetByReference(s) --> |
223 |
* <!-- const struct Set *s; --> |
224 |
* Increase ref_count. |
225 |
*/ |
226 |
|
227 |
extern void DestroySetListByReference(struct Set *s); |
228 |
/**< |
229 |
* <!-- void DestroySetListByReference(s) --> |
230 |
* <!-- struct Set *s; --> |
231 |
* Decrements the reference count and destroys the elements |
232 |
* in the set if the count is zero. |
233 |
*/ |
234 |
|
235 |
extern void DestroySetNodeByReference(struct Set *s); |
236 |
/**< |
237 |
* <!-- void DestroySetNodeByReference(s) --> |
238 |
* <!-- struct Set *s; --> |
239 |
* Decrease ref_count. |
240 |
*/ |
241 |
|
242 |
extern struct Set *JoinSetLists(struct Set *s1, struct Set *s2); |
243 |
/**< |
244 |
* <!-- void JoinSetLists(s1,s2) --> |
245 |
* <!-- struct Set *s1, *s2; --> |
246 |
* Append list s2 to the end of s1. Returns the pointer to the joined list. |
247 |
* If s1 is NULL, it simply returns s2. |
248 |
*/ |
249 |
|
250 |
extern struct Set *ReverseSetList(struct Set *s); |
251 |
/**< |
252 |
* <!-- struct Set *ReverseSetList(s) --> |
253 |
* <!-- struct Set *s; --> |
254 |
* Reverse the order of the set list. |
255 |
*/ |
256 |
|
257 |
extern int SetStructuresEqual(CONST struct Set *s1, CONST struct Set *s2); |
258 |
/**< |
259 |
* <!-- int SetStructuresEqual(s1,s2) --> |
260 |
* <!-- const struct Set *s1,*s2; --> |
261 |
* Return TRUE if and only if, s1 and s2 are structurally equivalent. |
262 |
*/ |
263 |
|
264 |
extern int CompareSetStructures(CONST struct Set *s1, CONST struct Set *s2); |
265 |
/**< |
266 |
* <!-- int CompareSetStructures(s1,s2) --> |
267 |
* <!-- const struct Set *s1,*s2; --> |
268 |
* Returns -1,0,1 as s1 < = > s2. |
269 |
* compares on length and on content value. |
270 |
* a range > an expression |
271 |
* a NULL Set * > all Sets. |
272 |
*/ |
273 |
|
274 |
extern unsigned long SetLength(CONST struct Set *s); |
275 |
/**< |
276 |
* Returns the number of elements in the set given. |
277 |
*/ |
278 |
|
279 |
extern struct gl_list_t *SetNameList(CONST struct Set *s); |
280 |
/**< |
281 |
* Returns a list containing all the names found in the Set given. |
282 |
* The names in the list belong to the set, so you can destroy |
283 |
* just the list when you are done with it. The list may be |
284 |
* empty. It should never be NULL. |
285 |
*/ |
286 |
|
287 |
extern char *CreateStrFromSet(CONST struct Set *set); |
288 |
/**< |
289 |
* <!-- char *CreateStrFromSet(set); --> |
290 |
* <!-- const struct Set *set; --> |
291 |
* Returns a copy of the string representation of the given set. |
292 |
*/ |
293 |
|
294 |
extern void sets_init_pool(void); |
295 |
/**< |
296 |
* Starts memory recycle. Do not call twice before stopping recycle. |
297 |
*/ |
298 |
|
299 |
extern void sets_destroy_pool(void); |
300 |
/**< |
301 |
* Stops memory recycle. Do not call while ANY Expr are outstanding. |
302 |
*/ |
303 |
|
304 |
extern void sets_report_pool(void); |
305 |
/**< |
306 |
* Write the pool report to ASCERR for the sets pool. |
307 |
*/ |
308 |
|
309 |
/* @} */ |
310 |
|
311 |
#endif /* ASC_SETS_H */ |
312 |
|