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

Annotation of /trunk/base/generic/compiler/statement.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 148 - (hide annotations) (download) (as text)
Thu Dec 22 08:49:39 2005 UTC (13 years, 11 months ago) by johnpye
File MIME type: text/x-chdr
File size: 94832 byte(s)
Changed from 'TEST expr' syntax to 'ASSERT expr' syntax.
Corrected ConfigAscend ability to compile with CMSlv solver.
1 jds 54 /*
2 aw0a 1 * Statement list module
3     * by Tom Epperly
4     * August 8, 1989
5     * Version: $Revision: 1.26 $
6     * Version control file: $RCSfile: statement.h,v $
7     * Date last modified: $Date: 1998/04/21 23:49:51 $
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
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     */
29    
30 jds 54 /** @file
31     * Statement list module.
32     * <pre>
33 aw0a 1 * When #including statement.h, make sure these files are #included first:
34 jds 54 * #include "utilities/ascConfig.h"
35 aw0a 1 * #include "fractions.h"
36     * #include "compiler.h"
37     * #include "dimen.h"
38     * #include "types.h"
39     * #include "stattypes.h"
40 jds 54 * </pre>
41 aw0a 1 */
42    
43 jds 54 #ifndef __STATEMENT_H_SEEN__
44     #define __STATEMENT_H_SEEN__
45 aw0a 1
46 jds 54 extern void AddContext(struct StatementList *slist ,unsigned int c);
47     /**<
48     * <!-- AddContext(slist,c) -->
49 aw0a 1 *
50     * Adds the given context flags, c, to the statements in the list
51     * using the | operator, so that existing context
52     * bits are preserved (other than context_MODEL).
53 jds 54 * Handles NULL slist gracefully.<br><br>
54 aw0a 1 *
55     * This function is recursive. Those statements which contain another
56     * statement list will have those lists visited with this function,
57     * adding the flags we have here. Context is a cumulative notion,
58     * after all. Careless use will make this a tad expensive for
59 jds 54 * deeply nested code.<br><br>
60 aw0a 1 *
61     * All the create functions below return a statement (if successful)
62 jds 54 * which will have a context value of context_MODEL (0).<br><br>
63 aw0a 1 *
64     * VRR. Added the context flags for statements inside WHEN, SELECT and
65     * CONDITIONAL. 2/3/97 and SWITCH 29/3/97
66     */
67    
68    
69 jds 54 extern unsigned int SlistHasWhat(struct StatementList *slist);
70     /**<
71     * <!-- unsigned int SlistHasWhat(slist); -->
72 aw0a 1 * Returns an unsigned with the low bits set according to whether or
73     * not there is a statement of the indicated class in the slist given.
74     * The value is determined by examining the list, not by looking up
75 jds 54 * some attribute.<br><br>
76 aw0a 1 * The return type is valid as a contains field.
77     */
78    
79 jds 54 extern struct Statement *CreateALIASES(struct VariableList *vl,
80     struct Name *n);
81     /**<
82     * <!-- struct Statement *CreateALIASES(vl,n) -->
83     * <!-- struct VariableList *vl; -->
84     * <!-- struct Name *n; -->
85 aw0a 1 * Create an ALIASES statement.
86     * Initializes the reference count to one.
87     * The statement's module is set to the current open module.
88     * The statement's line number is set to the current line number.
89 jds 54 *
90     * @param vl variable list
91     * @param n instance name
92 aw0a 1 */
93    
94 jds 54 extern struct Statement *CreateARR(struct VariableList *aname,
95     struct VariableList *il,
96     struct VariableList *setname,
97     int intset,
98     struct Set *setvals);
99     /**<
100     * <!-- struct Statement *CreateARR(aname,il,setname,intset,setvals) -->
101     * <!-- struct VariableList *avlname; -->
102     * <!-- struct VariableList *il; -->
103     * <!-- struct VariableList *setvlname; -->
104     * <!-- int intset; -->
105     * <!-- struct Set *setvals; -->
106 aw0a 1 * Create a compound ALIASES-IS_A statement.
107     * VariableListLength(avlname) and VariableListLength(setname) should
108     * be 1.
109     * setvals may be NULL, rest may must be supplied.
110     * Initializes the reference count to one.
111     * The statement's module is set to the current open module.
112     * The statement's line number is set to the current line number.
113 jds 54 *
114     * @param aname avlname lhs name (in varlist form) of array being made.
115     * @param il rhs varlist of things to alias.
116     * @param setname name (in varlist form) of set instance to create which
117     * indexes avlname.
118     * @param intset symbol (0) or integer (1) set instance.
119     * @param setvals set expression for subscripts. Must evaluate to match
120     * count of items il evaluates to if setvals != NULL.
121 aw0a 1 */
122    
123 jds 54 extern struct Statement *CreateISA(struct VariableList *vl,
124     symchar *t,
125     struct Set *ta,
126     symchar *st);
127     /**<
128     * <!-- struct Statement *CreateISA(vl,t,ta,st) -->
129     * <!-- struct VariableList *vl; -->
130     * <!-- struct Set *ta; -->
131     * <!-- const char *t,*st; -->
132 aw0a 1 * Initializes the reference count to one.
133     * The statement's module is set to the current open module.
134     * The statement's line number is set to the current line number.
135 jds 54 *
136     * @param vl variable list
137     * @param t instance type
138     * @param ta arguments for type t
139     * @param st set type
140 aw0a 1 */
141    
142 jds 54 extern struct Statement *CreateWILLBE(struct VariableList *vl,
143     symchar *t,
144     struct Set *ta,
145     symchar *st,
146     struct Expr *cv);
147     /**<
148     * <!-- struct Statement *CreateWILLBE(vl,t,ta,st,cv) -->
149     * <!-- struct VariableList *vl; -->
150     * <!-- struct Set *ta; -->
151     * <!-- const char *t,*st; -->
152     * <!-- struct Expr *cv; -->
153 aw0a 1 * Initializes the reference count to one.
154     * The statement's module is set to the current open module.
155     * The statement's line number is set to the current line number.
156 jds 54 *
157     * @param vl variable list
158     * @param t instance type
159     * @param ta arguments for type t
160     * @param st set type (possibly)
161     * @param cv WILL_BE value specification.
162 aw0a 1 */
163    
164 jds 54 extern struct Statement *CreateIRT(struct VariableList *vl,
165     symchar *t,
166     struct Set *ta);
167     /**<
168     * <!-- struct Statement *CreateIRT(vl,t,ta) -->
169     * <!-- struct VariableList *vl; -->
170     * <!-- const char *t; -->
171     * <!-- struct Set *ta; -->
172 aw0a 1 * Create an IS_REFINED_TO statement node.
173     * The statement's module is set to the current open module.
174     * The statement's line number is set to the current line number.
175 jds 54 *
176     * @param vl variable list
177     * @param t instance type
178     * @param ta arguments for type t
179 aw0a 1 */
180    
181 jds 54 extern struct Statement *CreateAA(struct VariableList *vl);
182     /**<
183     * <!-- struct Statement *CreateAA(vl) -->
184     * <!-- struct VariableList *vl; -->
185 aw0a 1 * Create an ARE_ALIKE statement node.
186     * The statement's module is set to the current open module.
187     * The statement's line number is set to the current line number.
188 jds 54 *
189     * @param vl variable list
190 aw0a 1 */
191    
192 jds 54 extern struct Statement *CreateATS(struct VariableList *vl);
193     /**<
194     * <!-- struct Statement *CreateATS(vl) -->
195     * <!-- struct VariableList *vl; -->
196 aw0a 1 * Create an ARE_THE_SAME statement node.
197     * The statement's module is set to the current open module.
198     * The statement's line number is set to the current line number.
199 jds 54 *
200     * @param vl variable list
201 aw0a 1 */
202    
203 jds 54 extern struct Statement *CreateWBTS(struct VariableList *vl);
204     /**<
205     * <!-- struct Statement *CreateWBTS(vl) -->
206     * <!-- struct VariableList *vl; -->
207 aw0a 1 * Create an WILL_BE_THE_SAME statement node.
208     * The statement's module is set to the current open module.
209     * The statement's line number is set to the current line number.
210 jds 54 *
211     * @param vl variable list
212 aw0a 1 */
213    
214 jds 54 extern struct Statement *CreateWNBTS(struct VariableList *vl);
215     /**<
216     * <!-- struct Statement *CreateWNBTS(vl) -->
217     * <!-- struct VariableList *vl; -->
218 aw0a 1 * Create an WILL_NOT_BE_THE_SAME statement node.
219     * The statement's module is set to the current open module.
220     * The statement's line number is set to the current line number.
221 jds 54 *
222     * @param vl variable list
223 aw0a 1 */
224    
225 jds 54 extern struct Statement *CreateFOR(symchar *index,
226     struct Expr *expr,
227     struct StatementList *stmts,
228     enum ForOrder order,
229     enum ForKind kind);
230     /**<
231     * <!-- struct Statement *CreateFOR(index,expr,stmts,order,kind) -->
232     * <!-- struct Expr *expr; -->
233     * <!-- const char *index; -->
234     * <!-- struct StatementList *stmts; -->
235     * <!-- enum ForOrder order; -->
236     * <!-- enum ForKind kind; -->
237 aw0a 1 *
238     * Create a FOR statement node.
239     * The statement's module is set to the current open module.
240     * The statement's line number is set to the current line number.
241     * The statement list is checked for presence of relations,
242     * default assignments, and structural assignments and marked
243     * as needed.
244     * The context bit context_FOR will be set on the statements
245     * in the list stmts that have a context field.
246     */
247    
248 jds 54 extern struct Statement *CreateREL(struct Name *n,
249     struct Expr *relation);
250     /**<
251     * <!-- struct Statement *CreateREL(n,relation); -->
252     * <!-- struct Name *n; -->
253     * <!-- struct Expr *relation; -->
254 aw0a 1 * The statement's module is set to the current open module.
255     * The statement's line number is set to the current line number.
256     */
257    
258 jds 54 extern struct Statement *CreateLOGREL(struct Name *n,
259     struct Expr *logrel);
260     /**<
261     * <!-- struct Statement *CreateLOGREL(n,logrel); -->
262     * <!-- struct Name *n; -->
263     * <!-- struct Expr *logrel; -->
264 aw0a 1 * The statement's module is set to the current open module.
265     * The statement's line number is set to the current line number.
266     */
267    
268    
269 jds 54 extern struct Statement *CreateEXTERN(int mode,
270     struct Name *n,
271     CONST char *funcname,
272     struct VariableList *vl,
273     struct Name *data,
274     struct Name *scope);
275     /**<
276     * <!-- struct Statement *CreateEXTERN(mode,n,funcname,vl,data,scope); -->
277     * <!-- int mode; -- 0 = procedural; -->
278     * <!-- -- 1 = glassbox declarative; -->
279     * <!-- -- 2 = blackbox declarative -->
280     * <!-- struct Name *n; -->
281     * <!-- char *funcname; -->
282     * <!-- struct VariableList *vl; -->
283     * <!-- struct Name *data; -- additional user data or NULL; -->
284     * <!-- struct Name *scope; -- scope at which external relations are to -->
285     * <!-- be embedded. Applicable only to glassboxes -->
286 aw0a 1 * The statement's module is set to the current open module.
287     * The statement's line number is set to the current line number.
288 jds 54 * @param mode 0 = procedural; 1 = glassbox declarative; 2 = blackbox declarative
289     * @param data additional user data or NULL
290     * @param scope scope at which external relations are to be embedded.
291     * Applicable only to glassboxes.
292 aw0a 1 */
293    
294 jds 54 extern struct Statement *CreateFlow(enum FlowControl fc,
295     CONST char *msgtext);
296     /**<
297     * <!-- struct Statement *CreateFlow(fc,msgtext); -->
298 aw0a 1 * Create a BREAK, CONTINUE, FALL_THROUGH, RETURN, STOP as
299     * indicated by fc. If msgtext is not NULL, it is
300     * converted to a bracechar and stored as the message.
301     */
302    
303 jds 54 extern struct Statement *CreateREF(struct VariableList *vl,
304     symchar *ref_name,
305     symchar *st,
306     int mode);
307     /**<
308     * <!-- struct Statement *CreateREF(vl,ref_name,st,mode) -->
309     * <!-- struct VariableList *vl; -->
310     * <!-- const char *ref_name; -->
311     * <!-- const char *settype; -->
312     * <!-- int mode; -- 0 = copy semantics; (_IS_) -->
313     * <!-- -- 1 = pure reference semantics; (_REFERS_) -->
314 aw0a 1 * Creates a new REFERENCE type statement. ref_name is the name of
315     * the type or prototype being referred to.
316     * Initializes the reference count to one.
317     * The statement's module is set to the current open module.
318 jds 54 * The statement's line number is set to the current line number.<br><br>
319     *
320 aw0a 1 * NOT IMPLEMENTED.
321 jds 54 *
322     * @param mode 0 = copy semantics (_IS_);
323     * 1 = pure reference semantics; (_REFERS_)
324 aw0a 1 */
325    
326 jds 54 extern void SetRelationName(struct Statement *stat, struct Name *n);
327     /**<
328     * <!-- void SetRelationName(stat,n) -->
329     * <!-- struct Statement *stat; -->
330     * <!-- struct Name *n; -->
331 aw0a 1 * This procedure provides a mechanism for unnamed relations to be named.
332     * It should only be called on relation statements that are unnamed. It
333     * will name the relation with the name provided.
334     */
335    
336 jds 54 extern void SetLogicalRelName(struct Statement *stat, struct Name *n);
337     /**<
338     * <!-- void SetLogicalRelName(stat,n) -->
339     * <!-- struct Statement *stat; -->
340     * <!-- struct Name *n; -->
341 aw0a 1 * This procedure provides a mechanism for unnamed relations to be named.
342     * It should only be called on logcial relation statements that are unnamed.
343     * It will name the logical relation with the name provided.
344     */
345    
346    
347 jds 54 extern struct Statement *CreateRUN(struct Name *n, struct Name *type);
348     /**<
349     * <!-- struct Statement *CreateRUN(n,type) -->
350     * <!-- struct Name *n; -->
351     * <!-- struct Name *type; -->
352 aw0a 1 * Create a run statement with procedure name n, and/or class type.
353     * If type is non NULL, then so called 'class access is to be used to
354     * access the procedure. This is equivalent to the "::" in some object
355     * oriented languages.
356     * The statement's module is set to the current open module.
357     * The statement's line number is set to the current line number.
358     */
359    
360 jds 54 extern struct Statement *CreateCALL(symchar *n, struct Set *arglist);
361     /**<
362     * <!-- struct Statement *CreateCALL(n,argList) -->
363     * <!-- symchar *n; -->
364     * <!-- struct Set * argList; -->
365 aw0a 1 * Create a CALL statement with name n and arguments argList.
366     * argList may be NULL.
367     * The statement's module is set to the current open module.
368     * The statement's line number is set to the current line number.
369     */
370    
371 johnpye 148 extern struct Statement *CreateASSERT(struct Expr *ex);
372 johnpye 124 /**
373     @param ex test expression.
374    
375 johnpye 148 Create a ASSERT statement with test expression 'ex'. If the expression
376 johnpye 124 evaluates to false, an error message will be shown. Implemented for use
377     in 'self_test' functionality.
378     */
379    
380 jds 54 extern struct Statement *CreateIF(struct Expr *ex,
381     struct StatementList *ifblock,
382     struct StatementList *elseblock);
383     /**<
384     * <!-- struct Statement *CreateIF(ex,ifblock,elseblock) -->
385     * <!-- struct Expr *ex; -->
386     * <!-- struct StatementList *ifblock,*elseblock; -->
387 aw0a 1 * Create an IF-THEN-ELSE structure. If the else block is omitted,
388     * pass in NULL for elseblock.
389     * The statement's module is set to the current open module.
390     * The statement's line number is set to the current line number.
391     */
392    
393 jds 54 extern struct Statement *CreateWhile(struct Expr *test,
394     struct StatementList *body);
395     /**<
396     * <!-- struct Statement *CreateWhile(test,body) -->
397     * <!-- struct Expr *test; -->
398     * <!-- struct StatementList *body; -->
399 aw0a 1 * Create a WHILE-DO structure.
400     * The statement's module is set to the current open module.
401     * The statement's line number is set to the current line number.
402     */
403    
404 jds 54 extern struct Statement *CreateWHEN(struct Name *wname,
405     struct VariableList *vlist,
406     struct WhenList *wl);
407     /**<
408     * <!-- struct Statement *CreateWHEN(wname,vlist,wl) -->
409     * <!-- struct Name *wname; -->
410     * <!-- struct VariableList *vlist; -->
411     * <!-- struct WhenList *wl; -->
412 aw0a 1 * Crease a WHEN statement structure.
413     * The statement's module is set to the current open module.
414     * The statement's line number is set to the current line number.
415     */
416    
417 jds 54 extern struct Statement *CreateFNAME(struct Name *name);
418     /**<
419     * <!-- struct Statement *CreateFNAME(name) -->
420 aw0a 1 * Crease a FNAME statement structure.
421     * The statement's module is set to the current open module.
422     * The statement's line number is set to the current line number.
423     * Name is the name of a model or a relation inside a WHEN statement
424     */
425    
426 jds 54 extern struct Statement *CreateSWITCH(struct VariableList *v,
427     struct SwitchList *sw);
428     /**<
429     * <!-- struct Statement *CreateSWITCH(v,sw) -->
430     * <!-- struct VariableList *v; -->
431     * <!-- struct SelectList *sw; -->
432 aw0a 1 * Crease a SWITCH statement structure.
433     * The statement's module is set to the current open module.
434     * The statement's line number is set to the current line number.
435     */
436    
437 jds 54 extern struct Statement *CreateCOND(struct StatementList *stat);
438     /**<
439     * <!-- struct Statement *CreateCOND(stat) -->
440     * <!-- struct StatementList *stmts; -->
441 aw0a 1 * Create a CONDITIONAL statement structure.
442     * The statement's module is set to the current open module.
443     * The statement's line number is set to the current line number.
444     */
445    
446 jds 54 extern struct Statement *CreateSELECT(struct VariableList *v,
447     struct SelectList *sel);
448     /**<
449     * <!-- struct Statement *CreateSELECT(v,sel) -->
450     * <!-- struct VariableList *v; -->
451     * <!-- struct SelectList *sel; -->
452 aw0a 1 * Crease a SELECT statement structure.
453     * The statement's module is set to the current open module.
454     * The statement's line number is set to the current line number.
455     */
456    
457 jds 54 extern struct Statement *CreateASSIGN(struct Name *n,
458     struct Expr *rhs);
459     /**<
460     * <!-- struct Statement *CreateASSIGN(n,rhs); -->
461     * <!-- struct Name *n; -->
462     * <!-- struct Expr *rhs; -->
463 aw0a 1 * Create a default assignment statement node.
464     * The statement's module is set to the current open module.
465     * The statement's line number is set to the current line number.
466     */
467    
468 jds 54 extern struct Statement *CreateCASSIGN(struct Name *n, struct Expr *rhs);
469     /**<
470     * <!-- struct Statement *CreateCASSIGN(n,rhs); -->
471     * <!-- struct Name *n; -->
472     * <!-- struct Expr *rhs; -->
473 aw0a 1 * Create a structural assignment statement node.
474     * The statement's module is set to the current open module.
475     * The statement's line number is set to the current line number.
476     */
477    
478     #ifdef NDEBUG
479     #define StatementType(s) ((s)->t)
480     #else
481     #define StatementType(s) StatementTypeF(s)
482     #endif
483 jds 54 /**<
484 aw0a 1 * Return the statement type of s.
485 jds 54 * @param s CONST struct Statement*, the statement to query.
486     * @return The type as an enum stat_t.
487     * @see StatementTypeF()
488 aw0a 1 */
489 jds 54 extern enum stat_t StatementTypeF(CONST struct Statement *s);
490     /**<
491     * <!-- macro StatementType(s) -->
492     * <!-- enum stat_t StatementTypeF(s) -->
493     * <!-- const struct Statement *s; -->
494     * <!-- Return the statement type of s. -->
495     * Implementation function for StatementType(). Do not call this
496     * function directly - use StatementType() instead.
497     */
498 aw0a 1
499     #ifdef NDEBUG
500     #define StatementModule(s) ((s)->mod)
501     #else
502     #define StatementModule(s) StatementModuleF(s)
503     #endif
504 jds 54 /**<
505 aw0a 1 * Return the module that statement s was defined in.
506 jds 54 * @param s CONST struct Statement*, the statement to query.
507     * @return The defining module as a struct module_t*.
508     * @see StatementModuleF()
509 aw0a 1 */
510 jds 54 extern struct module_t *StatementModuleF(CONST struct Statement *s);
511     /**<
512     * <!-- macro StatementModule(s) -->
513     * <!-- struct module_t *StatementModuleF(s) -->
514     * <!-- const struct Statement *s; -->
515     * <!-- Return the module that statement s was defined in. -->
516     * Implementation function for StatementModule(). Do not call this
517     * function directly - use StatementModule() instead.
518     */
519 aw0a 1
520     #ifdef NDEBUG
521     #define StatementLineNum(s) ((s)->linenum)
522     #else
523     #define StatementLineNum(s) StatementLineNumF(s)
524     #endif
525 jds 54 /**<
526 aw0a 1 * Return the line number where statement s was defined.
527 jds 54 * @param s CONST struct Statement*, the statement to query.
528     * @return The line number as an unsigned long.
529     * @see StatementLineNumF()
530 aw0a 1 */
531 jds 54 extern unsigned long StatementLineNumF(CONST struct Statement *s);
532     /**<
533     * <!-- macro StatementLineNum(s) -->
534     * <!-- unsigned long StatementLineNumF(s) -->
535     * <!-- const struct Statement *s; -->
536     * <!-- Return the line number where statement s was defined. -->
537     * Implementation function for StatementLineNum(). Do not call this
538     * function directly - use StatementLineNum() instead.
539     */
540 aw0a 1
541     #ifdef NDEBUG
542     #define CopyStatement(s) if ((s)->ref_count<MAXREFCOUNT) (((s)->ref_count)++)
543     #else
544     #define CopyStatement(s) CopyStatementF(s)
545     #endif
546 jds 54 /**<
547 aw0a 1 * Make a new reference to statement s. This does not actually make a new
548     * copy in memory of the data in s: it only increases the reference count.
549     * If you need to modify the statement, you should use CopyToModify which
550     * is defined below.
551     * You don't need to worry about the count overflowing unless the user is
552     * utterly insane.
553 jds 54 * @param s CONST struct Statement*, the statement to query.
554     * @return The new reference as a struct Statement*.
555     * @see CopyStatementF()
556 aw0a 1 */
557 jds 54 extern struct Statement *CopyStatementF(struct Statement *s);
558     /**<
559     * <!-- struct Statement *CopyStatementF(s) -->
560     * <!-- struct Statement *s; -->
561     * <!-- Make a new reference to statement s. This does not actually make a new -->
562     * <!-- copy in memory of the data in s: it only increases the reference count. -->
563     * <!-- If you need to modify the statement, you should use CopyToModify which -->
564     * <!-- is defined below. -->
565     * <!-- You don't need to worry about the count overflowing unless the user is -->
566     * <!-- utterly insane. -->
567     * Implementation function for CopyStatement(). Do not call this
568     * function directly - use CopyStatement() instead.
569     */
570 aw0a 1
571 jds 54 extern void DestroyStatement(struct Statement *s);
572 ben.allan 33 /**<
573 jds 54 * <!-- void DeleteStatement(s) -->
574     * <!-- struct Statement *s; -->
575 aw0a 1 * Delete a reference to statement s. This make not actually deallocate
576     * the memory associated with s if there are still other references to
577     * the statement. If there aren't any, remaining references it deallocates
578     * the memory.
579     */
580    
581 jds 54 extern struct Statement *CopyToModify(struct Statement *s);
582 ben.allan 33 /**<
583 jds 54 * <!-- struct Statement *CopyToModify(s) -->
584     * <!-- struct Statement *s; -->
585 aw0a 1 * This will always make a new separate copy of the statement, so that
586     * it can be modified. The statement reference count is initialize to
587     * one.
588     */
589    
590     #ifndef NDEBUG
591     #define GetStatContext(s) ((s)->context)
592     #else
593     #define GetStatContext(s) GetStatContextF(s)
594     #endif
595 jds 54 /**<
596 aw0a 1 * Returns the context bits of the statement.
597     * If statement is of a type that doesn't have context bits,
598     * returns context_MODEL and issues warning message.
599 jds 54 * @param s CONST struct Statement*, the statement to query.
600     * @return The context as an unsigned int.
601     * @see GetStatContextF()
602 aw0a 1 */
603 jds 54 extern unsigned int GetStatContextF(CONST struct Statement *s);
604     /**<
605     * <!-- bits = GetStatContext(s); -->
606     * <!-- const struct Statement *s; -->
607     * <!-- Returns the context bits of the statement. -->
608     * <!-- If statement is of a type that doesn't have context bits, -->
609     * <!-- returns context_MODEL and issues warning message. -->
610     * Implementation function for GetStatContext(). Do not call this
611     * function directly - use GetStatContext() instead.
612     */
613 aw0a 1
614     #define StatInFOR(stat) (GetStatContext(stat)&context_FOR)
615 ben.allan 33 /**<
616 aw0a 1 * Returns a nonzero value (context_FOR) if the statement is inside
617     * the statement list of a FOR statement.
618     */
619    
620     #define StatInMETH(stat) (GetStatContext(stat)&context_METH)
621 ben.allan 33 /**<
622 aw0a 1 * Returns a nonzero value (context_METH) if the statement is inside
623     * the statement list of a method.
624     */
625    
626     #define StatWrong(stat) (GetStatContext(stat)&context_WRONG)
627 ben.allan 33 /**<
628 aw0a 1 * Returns a nonzero value (context_WRONG) if the statement is probably
629     * incorrect in all situations.
630     */
631    
632     #define StatInCOND(stat) (GetStatContext(stat)&context_COND)
633 ben.allan 33 /**<
634 aw0a 1 * Returns a nonzero value (context_COND) if the statement is inside
635     * the statement list of a CONDITIONAL statement.
636     */
637    
638     #define StatInWHEN(stat) (GetStatContext(stat)&context_WHEN)
639 ben.allan 33 /**<
640 aw0a 1 * Returns a nonzero value (context_WHEN) if the statement is inside
641     * the statement list of a WHEN statement.
642     */
643    
644     #define StatInSELECT(stat) (GetStatContext(stat)&context_SELECT)
645 ben.allan 33 /**<
646 aw0a 1 * Returns a nonzero value (context_SELECT) if the statement is inside
647     * the statement list of a SELECT statement.
648     */
649    
650     #define StatInIF(stat) (GetStatContext(stat)&context_IF)
651 ben.allan 33 /**<
652 aw0a 1 * Returns a nonzero value (context_IF) if the statement is inside
653     * the thenblock or elseblock of an IF statement.
654     */
655    
656     #define StatInSWITCH(stat) (GetStatContext(stat)&context_SWITCH)
657 ben.allan 33 /**<
658 aw0a 1 * Returns a nonzero value (context_SWITCH) if the statement is inside
659     * the statement list of a SWITCH statement.
660     */
661    
662     #define StatModelParameter(stat) (GetStatContext(stat)&context_MODPARAM)
663 ben.allan 33 /**<
664 aw0a 1 * Returns a nonzero value (context_MODPARAM) if the statement is
665     * in a parameterized type list. (or at least came from there).
666     */
667    
668 jds 54 extern void SetStatContext(struct Statement *s, unsigned int bits);
669 ben.allan 33 /**<
670 jds 54 * <!-- SetStatContext(s,bits) -->
671 aw0a 1 * Sets the context field of a statement to the value, bits, given.
672     * E.g. to turn on the FOR context bit,
673     * This function should only be used at parse time, and probably not
674     * then -- see MarkStatContext for the proper interface.
675     * Calling it on a statement type without a context field causes
676     * an exit(2) and an error message.
677     */
678    
679 jds 54 extern void MarkStatContext(struct Statement *s, unsigned int bits);
680 ben.allan 33 /**<
681 jds 54 * <!-- MarkStatContext(s,bits) -->
682 aw0a 1 * Adds the context bits given in bits to the context field of the
683     * statement given.
684     * E.g. to turn on the FOR context bit,
685     * MarkStatContext(s,context_FOR);
686     * This function should only be used at parse time.
687     * Unfortunately, until we have proof that the parser is err tight,
688     * we might also use this function at points in instantiation where
689     * we have proved that a statement is always going to be impossible.
690     */
691    
692 jds 54 extern struct VariableList *GetStatVarList(CONST struct Statement *s);
693 ben.allan 33 /**<
694 jds 54 * <!-- struct VariableList *GetStatVarListF(s) -->
695     * <!-- const struct Statement *s; -->
696 aw0a 1 * Returns the variable list of a
697     * IS_A, IS_REFINED_TO, WILL_BE, WILL_BE_THE_SAME,
698     * ARE_ALIKE, ARE_THE_SAME, ALIASES or ALIASES-ISA(ARR) statement.
699     * It must be passed one of these types of statement.
700     * Other statements will return NULL or crash.
701     */
702    
703 jds 54 /*== StateIs functions ==*/
704 aw0a 1
705     #ifdef NDEBUG
706     #define GetStatType(s) ((s)->v.i.type)
707     #else
708     #define GetStatType(s) GetStatTypeF(s)
709     #endif
710 jds 54 /**<
711 aw0a 1 * Return the type field of an IS_A, WILL_BE, or IS_REFINED_TO statement.
712     * It must be passed one of these types of statement.
713     * Other statements will return NULL or crash.
714 jds 54 * See also GetStatTypeDesc(), type_desc.h.
715     * @param s CONST struct Statement*, the statement to query.
716     * @return The type field as a symchar*.
717     * @see GetStatTypeF()
718 aw0a 1 */
719 jds 54 extern symchar *GetStatTypeF(CONST struct Statement *s);
720     /**<
721     * <!-- macro GetStatType(s) -->
722     * <!-- symchar *GetStatTypeF(s) -->
723     * <!-- const struct Statement *s; -->
724     * <!-- Return the type field of an IS_A, WILL_BE, or IS_REFINED_TO statement. -->
725     * <!-- It must be passed one of these types of statement. -->
726     * <!-- Other statements will return NULL or crash. -->
727     * <!-- See also GetStatTypeDesc, type_desc.h. -->
728     * Implementation function for GetStatType(). Do not call this
729     * function directly - use GetStatType() instead.
730     */
731 aw0a 1
732     #ifdef NDEBUG
733     #define GetStatTypeArgs(s) ((s)->v.i.typeargs)
734     #else
735     #define GetStatTypeArgs(s) GetStatTypeArgsF(s)
736     #endif
737 jds 54 /**<
738 aw0a 1 * Return the typeargs field of an IS_A, WILL_BE or IS_REFINED_TO statement.
739     * It must be passed one of these types of statement.
740 jds 54 * Proper WILL_BE statements should always return NULL.
741 aw0a 1 * Other statements will return NULL or crash.
742 jds 54 * @param s CONST struct Statement*, the statement to query.
743     * @return The typergs field as a CONST struct Set*.
744     * @see GetStatTypeArgsF()
745 aw0a 1 */
746 jds 54 extern CONST struct Set *GetStatTypeArgsF(CONST struct Statement *s);
747     /**<
748     * <!-- macro GetStatTypeArgs(s) -->
749     * <!-- const struct Set *GetStatTypeArgsF(s) -->
750     * <!-- const struct Statement *s; -->
751     * <!-- Return the typeargs field of an IS_A, WILL_BE or IS_REFINED_TO statement. -->
752     * <!-- It must be passed one of these types of statement. -->
753     * <!-- Proper WILLBE statements should always return NULL. -->
754     * <!-- Other statements will return NULL or crash. -->
755     * Implementation function for GetStatTypeArgs(). Do not call this
756     * function directly - use GetStatTypeArgs() instead.
757     */
758 aw0a 1
759 jds 54 extern unsigned int GetStatNeedsArgs(CONST struct Statement *s);
760 ben.allan 33 /**<
761 jds 54 * <!-- len = GetStatNeedsArgs(s); -->
762     * <!-- const struct Statement *s; -->
763     * <!-- unsigned int len; -->
764 aw0a 1 * Returns the number of arguments required to satisfy the type of the
765     * ISA or IRT statement given. Note that this number is not necessarily
766     * the number of arguments actually in the statement as the user wrote it.
767     * The number comes from the typedescription in the statement.
768     */
769    
770     #ifdef NDEBUG
771     #define GetStatSetType(s) ((s)->v.i.settype)
772     #else
773     #define GetStatSetType(s) GetStatSetTypeF(s)
774     #endif
775 jds 54 /**<
776 aw0a 1 * Return the type of set for an IS_A, WILL_BE.
777     * Often this will be NULL, which
778     * means that there is no "OF" part to the IS_A/WILL_BE.
779 jds 54 * @param s CONST struct Statement*, the statement to query.
780     * @return The type as a symchar*.
781     * @see GetStatSetTypeF()
782 aw0a 1 */
783 jds 54 extern symchar *GetStatSetTypeF(CONST struct Statement *s);
784     /**<
785     * <!-- macro GetStatSetType(s) -->
786     * <!-- symchar *GetStatSetTypeF(s) -->
787     * <!-- const struct Statement *s; -->
788     * <!-- Return the type of set for an IS_A, WILL_BE. -->
789     * <!-- Often this will be NULL, which -->
790     * <!-- means that there is no "OF" part to the IS_A/WILL_BE. -->
791     * Implementation function for GetStatSetType(). Do not call this
792     * function directly - use GetStatSetType() instead.
793     */
794 aw0a 1
795     #ifdef NDEBUG
796     #define GetStatCheckValue(s) ((s)->v.i.checkvalue)
797     #else
798     #define GetStatCheckValue(s) GetStatCheckValueF(s)
799     #endif
800 jds 54 /**<
801 aw0a 1 * Return the value expression for a WILLBE. Often this will be NULL,
802     * which means that there is no WITH_VALUE part to the WILL_BE.
803 jds 54 * @param s CONST struct Statement*, the statement to query.
804     * @return The expression as a CONST struct Expr*.
805     * @see GetStatCheckValueF()
806 aw0a 1 */
807 jds 54 extern CONST struct Expr *GetStatCheckValueF(CONST struct Statement *s);
808     /**<
809     * <!-- macro GetStatCheckValue(s) -->
810     * <!-- const struct Expr *GetStatCheckValueF(s) -->
811     * <!-- const struct Statement *s; -->
812     * <!-- Return the value expression for a WILLBE. Often this will be NULL, -->
813     * <!-- which means that there is no WITH_VALUE part to the WILL_BE. -->
814     * Implementation function for GetStatCheckValue(). Do not call this
815     * function directly - use GetStatCheckValue() instead.
816     */
817 aw0a 1
818 jds 54 /* * * StateAlias functions * * */
819 aw0a 1
820     #ifdef NDEBUG
821     #define AliasStatName(s) ((s)->v.ali.u.nptr)
822     #else
823     #define AliasStatName(s) AliasStatNameF(s)
824     #endif
825 jds 54 /**<
826 aw0a 1 * Return the Name RHS from a simple ALIASES statement.
827     * See stattypes.h for meaning of Name.
828 jds 54 * @param s CONST struct Statement*, the statement to query.
829     * @return The name as a CONST struct Name*.
830     * @see AliasStatNameF()
831 aw0a 1 */
832 jds 54 extern CONST struct Name *AliasStatNameF(CONST struct Statement *s);
833     /**<
834     * <!-- macro AliasStatName(s) -->
835     * <!-- struct Name *AliasStatNameF(s) -->
836     * <!-- Return the Name RHS from a simple ALIASES statement. -->
837     * <!-- See stattypes.h for meaning of Name. -->
838     * Implementation function for AliasStatName(). Do not call this
839     * function directly - use AliasStatName() instead.
840     */
841 aw0a 1
842     #ifdef NDEBUG
843     #define ArrayStatAvlNames(s) ((s)->v.ali.u.avlname)
844     #else
845     #define ArrayStatAvlNames(s) ArrayStatAvlNamesF(s)
846     #endif
847 jds 54 /**<
848 aw0a 1 * Return the LHS (new array(s)) being defined from an ARR statement.
849     * See stattypes.h for meaning of vlist.
850     * syntax is currently:
851 jds 54 * <pre>
852 aw0a 1 * AvlNames ALIASES (VarList)
853     * WHERE SetName IS_A set OF IntSet WITH_VALUE (SetValues);
854 jds 54 * </pre>
855 aw0a 1 * while the standard ALIASES statement is just:
856 jds 54 * <pre>
857 aw0a 1 * VarList ALIASES Name;
858 jds 54 * </pre>
859     * @param s CONST struct Statement*, the statement to query.
860     * @return The LHS as a CONST struct VariableList*.
861     * @see ArrayStatAvlNamesF()
862 aw0a 1 */
863 jds 54 extern CONST struct VariableList *ArrayStatAvlNamesF(CONST struct Statement *s);
864     /**<
865     * <!-- macro ArrayStatAvlNames(s) -->
866     * <!-- CONST struct VariableList *ArrayStatAvlNamesF(s) -->
867     * <!-- Return the LHS (new array(s)) being defined from an ARR statement. -->
868     * <!-- See stattypes.h for meaning of vlist. -->
869     * <!-- syntax is currently: -->
870     *
871     * <!-- AvlNames ALIASES (VarList) -->
872     * <!-- WHERE SetName IS_A set OF IntSet WITH_VALUE (SetValues); -->
873     *
874     * <!-- while the standard ALIASES statement is just: -->
875     *
876     * <!-- VarList ALIASES Name; -->
877     * Implementation function for ArrayStatAvlNames(). Do not call this
878     * function directly - use ArrayStatAvlNames() instead.
879     */
880 aw0a 1
881     #ifdef NDEBUG
882     #define ArrayStatSetName(s) ((s)->v.ali.c.setname)
883     #else
884     #define ArrayStatSetName(s) ArrayStatSetNameF(s)
885     #endif
886 jds 54 /**<
887 aw0a 1 * Return the name of set for an ARR statement.
888 jds 54 * @param s CONST struct Statement*, the statement to query.
889     * @return The name as a CONST struct VariableList*.
890     * @see ArrayStatSetNameF()
891 aw0a 1 */
892 jds 54 extern CONST struct VariableList *ArrayStatSetNameF(CONST struct Statement *s);
893     /**<
894     * <!-- macro ArrayStatSetName(s) -->
895     * <!-- struct VariableList *ArrayStatSetNameF(s) -->
896     * <!-- const struct Statement *s; -->
897     * <!-- Return the name of set for an ARR statement. -->
898     * Implementation function for ArrayStatSetName(). Do not call this
899     * function directly - use ArrayStatSetName() instead.
900     */
901 aw0a 1
902     #ifdef NDEBUG
903     #define ArrayStatIntSet(s) ((s)->v.ali.c.intset)
904     #else
905     #define ArrayStatIntSet(s) ArrayStatIntSetF(s)
906     #endif
907 jds 54 /**<
908 aw0a 1 * Return 0 or 1 corresponding to set being defined as symbol or integer.
909     * It must be passed an ARR statement.
910     * Other statements will return goop or crash.
911 jds 54 * @param s CONST struct Statement*, the statement to query.
912     * @return The type code as an int.
913     * @see ArrayStatIntSetF()
914 aw0a 1 */
915 jds 54 extern int ArrayStatIntSetF(CONST struct Statement *s);
916     /**<
917     * <!-- macro ArrayStatIntSet(s) -->
918     * <!-- int ArrayStatIntSetF(s) -->
919     * <!-- const struct Statement *s; -->
920     *
921     * <!-- Return 0 or 1 corresponding to set being defined as symbol or integer. -->
922     * <!-- It must be passed an ARR statement. -->
923     * <!-- Other statements will return goop or crash. -->
924     * Implementation function for ArrayStatIntSet(). Do not call this
925     * function directly - use ArrayStatIntSet() instead.
926     */
927 aw0a 1
928     #ifdef NDEBUG
929     #define ArrayStatSetValues(s) ((s)->v.ali.c.setvals)
930     #else
931     #define ArrayStatSetValues(s) ArrayStatSetValuesF(s)
932     #endif
933 jds 54 /**<
934 aw0a 1 * Return the user proposed set of values to use for array names.
935     * It must be passed an ARR statement. May be empty/NULL set.
936     * (this is the list after WITH_VALUE)
937     * Other statements will return goop or crash.
938 jds 54 * @param s CONST struct Statement*, the statement to query.
939     * @return The set as a CONST struct Set*.
940     * @see ArrayStatSetValuesF()
941 aw0a 1 */
942 jds 54 extern CONST struct Set *ArrayStatSetValuesF(CONST struct Statement *s);
943     /**<
944     * <!-- macro ArrayStatSetValues(s) -->
945     * <!-- struct Set *ArrayStatSetValuesF(s) -->
946     * <!-- const struct Statement *s; -->
947     *
948     * <!-- Return the user proposed set of values to use for array names. -->
949     * <!-- It must be passed an ARR statement. May be empty/NULL set. -->
950     * <!-- (this is the list after WITH_VALUE) -->
951     * <!-- Other statements will return goop or crash. -->
952     * Implementation function for ArrayStatSetValues(). Do not call this
953     * function directly - use ArrayStatSetValues() instead.
954     */
955 aw0a 1
956 jds 54 /* * * StateFOR functions * * */
957 aw0a 1
958     #ifdef NDEBUG
959     #define ForStatIndex(s) ((s)->v.f.index)
960     #else
961     #define ForStatIndex(s) ForStatIndexF(s)
962     #endif
963 jds 54 /**<
964 aw0a 1 * Return the FOR index variable identifier.
965 jds 54 * @param s CONST struct Statement*, the statement to query.
966     * @return The identifier as a symchar*.
967     * @see ForStatIndexF()
968 aw0a 1 */
969 jds 54 extern symchar *ForStatIndexF(CONST struct Statement *s);
970     /**<
971     * <!-- macro ForStatIndex(s) -->
972     * <!-- symchar *ForStatIndexF(s) -->
973     * <!-- const struct Statement *s; -->
974     * <!-- Return the FOR index variable identifier. -->
975     * Implementation function for ForStatIndex(). Do not call this
976     * function directly - use ForStatIndex() instead.
977     */
978 aw0a 1
979     #ifdef NDEBUG
980     #define ForStatExpr(s) ((s)->v.f.e)
981     #else
982     #define ForStatExpr(s) ForStatExprF(s)
983     #endif
984 jds 54 /**<
985 aw0a 1 * Return the expression of values that the index variable takes.
986 jds 54 * @param s CONST struct Statement*, the statement to query.
987     * @return The expression as a struct Expr*.
988     * @see ForStatExprF()
989 aw0a 1 */
990 jds 54 extern struct Expr *ForStatExprF(CONST struct Statement *s);
991     /**<
992     * <!-- macro ForStatExpr(s) -->
993     * <!-- struct Expr *ForStatExprF(s) -->
994     * <!-- const struct Statement *s; -->
995     * <!-- Return the expression of values that the index variable takes. -->
996     * Implementation function for ForStatExpr(). Do not call this
997     * function directly - use ForStatExpr() instead.
998     */
999 aw0a 1
1000     #ifdef NDEBUG
1001     #define ForStatStmts(s) ((s)->v.f.stmts)
1002     #else
1003     #define ForStatStmts(s) ForStatStmtsF(s)
1004     #endif
1005 jds 54 /**<
1006 aw0a 1 * Return the list of statements that are in the body of the FOR construct.
1007 jds 54 * @param s CONST struct Statement*, the statement to query.
1008     * @return The list as a struct StatementList*.
1009     * @see ForStatStmtsF()
1010 aw0a 1 */
1011 jds 54 extern struct StatementList *ForStatStmtsF(CONST struct Statement *s);
1012     /**<
1013     * <!-- macro ForStatStmts(s) -->
1014     * <!-- struct StatementList *ForStatStmtsF(s) -->
1015     * <!-- const struct Statement *s; -->
1016     * <!-- Return the list of statements that are in the body of the FOR construct. -->
1017     * Implementation function for ForStatStmts(). Do not call this
1018     * function directly - use ForStatStmts() instead.
1019     */
1020 aw0a 1
1021     #ifdef NDEBUG
1022     #define ForLoopKind(s) ((s)->v.f.kind)
1023     #else
1024     #define ForLoopKind(s) ForLoopKindF(s)
1025     #endif
1026 jds 54 /**<
1027     * Return the kind of the FOR construct.
1028     * @param s CONST struct Statement*, the statement to query.
1029     * @return The kind as an enum ForKind.
1030     * @see ForLoopKindF()
1031 aw0a 1 */
1032 jds 54 extern enum ForKind ForLoopKindF(CONST struct Statement *s);
1033     /**<
1034     * <!-- macro ForLoopKind(s) -->
1035     * <!-- enum ForOrder ForLoopKindF(s) -->
1036     * <!-- const struct Statement *s; -->
1037     * <!-- Return the kind of the FOR construct. -->
1038     * Implementation function for ForLoopKind(). Do not call this
1039     * function directly - use ForLoopKind() instead.
1040     */
1041 aw0a 1
1042     #ifdef NDEBUG
1043     #define ForLoopOrder(s) ((s)->v.f.order)
1044     #else
1045     #define ForLoopOrder(s) ForLoopOrderF(s)
1046     #endif
1047 jds 54 /**<
1048 aw0a 1 * Return the order of the FOR construct. For declarative this should
1049     * always be random.
1050 jds 54 * @param s CONST struct Statement*, the statement to query.
1051     * @return The order as an enum ForOrder.
1052     * @see ForLoopOrderF()
1053 aw0a 1 */
1054 jds 54 extern enum ForOrder ForLoopOrderF(CONST struct Statement *s);
1055     /**<
1056     * <!-- macro ForLoopOrder(s) -->
1057     * <!-- enum ForOrder ForLoopOrderF(s) -->
1058     * <!-- const struct Statement *s; -->
1059     * <!-- Return the order of the FOR construct. For declarative this -->
1060     * <!-- should always be random. -->
1061     * Implementation function for ForLoopOrder(). Do not call this
1062     * function directly - use ForLoopOrder() instead.
1063     */
1064 aw0a 1
1065     #ifdef NDEBUG
1066 jds 54 #define ForContains(s) ((s)->v.f.contains)
1067     #define ForContainsRelations(s) ((s)->v.f.contains & contains_REL)
1068 aw0a 1 #define ForContainsLogRelations(s) ((s)->v.f.contains & contains_LREL)
1069 jds 54 #define ForContainsDefaults(s) ((s)->v.f.contains & contains_DEF)
1070     #define ForContainsCAssigns(s) ((s)->v.f.contains & contains_CAS)
1071     #define ForContainsWhen(s) ((s)->v.f.contains & contains_WHEN)
1072     #define ForContainsAlike(s) ((s)->v.f.contains & contains_AA)
1073     #define ForContainsAlias(s) ((s)->v.f.contains & contains_ALI)
1074     #define ForContainsArray(s) ((s)->v.f.contains & contains_ARR)
1075     #define ForContainsIsa(s) ((s)->v.f.contains & contains_ISA)
1076     #define ForContainsIrt(s) ((s)->v.f.contains & contains_IRT)
1077     #define ForContainsAts(s) ((s)->v.f.contains & contains_ATS)
1078     #define ForContainsWbts(s) ((s)->v.f.contains & contains_WBTS)
1079     #define ForContainsWnbts(s) ((s)->v.f.contains & contains_WNBTS)
1080     #define ForContainsWillbe(s) ((s)->v.f.contains & contains_WILLBE)
1081     #define ForContainsSelect(s) ((s)->v.f.contains & contains_SELECT)
1082     #define ForContainsConditional(s) ((s)->v.f.contains & contains_COND)
1083     #define ForContainsIllegal(s) ((s)->v.f.contains & contains_ILL)
1084 aw0a 1 #else
1085 jds 54 #define ForContains(s) ForContainsF(s)
1086     #define ForContainsRelations(s) ForContainsRelationsF(s)
1087 aw0a 1 #define ForContainsLogRelations(s) ForContainsLogRelationsF(s)
1088 jds 54 #define ForContainsDefaults(s) ForContainsDefaultsF(s)
1089     #define ForContainsCAssigns(s) ForContainsCAssignsF(s)
1090     #define ForContainsWhen(s) ForContainsWhenF(s)
1091     #define ForContainsAlike(s) ForContainsAlikeF(s)
1092     #define ForContainsAlias(s) ForContainsAliasF(s)
1093     #define ForContainsArray(s) ForContainsArrayF(s)
1094     #define ForContainsIsa(s) ForContainsIsaF(s)
1095     #define ForContainsIrt(s) ForContainsIrtF(s)
1096     #define ForContainsAts(s) ForContainsAtsF(s)
1097     #define ForContainsWbts(s) ForContainsWbtsF(s)
1098     #define ForContainsWnbts(s) ForContainsWnbtsF(s)
1099     #define ForContainsWillbe(s) ForContainsWillbeF(s)
1100     #define ForContainsSelect(s) ForContainsSelectF(s)
1101     #define ForContainsConditional(s) ForContainsConditionalF(s)
1102     #define ForContainsIllegal(s) ForContainsIllegalF(s)
1103 aw0a 1 #endif
1104 jds 54 extern unsigned ForContainsF(CONST struct Statement *s);
1105     extern unsigned ForContainsRelationsF(CONST struct Statement *s);
1106     extern unsigned ForContainsLogRelationsF(CONST struct Statement *s);
1107     extern unsigned ForContainsDefaultsF(CONST struct Statement *s);
1108     extern unsigned ForContainsCAssignsF(CONST struct Statement *s);
1109     extern unsigned ForContainsWhenF(CONST struct Statement *s);
1110     extern unsigned ForContainsAlikeF(CONST struct Statement *s);
1111     extern unsigned ForContainsAliasF(CONST struct Statement *s);
1112     extern unsigned ForContainsArrayF(CONST struct Statement *s);
1113     extern unsigned ForContainsIsaF(CONST struct Statement *s);
1114     extern unsigned ForContainsIrtF(CONST struct Statement *s);
1115     extern unsigned ForContainsAtsF(CONST struct Statement *s);
1116     extern unsigned ForContainsWbtsF(CONST struct Statement *s);
1117     extern unsigned ForContainsWnbtsF(CONST struct Statement *s);
1118     extern unsigned ForContainsWillbeF(CONST struct Statement *s);
1119     extern unsigned ForContainsSelectF(CONST struct Statement *s);
1120     extern unsigned ForContainsConditionalF(CONST struct Statement *s);
1121     extern unsigned ForContainsIllegalF(CONST struct Statement *s);
1122 ben.allan 33 /**<
1123 jds 54 * <pre>
1124 aw0a 1 * macro ForContains(s)
1125     * unsigned ForContainsF(s)
1126     * macro ForContainsRelations(s)
1127     * unsigned ForContainsRelationsF(s)
1128     * macro ForContainsLogRelations(s)
1129     * unsigned ForContainsLogRelationsF(s)
1130     * macro ForContainsDefaults(s)
1131     * unsigned ForContainsDefaultsF(s)
1132     * macro ForContainsCAssigns(s)
1133     * unsigned ForContainsCAssignsF(s)
1134     * macro ForContainsWhen(s)
1135     * unsigned ForContainsWhenF(s)
1136     * macro ForContainsIllegal(s)
1137     * unsigned ForContainsIllegalF(s)
1138     * etc....
1139     * const struct Statement *s;
1140     *
1141     * Respectively:
1142     * Returns the entire contains field.
1143     * Return true if the FOR statement given contains itself or in any of
1144     * its nested statements a relation.
1145     * Return true if the FOR statement given contains itself or in any of
1146     * its nested statements a default statement.
1147     * Return true if the FOR statement given contains itself or in any of
1148     * its nested statements a constant/structural variable assignment.
1149     * Return true if the FOR statement given contains itself or in any of
1150     * its nested statements a WHEN statement.
1151     * Likewise for:
1152     * ARE_ALIKE
1153     * ALIASES
1154     * CREATE ARRAY
1155     * IS_A
1156     * IS_REFINED_TO
1157     * ARE_THE_SAME
1158     * WILL_BE_THE_SAME
1159     * WILL_BE
1160     * SELECT
1161     * CONDITIONAL.
1162     * Return true if the FOR statement given contains itself or in any of
1163     * its nested statements an illegal instruction.
1164 jds 54 * </pre>
1165     * @todo Rework documentation for individual functions.
1166 aw0a 1 */
1167    
1168 jds 54 /* * * StateAssign functions * * */
1169 aw0a 1
1170 jds 54 /*
1171 aw0a 1 * Assign has been split into Assign (structural) and Default
1172     * (variable) assignment types.
1173     */
1174     #ifdef NDEBUG
1175     #define DefaultStatVar(sptr) ((sptr)->v.asgn.nptr)
1176     #else
1177     #define DefaultStatVar(sptr) DefaultStatVarF(sptr)
1178     #endif
1179 jds 54 /**<
1180 aw0a 1 * Return the name structure which is the left hand side of the
1181     * default assignment.
1182 jds 54 * @param sptr CONST struct Statement*, the statement to query.
1183     * @return The name as a struct Name*.
1184     * @see DefaultStatVarF()
1185 aw0a 1 */
1186 jds 54 extern struct Name *DefaultStatVarF(CONST struct Statement *s);
1187     /**<
1188     * <!-- macro DefaultStatVar(s) -->
1189     * <!-- struct Name *DefaultStatVarF(s) -->
1190     * <!-- const struct Statement *s; -->
1191     * <!-- Return the name structure which is the left hand side of the -->
1192     * <!-- default assignment. -->
1193     * Implementation function for DefaultStatVar(). Do not call this
1194     * function directly - use DefaultStatVar() instead.
1195     */
1196 aw0a 1
1197     #ifdef NDEBUG
1198     #define DefaultStatRHS(s) ((s)->v.asgn.rhs)
1199     #else
1200     #define DefaultStatRHS(s) DefaultStatRHSF(s)
1201     #endif
1202 jds 54 /**<
1203 aw0a 1 * Return the right hand side expression of the default assignment.
1204 jds 54 * @param s CONST struct Statement*, the statement to query.
1205     * @return The expression as a struct Expr*.
1206     * @see DefaultStatRHSF()
1207 aw0a 1 */
1208 jds 54 extern struct Expr *DefaultStatRHSF(CONST struct Statement *s);
1209     /**<
1210     * <!-- macro DefaultStatRHS(s) -->
1211     * <!-- struct Expr *DefaultStatRHSF(s) -->
1212     * <!-- const struct Statement *s; -->
1213     * <!-- Return the right hand side expression of the default assignment. -->
1214     * Implementation function for DefaultStatRHS(). Do not call this
1215     * function directly - use DefaultStatRHS() instead.
1216     */
1217 aw0a 1
1218     #ifdef NDEBUG
1219     #define AssignStatVar(sptr) ((sptr)->v.asgn.nptr)
1220     #else
1221     #define AssignStatVar(sptr) AssignStatVarF(sptr)
1222     #endif
1223 jds 54 /**<
1224 aw0a 1 * Return the name structure which is the left hand side of the
1225     * structural assignment.
1226 jds 54 * @param sptr CONST struct Statement*, the statement to query.
1227     * @return The name as a struct Name*.
1228     * @see AssignStatVarF()
1229 aw0a 1 */
1230 jds 54 extern struct Name *AssignStatVarF(CONST struct Statement *s);
1231     /**<
1232     * <!-- macro AssignStatVar(s) -->
1233     * <!-- struct Name *AssignStatVarF(s) -->
1234     * <!-- const struct Statement *s; -->
1235     * <!-- Return the name structure which is the left hand side of the -->
1236     * <!-- structural assignment. -->
1237     * Implementation function for AssignStatVar(). Do not call this
1238     * function directly - use AssignStatVar() instead.
1239     */
1240 aw0a 1
1241     #ifdef NDEBUG
1242     #define AssignStatRHS(s) ((s)->v.asgn.rhs)
1243     #else
1244     #define AssignStatRHS(s) AssignStatRHSF(s)
1245     #endif
1246 jds 54 /**<
1247 aw0a 1 * Return the right hand side expression of the structural assignment.
1248 jds 54 * @param s CONST struct Statement*, the statement to query.
1249     * @return The expression as a struct Expr*.
1250     * @see AssignStatRHSF()
1251 aw0a 1 */
1252 jds 54 extern struct Expr *AssignStatRHSF(CONST struct Statement *s);
1253     /**<
1254     * <!-- macro AssignStatRHS(s) -->
1255     * <!-- struct Expr *AssignStatRHSF(s) -->
1256     * <!-- const struct Statement *s; -->
1257     * <!-- Return the right hand side expression of the structural assignment. -->
1258     * Implementation function for AssignStatRHS(). Do not call this
1259     * function directly - use AssignStatRHS() instead.
1260     */
1261 aw0a 1
1262 jds 54 /* * * StateRelation functions * * */
1263 aw0a 1
1264     #ifdef NDEBUG
1265     #define RelationStatName(s) ((s)->v.rel.nptr)
1266     #else
1267     #define RelationStatName(s) RelationStatNameF(s)
1268     #endif
1269 jds 54 /**<
1270 aw0a 1 * Return the name of the relation.
1271 jds 54 * @param s CONST struct Statement*, the statement to query.
1272     * @return The name as a struct Name*.
1273     * @see RelationStatNameF()
1274 aw0a 1 */
1275 jds 54 extern struct Name *RelationStatNameF(CONST struct Statement *s);
1276     /**<
1277     * <!-- macro RelationStatName(s) -->
1278     * <!-- struct Name *RelationStatNameF(s) -->
1279     * <!-- const struct Statement *s; -->
1280     * <!-- Return the name of the relation. -->
1281     * Implementation function for RelationStatName(). Do not call this
1282     * function directly - use RelationStatName() instead.
1283     */
1284 aw0a 1
1285     #ifdef NDEBUG
1286     #define RelationStatExpr(s) ((s)->v.rel.relation)
1287     #else
1288     #define RelationStatExpr(s) RelationStatExprF(s)
1289     #endif
1290 jds 54 /**<
1291 aw0a 1 * Return the relation expression.
1292 jds 54 * @param s CONST struct Statement*, the statement to query.
1293     * @return The expression as a struct Expr*.
1294     * @see RelationStatExprF()
1295 aw0a 1 */
1296 jds 54 extern struct Expr *RelationStatExprF(CONST struct Statement *s);
1297     /**<
1298     * <!-- macro RelationStatExpr(s) -->
1299     * <!-- struct Expr *RelationStatExprF(s) -->
1300     * <!-- const struct Statement *s; -->
1301     * <!-- Return the relation expression. -->
1302     * Implementation function for RelationStatExpr(). Do not call this
1303     * function directly - use RelationStatExpr() instead.
1304     */
1305 aw0a 1
1306     #ifdef NDEBUG
1307     #define LogicalRelStatName(s) ((s)->v.lrel.nptr)
1308     #else
1309     #define LogicalRelStatName(s) LogicalRelStatNameF(s)
1310     #endif
1311 jds 54 /**<
1312 aw0a 1 * Return the name of the logical relation.
1313 jds 54 * @param s CONST struct Statement*, the statement to query.
1314     * @return The name as a struct Name*.
1315     * @see LogicalRelStatNameF()
1316 aw0a 1 */
1317 jds 54 extern struct Name *LogicalRelStatNameF(CONST struct Statement *s);
1318     /**<
1319     * <!-- macro LogicalRelStatName(s) -->
1320     * <!-- struct Name *LogicalRelStatNameF(s) -->
1321     * <!-- const struct Statement *s; -->
1322     * <!-- Return the name of the logical relation. -->
1323     * Implementation function for LogicalRelStatName(). Do not call this
1324     * function directly - use LogicalRelStatName() instead.
1325     */
1326 aw0a 1
1327     #ifdef NDEBUG
1328     #define LogicalRelStatExpr(s) ((s)->v.lrel.logrel)
1329     #else
1330     #define LogicalRelStatExpr(s) LogicalRelStatExprF(s)
1331     #endif
1332 jds 54 /**<
1333 aw0a 1 * Return the logical relation expression.
1334 jds 54 * @param s CONST struct Statement*, the statement to query.
1335     * @return The expression as a struct Expr*.
1336     * @see RelationStatExprF()
1337 aw0a 1 */
1338 jds 54 extern struct Expr *LogicalRelStatExprF(CONST struct Statement *s);
1339     /**<
1340     * <!-- macro LogicalRelStatExpr(s) -->
1341     * <!-- struct Expr *LogicalRelStatExprF(s) -->
1342     * <!-- const struct Statement *s; -->
1343     * <!-- Return the logical relation expression. -->
1344     * Implementation function for LogicalRelStatExpr(). Do not call this
1345     * function directly - use LogicalRelStatExpr() instead.
1346     */
1347 aw0a 1
1348 jds 54 /* * * StateExternal functions * * */
1349 aw0a 1
1350     #ifdef NDEBUG
1351     #define ExternalStatMode(s) ((s)->v.ext.mode)
1352     #else
1353     #define ExternalStatMode(s) ExternalStatModeF(s)
1354     #endif
1355 jds 54 /**<
1356 aw0a 1 * Return the external statement's mode.
1357     * 0 = Procedural, 1 = Glassbox Declarative, 2 = Blackbox Declarative.
1358 jds 54 * @param s CONST struct Statement*, the statement to query.
1359     * @return The mode as an int.
1360     * @see ExternalStatModeF()
1361 aw0a 1 */
1362 jds 54 extern int ExternalStatModeF(CONST struct Statement *s);
1363     /**<
1364     * <!-- macro ExternalStatMode(s) -->
1365     * <!-- int ExternalStatModeF(s) -->
1366     * <!-- const struct Statement *s; -->
1367     * <!-- Return the external statement's mode. -->
1368     * <!-- 0 = Procedural, 1 = Glassbox Declarative, 2 = Blackbox Declarative. -->
1369     * Implementation function for ExternalStatMode(). Do not call this
1370     * function directly - use ExternalStatMode() instead.
1371     */
1372 aw0a 1
1373     #ifdef NDEBUG
1374     #define ExternalStatName(s) ((s)->v.ext.nptr)
1375     #else
1376     #define ExternalStatName(s) ExternalStatNameF(s)
1377     #endif
1378 jds 54 /**<
1379 aw0a 1 * Return the external statement's name.
1380 jds 54 * @param s CONST struct Statement*, the statement to query.
1381     * @return The name as a struct Name*.
1382     * @see ExternalStatNameF()
1383 aw0a 1 */
1384 jds 54 extern struct Name *ExternalStatNameF(CONST struct Statement *s);
1385     /**<
1386     * <!-- macro ExternalStatName(s) -->
1387     * <!-- struct Name *ExternalStatNameF(s) -->
1388     * <!-- const struct Statement *s; -->
1389     * <!-- Return the external statement's name. -->
1390     * Implementation function for ExternalStatName(). Do not call this
1391     * function directly - use ExternalStatName() instead.
1392     */
1393 aw0a 1
1394     #ifdef NDEBUG
1395     #define ExternalStatData(s) ((s)->v.ext.data)
1396     #else
1397     #define ExternalStatData(s) ExternalStatDataF(s)
1398     #endif
1399 jds 54 /**<
1400 aw0a 1 * Return the external statement's name of its additional data.
1401 jds 54 * @param s CONST struct Statement*, the statement to query.
1402     * @return The name as a struct Name*.
1403     * @see ExternalStatDataF()
1404 aw0a 1 */
1405 jds 54 extern struct Name *ExternalStatDataF(CONST struct Statement *s);
1406     /**<
1407     * <!-- macro ExternalStatData(s) -->
1408     * <!-- struct Name *ExternalStatDataF(s) -->
1409     * <!-- const struct Statement *s; -->
1410     * <!-- Return the external statement's name of its additional data. -->
1411     * Implementation function for ExternalStatData(). Do not call this
1412     * function directly - use ExternalStatData() instead.
1413     */
1414 aw0a 1
1415     #ifdef NDEBUG
1416     #define ExternalStatScope(s) ((s)->v.ext.scope)
1417     #else
1418     #define ExternalStatScope(s) ExternalStatScopeF(s)
1419     #endif
1420 jds 54 /**<
1421 aw0a 1 * Return the external statement's name of its scope. This may be NULL.
1422     * If it is NULL, then the external relation (at this time assumed to be
1423 jds 54 * a glassbox), will added at the scope that it was found; otherwise it
1424 aw0a 1 * will be added at the given scope.
1425 jds 54 * @param s CONST struct Statement*, the statement to query.
1426     * @return The name as a struct Name*.
1427     * @see ExternalStatScopeF()
1428 aw0a 1 */
1429 jds 54 extern struct Name *ExternalStatScopeF(CONST struct Statement *s);
1430     /**<
1431     * <!-- macro ExternalStatScope(s) -->
1432     * <!-- struct Name *ExternalStatScopeF(s) -->
1433     * <!-- const struct Statement *s; -->
1434     * <!-- Return the external statement's name of its scope. This may be NULL. -->
1435     * <!-- If it is NULL, then the external relation (at this time assumed to be -->
1436     * <!-- a glassbox, will added at the scope that it was found; otherwise it -->
1437     * <!-- will be added at the given scope. -->
1438     * Implementation function for ExternalStatScope(). Do not call this
1439     * function directly - use ExternalStatScope() instead.
1440     */
1441 aw0a 1
1442     #ifdef NDEBUG
1443     #define ExternalStatVlist(s) ((s)->v.ext.vl)
1444     #else
1445     #define ExternalStatVlist(s) ExternalStatVlistF(s)
1446     #endif
1447 jds 54 /**<
1448     * Return the external statement's variable list -- the argument list.
1449     * @param s CONST struct Statement*, the statement to query.
1450     * @return The list as a struct VariableList*.
1451     * @see ExternalStatVlistF()
1452 aw0a 1 */
1453 jds 54 extern struct VariableList *ExternalStatVlistF(CONST struct Statement *s);
1454     /**<
1455     * <!-- macro ExternalStatVlist(s) -->
1456     * <!-- struct VariableList *ExternalStatVlist(s) -->
1457     * <!-- const struct Statement *s; -->
1458     * <!-- Return the external statement's variable list -- the argument list. -->
1459     * Implementation function for ExternalStatVlist(). Do not call this
1460     * function directly - use ExternalStatVlist() instead.
1461     */
1462 aw0a 1
1463     #ifdef NDEBUG
1464     #define ExternalStatFuncName(s) ((s)->v.ext.extcall)
1465     #else
1466     #define ExternalStatFuncName(s) ExternalStatFuncNameF(s)
1467     #endif
1468 jds 54 /**<
1469 aw0a 1 * Return the external statement's function call
1470     * name. -- the name invoked with.
1471 jds 54 * @param s CONST struct Statement*, the statement to query.
1472     * @return The name as a CONST char*.
1473     * @see ExternalStatFuncNameF()
1474 aw0a 1 */
1475 jds 54 extern CONST char *ExternalStatFuncNameF(CONST struct Statement *s);
1476     /**<
1477     * <!-- macro ExternalStatFuncName(s) -->
1478     * <!-- struct Name *ExternalStatFuncNameF(s) -->
1479     * <!-- const struct Statement *s; -->
1480     * <!-- Return the external statement's function call -->
1481     * <!-- name. -- the name invoked with. -->
1482     * Implementation function for ExternalStatFuncName(). Do not call this
1483     * function directly - use ExternalStatFuncName() instead.
1484     */
1485 aw0a 1
1486 jds 54 /* * * StateReference functions * * */
1487 aw0a 1
1488     #ifdef NDEBUG
1489     #define ReferenceStatMode(s) ((s)->v.ref.mode)
1490     #else
1491     #define ReferenceStatMode(s) ReferenceStatModeF(s)
1492     #endif
1493 jds 54 /**<
1494 aw0a 1 * Return the mode of the refernce statement. Mode at the moment:
1495     * 0 => copy/clone semantics; 1 => pure reference semantics, such as in
1496     * languages with pointers. Value semantics is handled by ISA statements
1497 jds 54 * @param s CONST struct Statement*, the statement to query.
1498     * @return The mode as an int.
1499     * @see ReferenceStatModeF()
1500 aw0a 1 */
1501 jds 54 extern int ReferenceStatModeF(CONST struct Statement *s);
1502     /**<
1503     * <!-- macro ReferenceStatMode(s) -->
1504     * <!-- int ReferenceStatModeF(s) -->
1505     * <!-- const struct Statement *s; -->
1506     * <!-- Return the mode of the refernce statement. Mode at the moment: -->
1507     * <!-- 0 => copy/clone semantics; 1 => pure reference semantics, such as in -->
1508     * <!-- languages with pointers. Value semantics is handled by ISA statements -->
1509     * Implementation function for ReferenceStatMode(). Do not call this
1510     * function directly - use ReferenceStatMode() instead.
1511     */
1512 aw0a 1
1513     #ifdef NDEBUG
1514     #define ReferenceStatName(s) ((s)->v.ref.ref_name)
1515     #else
1516     #define ReferenceStatName(s) ReferenceStatNameF(s)
1517     #endif
1518 jds 54 /**<
1519 aw0a 1 * Return the name of the thing being referred to. This name is a simple
1520     * such as a type description. Later this may become accept a fully qulafied
1521     * id., and will depend upon the semantics of how it was invoked.
1522     * This name may alternatively be called the *referee*
1523 jds 54 * @param s CONST struct Statement*, the statement to query.
1524     * @return The name as a symchar*.
1525     * @see ReferenceStatNameF()
1526 aw0a 1 */
1527 jds 54 extern symchar *ReferenceStatNameF(CONST struct Statement *s);
1528     /**<
1529     * <!-- macro ReferenceStatName(s) -->
1530     * <!-- const char *ReferenceStatNameF(s) -->
1531     * <!-- const struct Statement *s; -->
1532     * <!-- Return the name of the thing being referred to. This name is a simple -->
1533     * <!-- such as a type description. Later this may become accept a fully qulafied -->
1534     * <!-- id., and will depend upon the semantics of how it was invoked. -->
1535     * <!-- This name may alternatively be called the *referee* -->
1536     * Implementation function for ReferenceStatName(). Do not call this
1537     * function directly - use ReferenceStatName() instead.
1538     */
1539 aw0a 1
1540     #ifdef NDEBUG
1541     #define ReferenceStatSetType(s) ((s)->v.ref.settype)
1542     #else
1543     #define ReferenceStatSetType(s) ReferenceStatSetTypeF(s)
1544 jds 54 /**<
1545 aw0a 1 * Return the type of set for a REF statement. This may be NULL, which
1546 jds 54 * means that there is no "OF" part to the _IS_ statement.<br>
1547     * Eg: foo[thing] _IS_ set OF barobject; -- not NULL <br>
1548     * foo_other _IS_ bar_other; -- NULL.
1549     * @param s CONST struct Statement*, the statement to query.
1550     * @return The type as a symchar*.
1551     * @see ReferenceStatSetTypeF()
1552 aw0a 1 */
1553 jds 54 extern symchar *ReferenceStatSetTypeF(CONST struct Statement *s);
1554     #endif
1555     /**<
1556     * <!-- macro ReferenceStatSetType(s) -->
1557     * <!-- symchar *ReferenceStatSetType(s) -->
1558     * <!-- const struct Statement *s; -->
1559     * <!-- Return the type of set for a REF statement. This may be NULL, which -->
1560     * <!-- means that there is no "OF" part to the _IS_ statement. -->
1561     * <!-- Eg: foo[thing] _IS_ set OF barobject; -- not NULL -->
1562     * <!-- foo_other _IS_ bar_other; -- NULL. -->
1563     * Implementation function for ReferenceStatSetType(). Do not call this
1564     * function directly - use ReferenceStatSetType() instead.
1565     */
1566 aw0a 1
1567     #ifdef NDEBUG
1568     #define ReferenceStatVlist(s) ((s)->v.ref.vl)
1569     #else
1570     #define ReferenceStatVlist(s) ReferenceStatVlistF(s)
1571     #endif
1572 jds 54 /**<
1573     * Return the list of variables/models that refer to the given reference.
1574     * @param s CONST struct Statement*, the statement to query.
1575     * @return The list as a struct VariableList*.
1576     * @see ReferenceStatVlistF()
1577 aw0a 1 */
1578 jds 54 extern struct VariableList *ReferenceStatVlistF(CONST struct Statement *s);
1579     /**<
1580     * <!-- macro ReferenceStatVlist(s) -->
1581     * <!-- struct VariableList *ReferenceStatVlistF(s) -->
1582     * <!-- const struct Statement *s; -->
1583     * <!-- Return the list of variables/models that refer to the given reference. -->
1584     * Implementation function for ReferenceStatVlist(). Do not call this
1585     * function directly - use ReferenceStatVlist() instead.
1586     */
1587 aw0a 1
1588 jds 54 /* * * StateRun functions * * */
1589 aw0a 1
1590     #ifdef NDEBUG
1591     #define RunStatName(s) ((s)->v.r.proc_name)
1592     #else
1593     #define RunStatName(s) RunStatNameF(s)
1594     #endif
1595 jds 54 /**<
1596 aw0a 1 * Returns the name pointer of a run statement.
1597 jds 54 * @param s CONST struct Statement*, the statement to query.
1598     * @return The name as a struct Name*.
1599     * @see RunStatNameF()
1600 aw0a 1 */
1601 jds 54 extern struct Name *RunStatNameF(CONST struct Statement *s);
1602     /**<
1603     * <!-- macro RunStatName(s) -->
1604     * <!-- struct Name *RunStatNameF(s) -->
1605     * <!-- const struct Statement *s; -->
1606     * <!-- Returns the name pointer of a run statement. -->
1607     * Implementation function for RunStatName(). Do not call this
1608     * function directly - use RunStatName() instead.
1609     */
1610 aw0a 1
1611     #ifdef NDEBUG
1612     #define RunStatAccess(s) ((s)->v.r.type_name)
1613     #else
1614     #define RunStatAccess(s) RunStatAccessF(s)
1615     #endif
1616 jds 54 /**<
1617 aw0a 1 * Returns the type access of a RUN statement. This is to allow the
1618     * use of syntax such as: RUN A::b where 'B' is a class/model/atom, and b
1619     * is a name of procedure within that class/atom/model.
1620 jds 54 * @param s CONST struct Statement*, the statement to query.
1621     * @return The type access as a struct Name*.
1622     * @see RunStatAccessF()
1623 aw0a 1 */
1624 jds 54 extern struct Name *RunStatAccessF(CONST struct Statement *s);
1625     /**<
1626     * <!-- macro RunStatAccess(s) -->
1627     * <!-- char *RunStatAccessF(s) -->
1628     * <!-- const struct Statement *s; -->
1629     * <!-- Returns the type access of a RUN statement. This is to allow the -->
1630     * <!-- use of syntax such as: RUN A::b where 'B' is a class/model/atom, and b -->
1631     * <!-- is a name of procedure within that class/atom/model. -->
1632     * Implementation function for RunStatAccess(). Do not call this
1633     * function directly - use RunStatAccess() instead.
1634     */
1635 aw0a 1
1636 jds 54 /* * * StateCall functions * * */
1637    
1638 aw0a 1 #ifdef NDEBUG
1639     #define CallStatArgs(s) ((s)->v.call.args)
1640     #else
1641     #define CallStatArgs(s) CallStatArgsF(s)
1642     #endif
1643 jds 54 /**<
1644 aw0a 1 * Return the call statement's argument list.
1645 jds 54 * @param s CONST struct Statement*, the statement to query.
1646     * @return The list as a struct Set*.
1647     * @see CallStatArgsF()
1648 aw0a 1 */
1649 jds 54 extern struct Set *CallStatArgsF(CONST struct Statement *s);
1650     /**<
1651     * <!-- macro CallStatArgs(s) -->
1652     * <!-- struct Set *CallStatArgs(s) -->
1653     * <!-- const struct Statement *s; -->
1654     * <!-- Return the call statement's argument list. -->
1655     * Implementation function for CallStatArgs(). Do not call this
1656     * function directly - use CallStatArgs() instead.
1657     */
1658 aw0a 1
1659     #ifdef NDEBUG
1660     #define CallStatId(s) ((s)->v.call.id)
1661     #else
1662     #define CallStatId(s) CallStatIdF(s)
1663     #endif
1664 jds 54 /**<
1665 aw0a 1 * Return the call statement's function id.
1666 jds 54 * @param s CONST struct Statement*, the statement to query.
1667     * @return The id as a symchar*.
1668     * @see CallStatIdF()
1669 aw0a 1 */
1670 jds 54 extern symchar *CallStatIdF(CONST struct Statement *s);
1671     /**<
1672     * <!-- macro CallStatId(s) -->
1673     * <!-- symchar *CallStatId(s) -->
1674     * <!-- const struct Statement *s; -->
1675     * <!-- Return the call statement's function id. -->
1676     * Implementation function for CallStatId(). Do not call this
1677     * function directly - use CallStatId() instead.
1678     */
1679 aw0a 1
1680 jds 54 /* * * StateWhile functions * * */
1681 aw0a 1
1682     #ifdef NDEBUG
1683     #define WhileStatExpr(s) ((s)->v.loop.test)
1684     #else
1685     #define WhileStatExpr(s) WhileStatExprF(s)
1686     #endif
1687 jds 54 /**<
1688 aw0a 1 * Return the WHILE expression.
1689 jds 54 * @param s CONST struct Statement*, the statement to query.
1690     * @return The expression as a struct Expr*.
1691     * @see WhileStatExprF()
1692 aw0a 1 */
1693 jds 54 extern struct Expr *WhileStatExprF(CONST struct Statement *s);
1694     /**<
1695     * <!-- macro WhileStatExpr(s) -->
1696     * <!-- struct Expr *WhileStatExprF(s) -->
1697     * <!-- const struct Statement *s; -->
1698     * <!-- Return the WHILE expression. -->
1699     * Implementation function for WhileStatExpr(). Do not call this
1700     * function directly - use WhileStatExpr() instead.
1701     */
1702 aw0a 1
1703     #ifdef NDEBUG
1704     #define WhileStatBlock(s) ((s)->v.loop.block)
1705     #else
1706     #define WhileStatBlock(s) WhileStatBlockF(s)
1707     #endif
1708 jds 54 /**<
1709 aw0a 1 * Return the block of a while statement.
1710 jds 54 * @param s CONST struct Statement*, the statement to query.
1711     * @return The block as a struct StatementList*.
1712     * @see WhileStatBlockF()
1713 aw0a 1 */
1714 jds 54 extern struct StatementList *WhileStatBlockF(CONST struct Statement *s);
1715     /**<
1716     * <!-- macro WhileStatBlock(s) -->
1717     * <!-- struct StatementList *WhileStatBlockF(s) -->
1718     * <!-- const struct Statement *s; -->
1719     * <!-- Return the block of a while statement. -->
1720     * Implementation function for WhileStatBlock(). Do not call this
1721     * function directly - use WhileStatBlock() instead.
1722     */
1723 aw0a 1
1724 jds 54 /* * * stateflow * * */
1725 aw0a 1
1726     #define FlowStatControl(s) ((s)->v.flow.fc)
1727 jds 54 /**<
1728     * Return the type of flow control.
1729     * @todo Needs a function wrapper.
1730     */
1731 aw0a 1
1732     #define FlowStatMessage(s) ((s)->v.flow.message)
1733 jds 54 /**<
1734     * Return the message of the flow control.
1735     * @todo Needs a function wrapper.
1736     */
1737 aw0a 1
1738 johnpye 148 /* * * StateASSERT functions * * */
1739 johnpye 124
1740 johnpye 148 /** Return the ASSERT expression
1741 johnpye 124 @param s the expression to test
1742 johnpye 148 @see AssertStatExprF()
1743 johnpye 124 */
1744     #ifdef NDEBUG
1745 johnpye 148 # define AssertStatExpr(s) ((s)->v.asserts.test)
1746 johnpye 124 #else
1747 johnpye 148 # define AssertStatExpr(s) AssertStatExprF(s)
1748 johnpye 124 #endif
1749    
1750 johnpye 148 /** Internal implemention of ASSERT expression
1751 johnpye 124 @see IfStatExprF()
1752     */
1753 johnpye 148 extern struct Expr *AssertStatExprF(CONST struct Statement *s);
1754 johnpye 124
1755 jds 54 /* * * StateIf functions * * */
1756 aw0a 1
1757     #ifdef NDEBUG
1758     #define IfStatExpr(s) ((s)->v.ifs.test)
1759     #else
1760     #define IfStatExpr(s) IfStatExprF(s)
1761     #endif
1762 jds 54 /**<
1763 aw0a 1 * Return the IF expression.
1764 johnpye 124 * @param s the statement to query.
1765 jds 54 * @return The expression as a struct Expr*.
1766     * @see IfStatExprF()
1767 aw0a 1 */
1768 jds 54 extern struct Expr *IfStatExprF(CONST struct Statement *s);
1769     /**<
1770     * <!-- macro IfStatExpr(s) -->
1771     * <!-- struct Expr *IfStatExprF(s) -->
1772     * <!-- const struct Statement *s; -->
1773     * <!-- Return the IF expression. -->
1774     * Implementation function for IfStatExpr(). Do not call this
1775     * function directly - use IfStatExpr() instead.
1776     */
1777 aw0a 1
1778     #ifdef NDEBUG
1779     #define IfStatThen(s) ((s)->v.ifs.thenblock)
1780     #else
1781     #define IfStatThen(s) IfStatThenF(s)
1782     #endif
1783 jds 54 /**<
1784 aw0a 1 * Return the then block of an if statement.
1785 jds 54 * @param s CONST struct Statement*, the statement to query.
1786     * @return The block as a struct StatementList*.
1787     * @see IfStatThenF()
1788 aw0a 1 */
1789 jds 54 extern struct StatementList *IfStatThenF(CONST struct Statement *s);
1790     /**<
1791     * <!-- macro IfStatThen(s) -->
1792     * <!-- struct StatementList *IfStatThenF(s) -->
1793     * <!-- const struct Statement *s; -->
1794     * <!-- Return the then block of an if statement. -->
1795     * Implementation function for IfStatThen(). Do not call this
1796     * function directly - use IfStatThen() instead.
1797     */
1798 aw0a 1
1799     #ifdef NDEBUG
1800     #define IfStatElse(s) ((s)->v.ifs.elseblock)
1801     #else
1802     #define IfStatElse(s) IfStatElseF(s)
1803     #endif
1804 jds 54 /**<
1805 aw0a 1 * Return the else block of an if statement. This is NULL if the else
1806     * was omitted.
1807 jds 54 * @param s CONST struct Statement*, the statement to query.
1808     * @return The block as a struct StatementList*.
1809     * @see IfStatElseF()
1810 aw0a 1 */
1811 jds 54 extern struct StatementList *IfStatElseF(CONST struct Statement *s);
1812     /**<
1813     * <!-- macro IfStatElse(s) -->
1814     * <!-- struct StatementList *IfStatElseF(s) -->
1815     * <!-- const struct Statement *s; -->
1816     * <!-- Return the else block of an if statement. -->
1817     * <!-- This is NULL if the else was omitted. -->
1818     * Implementation function for IfStatElse(). Do not call this
1819     * function directly - use IfStatElse() instead.
1820     */
1821 aw0a 1
1822 jds 54 /* * * StateWhen functions * * */
1823 aw0a 1
1824     #ifdef NDEBUG
1825     #define WhenStatName(s) ((s)->v.w.nptr)
1826     #else
1827     #define WhenStatName(s) WhenStatNameF(s)
1828     #endif
1829 jds 54 /**<
1830 aw0a 1 * Return the name of a WHEN node.
1831 jds 54 * @param s CONST struct Statement*, the statement to query.
1832     * @return The name as a struct Name*.
1833     * @see WhenStatNameF()
1834 aw0a 1 */
1835 jds 54 extern struct Name *WhenStatNameF(CONST struct Statement *s);
1836     /**<
1837     * <!-- macro WhenStatName(s) -->
1838     * <!-- struct Name *WhenStatName(s) -->
1839     * <!-- const struct Statement *s; -->
1840     * <!-- Return the name of a WHEN node. -->
1841     * Implementation function for WhenStatName(). Do not call this
1842     * function directly - use WhenStatName() instead.
1843     */
1844 aw0a 1
1845 jds 54 extern void SetWhenName(struct Statement *s, struct Name *n);
1846     /**<
1847     * <!-- void SetWhenName(s,n) -->
1848     * <!-- struct Statement *s; -->
1849     * <!-- struct Name *n; -->
1850 aw0a 1 * This procedure provides a mechanism for unnamed whens to be named.
1851     */
1852    
1853     #ifdef NDEBUG
1854     #define WhenStatVL(s) ((s)->v.w.vl)
1855     #else
1856     #define WhenStatVL(s) WhenStatVLF(s)
1857     #endif
1858 jds 54 /**<
1859 aw0a 1 * Return the variable list part of a WHEN statement.
1860 jds 54 * @param s CONST struct Statement*, the statement to query.
1861     * @return The list as a struct VariableList*.
1862     * @see WhenStatVLF()
1863 aw0a 1 */
1864 jds 54 extern struct VariableList *WhenStatVLF(CONST struct Statement *s);
1865     /**<
1866     * <!-- macro WhenStatVL(s) -->
1867     * <!-- struct VariableList *WhenStatVLF(s) -->
1868     * <!-- const struct Statement *s; -->
1869     * <!-- Return the variable list part of a WHEN statement. -->
1870     * Implementation function for WhenStatVL(). Do not call this
1871     * function directly - use WhenStatVL() instead.
1872     */
1873 aw0a 1
1874     #ifdef NDEBUG
1875     #define WhenStatCases(s) ((s)->v.w.cases)
1876     #else
1877     #define WhenStatCases(s) WhenStatCasesF(s)
1878     #endif
1879 jds 54 /**<
1880 aw0a 1 * Return the list of cases of a WHEN statement. To obtain the
1881     * statement list in each of the CASEs, see when.h
1882 jds 54 * @param s CONST struct Statement*, the statement to query.
1883     * @return The list as a struct WhenList*.
1884     * @see WhenStatCasesF()
1885 aw0a 1 */
1886 jds 54 extern struct WhenList *WhenStatCasesF(CONST struct Statement *s);
1887     /**<
1888     * <!-- macro WhenStatCases(s) -->
1889     * <!-- struct WhenList *WhenStatCasesF(s) -->
1890     * <!-- const struct Statement *s; -->
1891     * <!-- Return the list of cases of a WHEN statement. To obtain the -->
1892     * <!-- statement list in each of the CASEs, see when.h -->
1893     * Implementation function for WhenStatCases(). Do not call this
1894     * function directly - use WhenStatCases() instead.
1895     */
1896 aw0a 1
1897 jds 54 extern int CompareWhenStatements(CONST struct Statement *s1,
1898     CONST struct Statement *s2);
1899     /**<
1900 aw0a 1 * Compare functions for WHEN statements. It includes the decomposition
1901     * of the WHEN in the list of variables and the list of CASEs. Also,
1902     * each case is decomposed in the set of values and the list of statements.
1903     * It is done here since we are comparing the statement rather than only a
1904     * WhenList structure (when.[ch]).
1905     * It is called for the function CompareStatements and it follows the
1906     * same pattern for the comparation.
1907     */
1908    
1909 jds 54 /* * * StateFname functions * * */
1910 aw0a 1
1911     #ifdef NDEBUG
1912     #define FnameStat(s) ((s)->v.n.wname)
1913     #else
1914     #define FnameStat(s) FnameStatF(s)
1915     #endif
1916 jds 54 /**<
1917 aw0a 1 * Return the name of a model or relation (inside WHEN statement)
1918 jds 54 * @param s CONST struct Statement*, the statement to query.
1919     * @return The name as a struct Name*.
1920     * @see FnameStatF()
1921 aw0a 1 */
1922 jds 54 extern struct Name *FnameStatF(CONST struct Statement *s);
1923     /**<
1924     * <!-- macro FnameStatcases(s) -->
1925     * <!-- struct Name *FnameStatF(s) -->
1926     * <!-- const struct Statement *s; -->
1927     * <!-- Return the name of a model or relation (inside WHEN statement) -->
1928     * Implementation function for FnameStat(). Do not call this
1929     * function directly - use FnameStat() instead.
1930     */
1931 aw0a 1
1932 jds 54 /* * * StateCOND functions * * */
1933 aw0a 1
1934     #ifdef NDEBUG
1935     #define CondStatList(s) ((s)->v.cond.stmts)
1936     #else
1937     #define CondStatList(s) CondStatListF(s)
1938     #endif
1939 jds 54 /**<
1940 aw0a 1 * Return the list of statements in a Conditional statement.
1941 jds 54 * @param s CONST struct Statement*, the statement to query.
1942     * @return The list as a struct StatementList*.
1943     * @see CondStatListF()
1944 aw0a 1 */
1945 jds 54 extern struct StatementList *CondStatListF(CONST struct Statement *s);
1946     /**<
1947     * <!-- macro CondStatList(s) -->
1948     * <!-- struct StatementList *CondStatListF(s) -->
1949     * <!-- const struct Statement *s; -->
1950     * <!-- Return the list of statements in a Conditional statement. -->
1951     * Implementation function for CondStatList(). Do not call this
1952     * function directly - use CondStatList() instead.
1953     */
1954 aw0a 1
1955     #ifdef NDEBUG
1956     #define CondContains(s) ((s)->v.cond.contains)
1957     #define CondContainsRelations(s) ((s)->v.cond.contains & contains_REL)
1958     #define CondContainsLogRelations(s) ((s)->v.cond.contains & contains_LREL)
1959     #else
1960     #define CondContains(s) CondContainsF(s)
1961     #define CondContainsRelations(s) CondContainsRelationsF(s)
1962     #define CondContainsLogRelations(s) CondContainsLogRelationsF(s)
1963     #endif
1964 jds 54 extern unsigned CondContainsF(CONST struct Statement *s);
1965     extern unsigned CondContainsRelationsF(CONST struct Statement *s);
1966     extern unsigned CondContainsLogRelationsF(CONST struct Statement *s);
1967     /**<
1968     * <pre>
1969 aw0a 1 * macro CondContains(s)
1970     * unsigned CondContainsF(s)
1971     * macro CondContainsRelations(s)
1972     * unsigned CondContainsRelationsF(s)
1973     * macro CondContainsLogRelations(s)
1974     * unsigned CondContainsLogRelationsF(s)
1975     * const struct Statement *s;
1976     *
1977     * Respectively:
1978     * Returns the entire contains field.
1979     * Return true if the Cond statement given contains a relation.
1980     * Return true if the Cond statement given contains a logical relation.
1981 jds 54 * </pre>
1982     * @todo Rework documentation for individual functions.
1983 aw0a 1 */
1984    
1985 jds 54 /* * * StateSelect functions * * */
1986 aw0a 1
1987     #ifdef NDEBUG
1988     #define SelectStatVL(s) ((s)->v.se.vl)
1989     #else
1990     #define SelectStatVL(s) SelectStatVLF(s)
1991     #endif
1992 jds 54 /**<
1993 aw0a 1 * Return the set part of a SELECT statement.
1994 jds 54 * @param s CONST struct Statement*, the statement to query.
1995     * @return The set part as a struct VariableList*.
1996     * @see SelectStatVLF()
1997 aw0a 1 */
1998 jds 54 extern struct VariableList *SelectStatVLF(CONST struct Statement *s);
1999     /**<
2000     * <!-- macro SelectStatVL(s) -->
2001     * <!-- struct VariableList *SelectStatVLF(s) -->
2002     * <!-- const struct Statement *s; -->
2003     * <!-- Return the set part of a SELECT statement. -->
2004     * Implementation function for SelectStatVL(). Do not call this
2005     * function directly - use SelectStatVL() instead.
2006     */
2007 aw0a 1
2008     #ifdef NDEBUG
2009     #define SelectStatNumberStats(s) ((s)->v.se.n_statements)
2010     #else
2011     #define SelectStatNumberStats(s) SelectStatNumberStatsF(s)
2012     #endif
2013 jds 54 /**<
2014 aw0a 1 * Return the number of statements inside a SELECT statement.
2015 jds 54 * @param s CONST struct Statement*, the statement to query.
2016     * @return The statement count as an int.
2017     * @see SelectStatNumberStatsF()
2018 aw0a 1 */
2019 jds 54 extern int SelectStatNumberStatsF(CONST struct Statement *s);
2020     /**<
2021     * <!-- macro SelectStatNumberStats(s) -->
2022     * <!-- int SelectStatNumberStatsF(s) -->
2023     * <!-- const struct Statement *s; -->
2024     * <!-- Return the number of statements inside a SELECT statement. -->
2025     * Implementation function for SelectStatNumberStats(). Do not call this
2026     * function directly - use SelectStatNumberStats() instead.
2027     */
2028 aw0a 1
2029     #ifdef NDEBUG
2030     #define SelectStatCases(s) ((s)->v.se.cases)
2031     #else
2032     #define SelectStatCases(s) SelectStatCasesF(s)
2033     #endif
2034 jds 54 /**<
2035 aw0a 1 * Return the list of cases of a SELECT statement. To obtain the
2036     * statement list in each of the CASEs, see select.h
2037 jds 54 * @param s CONST struct Statement*, the statement to query.
2038     * @return The list as a struct SelectList*.
2039     * @see SelectStatCasesF()
2040 aw0a 1 */
2041 jds 54 extern struct SelectList *SelectStatCasesF(CONST struct Statement *s);
2042     /**<
2043     * <!-- macro SelectStatCases(s) -->
2044     * <!-- struct SelectList *SelectStatCasesF(s) -->
2045     * <!-- const struct Statement *s; -->
2046     * <!-- Return the list of cases of a SELECT statement. To obtain the -->
2047     * <!-- statement list in each of the CASEs, see select.h -->
2048     * Implementation function for SelectStatCases(). Do not call this
2049     * function directly - use SelectStatCases() instead.
2050     */
2051 aw0a 1
2052 jds 54 extern int CompareSelectStatements(CONST struct Statement *s1,
2053     CONST struct Statement *s2);
2054 aw0a 1
2055 jds 54 /**<
2056 aw0a 1 * Compare functions for SELECT statements. It includes the decomposition
2057     * of the SELECT in the list of variables and the list of CASEs. Also,
2058     * each case is decomposed in the set of values and the list of statements.
2059     * It is done here since we are comparing the statement rather than only a
2060 jds 54 * SelectList structure (select.[ch]).<br><br>
2061 aw0a 1 *
2062     * It is called for the function CompareStatements and it follows the
2063     * same pattern for the comparation.
2064     *
2065     */
2066    
2067     #ifdef NDEBUG
2068     #define SelectContains(s) ((s)->v.se.contains)
2069     #define SelectContainsRelations(s) ((s)->v.se.contains & contains_REL)
2070     #define SelectContainsLogRelations(s) ((s)->v.se.contains & contains_LREL)
2071     #define SelectContainsDefaults(s) ((s)->v.se.contains & contains_DEF)
2072     #define SelectContainsCAssigns(s) ((s)->v.se.contains & contains_CAS)
2073     #define SelectContainsWhen(s) ((s)->v.se.contains & contains_WHEN)
2074     #define SelectContainsAlike(s) ((s)->v.se.contains & contains_AA)
2075     #define SelectContainsAlias(s) ((s)->v.se.contains & contains_ALI)
2076     #define SelectContainsArray(s) ((s)->v.se.contains & contains_ARR)
2077     #define SelectContainsIsa(s) ((s)->v.se.contains & contains_ISA)
2078     #define SelectContainsIrt(s) ((s)->v.se.contains & contains_IRT)
2079     #define SelectContainsAts(s) ((s)->v.se.contains & contains_ATS)
2080     #define SelectContainsWbts(s) ((s)->v.se.contains & contains_WBTS)
2081     #define SelectContainsWnbts(s) ((s)->v.se.contains & contains_WNBTS)
2082     #define SelectContainsWillbe(s) ((s)->v.se.contains & contains_WILLBE)
2083     #define SelectContainsSelect(s) ((s)->v.se.contains & contains_SELECT)
2084     #define SelectContainsConditional(s) ((s)->v.se.contains & contains_COND)
2085     #define SelectContainsIllegal(s) ((s)->v.se.contains & contains_ILL)
2086     #else
2087     #define SelectContains(s) SelectContainsF(s)
2088     #define SelectContainsRelations(s) SelectContainsRelationsF(s)
2089     #define SelectContainsLogRelations(s) SelectContainsLogRelationsF(s)
2090     #define SelectContainsDefaults(s) SelectContainsDefaultsF(s)
2091     #define SelectContainsCAssigns(s) SelectContainsCAssignsF(s)
2092     #define SelectContainsWhen(s) SelectContainsWhenF(s)
2093     #define SelectContainsAlike(s) SelectContainsAlikeF(s)
2094     #define SelectContainsAlias(s) SelectContainsAliasF(s)
2095     #define SelectContainsArray(s) SelectContainsArrayF(s)
2096     #define SelectContainsIsa(s) SelectContainsIsaF(s)
2097     #define SelectContainsIrt(s) SelectContainsIrtF(s)
2098     #define SelectContainsAts(s) SelectContainsAtsF(s)
2099     #define SelectContainsWbts(s) SelectContainsWbtsF(s)
2100     #define SelectContainsWnbts(s) SelectContainsWnbtsF(s)
2101     #define SelectContainsWillbe(s) SelectContainsWillbeF(s)
2102     #define SelectContainsSelect(s) SelectContainsSelectF(s)
2103     #define SelectContainsConditional(s) SelectContainsConditionalF(s)
2104     #define SelectContainsIllegal(s) SelectContainsIllegalF(s)
2105     #endif
2106 jds 54 extern unsigned SelectContainsF(CONST struct Statement *s);
2107     extern unsigned SelectContainsRelationsF(CONST struct Statement *s);
2108     extern unsigned SelectContainsLogRelationsF(CONST struct Statement *s);
2109     extern unsigned SelectContainsDefaultsF(CONST struct Statement *s);
2110     extern unsigned SelectContainsCAssignsF(CONST struct Statement *s);
2111     extern unsigned SelectContainsWhenF(CONST struct Statement *s);
2112     extern unsigned SelectContainsAlikeF(CONST struct Statement *s);
2113     extern unsigned SelectContainsAliasF(CONST struct Statement *s);
2114     extern unsigned SelectContainsArrayF(CONST struct Statement *s);
2115     extern unsigned SelectContainsIsaF(CONST struct Statement *s);
2116     extern unsigned SelectContainsIrtF(CONST struct Statement *s);
2117     extern unsigned SelectContainsAtsF(CONST struct Statement *s);
2118     extern unsigned SelectContainsWbtsF(CONST struct Statement *s);
2119     extern unsigned SelectContainsWnbtsF(CONST struct Statement *s);
2120     extern unsigned SelectContainsWillbeF(CONST struct Statement *s);
2121     extern unsigned SelectContainsSelectF(CONST struct Statement *s);
2122     extern unsigned SelectContainsConditionalF(CONST struct Statement *s);
2123     extern unsigned SelectContainsIllegalF(CONST struct Statement *s);
2124 ben.allan 33 /**<
2125 jds 54 * <pre>
2126 aw0a 1 * macro SelectContains(s)
2127     * unsigned SelectContainsF(s)
2128     * macro SelectContainsRelations(s)
2129     * unsigned SelectContainsRelationsF(s)
2130     * macro SelectContainsLogRelations(s)
2131     * unsigned SelectContainsLogRelationsF(s)
2132     * macro SelectContainsDefaults(s)
2133     * unsigned SelectContainsDefaultsF(s)
2134     * macro SelectContainsCAssigns(s)
2135     * unsigned SelectContainsCAssignsF(s)
2136     * macro SelectContainsWhen(s)
2137     * unsigned SelectContainsWhenF(s)
2138     * macro SelectContainsIllegal(s)
2139     * unsigned SelectContainsIllegalF(s)
2140     * etc....
2141     * const struct Statement *s;
2142     *
2143     * Respectively:
2144     * Returns the entire contains field.
2145     * Return true if the SELECT statement given contains itself or in any of
2146     * its nested statements a relation.
2147     * Return true if the SELECT statement given contains itself or in any of
2148     * its nested statements a default statement.
2149     * Return true if the SELECT statement given contains itself or in any of
2150     * its nested statements a constant/structural variable assignment.
2151     * Return true if the SELECT statement given contains itself or in any of
2152     * its nested statements a WHEN statement.
2153     * Likewise for:
2154     * ARE_ALIKE
2155     * ALIASES
2156     * CREATE ARRAY
2157     * IS_A
2158     * IS_REFINED_TO
2159     * ARE_THE_SAME
2160     * WILL_BE_THE_SAME
2161     * WILL_BE
2162     * SELECT
2163     * CONDITIONAL.
2164     * Return true if the Select statement given contains itself or in any of
2165     * its nested statements an illegal instruction.
2166 jds 54 * </pre>
2167     * @todo Rework documentation for individual functions.
2168 aw0a 1 */
2169    
2170 jds 54 /*==============================*/
2171 aw0a 1
2172 jds 54 /* * * StateSwitch functions * * */
2173 aw0a 1
2174     #ifdef NDEBUG
2175     #define SwitchStatVL(s) ((s)->v.sw.vl)
2176     #else
2177     #define SwitchStatVL(s) SwitchStatVLF(s)
2178     #endif
2179 jds 54 /**<
2180 aw0a 1 * Return the set part of a SWITCH statement.
2181 jds 54 * @param s CONST struct Statement*, the statement to query.
2182     * @return The set part as a struct VariableList*.
2183     * @see SwitchStatVLF()
2184 aw0a 1 */
2185 jds 54 extern struct VariableList *SwitchStatVLF(CONST struct Statement *s);
2186     /**<
2187     * <!-- macro SwitchStatVL(s) -->
2188     * <!-- struct VariableList *SwitchStatVLF(s) -->
2189     * <!-- const struct Statement *s; -->
2190     * <!-- Return the set part of a SWITCH statement. -->
2191     * Implementation function for SwitchStatVL(). Do not call this
2192     * function directly - use SwitchStatVL() instead.
2193     */
2194 aw0a 1
2195     #ifdef NDEBUG
2196     #define SwitchStatCases(s) ((s)->v.sw.cases)
2197     #else
2198     #define SwitchStatCases(s) SwitchStatCasesF(s)
2199     #endif
2200 jds 54 /**<
2201 aw0a 1 * Return the list of cases of a SWITCH statement. To obtain the
2202     * statement list in each of the CASEs, see switch.h
2203 jds 54 * @param s CONST struct Statement*, the statement to query.
2204     * @return The list as a struct SwitchList*.
2205     * @see SwitchStatCasesF()
2206 aw0a 1 */
2207 jds 54 extern struct SwitchList *SwitchStatCasesF(CONST struct Statement *s);
2208     /**<
2209     * <!-- macro SwitchStatCases(s) -->
2210     * <!-- struct SwitchList *SwitchStatCasesF(s) -->
2211     * <!-- const struct Statement *s; -->
2212     * <!-- Return the list of cases of a SWITCH statement. To obtain the -->
2213     * <!-- statement list in each of the CASEs, see switch.h -->
2214     * Implementation function for SwitchStatCases(). Do not call this
2215     * function directly - use SwitchStatCases() instead.
2216     */
2217 aw0a 1
2218 jds 54 extern int CompareSwitchStatements(CONST struct Statement *s1,
2219     CONST struct Statement *s2);
2220     /**<
2221 aw0a 1 * Compare functions for SWITCH statements. It includes the decomposition
2222     * of the Switch in the list of variables and the list of CASEs. Also,
2223     * each case is decomposed in the set of values and the list of statements.
2224     * It is done here since we are comparing the statement rather than only a
2225 jds 54 * SwitchList structure (switch.[ch]).<br><br>
2226 aw0a 1 *
2227     * It is called for the function CompareStatements and it follows the
2228     * same pattern for the comparation.
2229     */
2230    
2231 jds 54 /*====================================*/
2232 aw0a 1
2233 jds 54 extern int CompareStatements(CONST struct Statement *s1,
2234     CONST struct Statement *s2);
2235     /**<
2236     * <!-- CompareStatements(s1,s2); -->
2237 aw0a 1 * Returns -1,0,1 as s1 is <, ==, > s2.
2238     * s1 < s2 if type(s1) < type(s2), exception: NULL > all statements.
2239     * For statements of the same type, compared according to
2240     * the number of arguments or alphabetically, as appropriate.
2241     * We are comparing statement contents, not statement memory location
2242 jds 54 * or origin.<br><br>
2243 aw0a 1 * Special notes:
2244     * For a less picky version (when it comes to type compatibility)
2245     * see CompareISStatements below.
2246     */
2247    
2248 jds 54 extern int CompareISStatements(CONST struct Statement *s1,
2249     CONST struct Statement *s2);
2250     /**<
2251     * <!-- CompareISStatements(s1,s2); -->
2252 aw0a 1 * s1 and s2 must be StateIS or some of the StateARE based statements, i.e.
2253     * IS_A WILL_BE IS_REFINED_TO WILL_BE_THE_SAME statements, or
2254     * s1 and s2 must be relations.
2255     * FOR loops containing only these kinds are also allowed.
2256     * Returns -1,0,1 as s1 is <, ==, > s2.
2257     * s1 < s2 if StatementType(s1) < StatementType(s2),
2258 jds 54 * exception: NULL > all statements.<br><br>
2259 aw0a 1 *
2260     * For statements of the same StatementType, compared according to
2261     * the number of arguments or alphabetically, as appropriate
2262     * after type compatibility is checked. In particular,
2263     * if MoreRefined(GetStateType(s1),GetStatType(s2)) returns
2264     * the type from s2, the two potentially type differing statements
2265     * which OTHERWISE are identical are considered identical.
2266     * If s1 is more refined than s2, the statements are considered
2267     * incompatible. If s1 has a WITH_VALUE clause that does not match
2268 jds 54 * s2, the statements are incompatible.<br><br>
2269 aw0a 1 *
2270     * We are comparing statement contents, not statement memory location
2271 jds 54 * or origin.<br><br>
2272 aw0a 1 *
2273     * Special notes:
2274     * For a more picky version (when it comes to type compatibility)
2275     * see CompareStatements above.
2276     */
2277    
2278 jds 54 #endif /* __STATEMENT_H_SEEN__ */
2279    

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