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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1066 - (show annotations) (download) (as text)
Sun Jan 7 10:02:41 2007 UTC (17 years, 8 months ago) by johnpye
File MIME type: text/x-chdr
File size: 5927 byte(s)
Adding doxygen 'addtogroup' for Solver, Compiler, Integrator.
1 /* ASCEND modelling environment
2 Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly
3 Copyright (C) 2006 Carnegie Mellon University
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19 *//**
20 @file
21 Statement list routines.
22
23 Requires:
24 #include "utilities/ascConfig.h"
25 #include "compiler.h"
26 #include "list.h"
27 #include "stattypes.h"
28 *//*
29 by Tom Epperly
30 Version: $Revision: 1.9 $
31 Version control file: $RCSfile: slist.h,v $
32 Date last modified: $Date: 1997/07/18 12:35:00 $
33 Last modified by: $Author: mthomas $
34 */
35
36 #ifndef ASC_SLIST_H
37 #define ASC_SLIST_H
38
39 /** addtogroup compiler Compiler
40 @{
41 */
42
43 #include <utilities/ascConfig.h>
44
45 extern struct StatementList *CreateStatementList(struct gl_list_t *l);
46 /**<
47 * Create a statement list structure.
48 */
49
50 extern struct StatementList *EmptyStatementList(void);
51 /**<
52 * Create an empty statement list structure.
53 */
54
55 #ifdef NDEBUG
56 #define GetList(sl) ((sl)->l)
57 #else
58 #define GetList(sl) GetListF(sl,__FILE__,__LINE__)
59 #endif
60 /**<
61 * Return the list structure.
62 * @param sl CONST struct StatementList*, list to query.
63 * @return The list as a struct gl_list_t*.
64 * @see GetListF()
65 */
66 ASC_DLLSPEC struct gl_list_t *GetListF(CONST struct StatementList *sl,
67 CONST char *file,
68 int line);
69 /**<
70 * Implementation function for GetList(). Do not call this
71 * function directly - use GetList() instead.
72 */
73
74 extern unsigned long StatementInList(CONST struct StatementList *sl,
75 CONST struct Statement *s);
76 /**<
77 * Returns the position of s in sl, if s is in sl. otherwise returns 0.
78 * Handles NULL input gracefully. Does not look inside compound statements.
79 */
80
81 extern struct Statement *GetStatement(CONST struct StatementList *sl,
82 unsigned long int j);
83 /**<
84 * Returns the jth statement from sl, or NULL if it doesn't exist.
85 * Tolerates all forms of insane input, and much code relies on this fact.
86 * Correct values of j are 1..StatementListLength(sl).
87 */
88
89 extern struct StatementList *CopyStatementList(struct StatementList *sl);
90 /**<
91 * By reference on the slist. Statements in the list are not
92 * changed in any way.
93 */
94
95 extern struct StatementList *CopyListToModify(struct StatementList *sl);
96 /**<
97 * Creates new slist and new copies in memory of all that it contains.
98 * Avoid this operator if possible.
99 */
100
101 extern int CompareStatementLists(CONST struct StatementList *sl1,
102 CONST struct StatementList *sl2,
103 unsigned long int *diff);
104 /**<
105 * Returns -1 0 1 as sl1 < == > sl2.
106 * If cmp != 0, diff is the position of the first unequal statement.
107 * If the lists are of different length, but the longer is contentwise
108 * identical up to the length of the shorter, then diff will be
109 * the length of the shorter list+1.
110 * Returns the position of the first statement which is not
111 * equivalent between sl1 and sl2.
112 * diff must not be NULL.
113 * Returns 0 if there is no difference.
114 */
115
116 extern int CompareISLists(CONST struct StatementList *sl1,
117 CONST struct StatementList *sl2,
118 unsigned long int *diff);
119 /**<
120 * Compare slists containing only StateIS, some StateARE
121 * (WILL_BE, IS_A, IS_REFINED_TO, WILL_BE_THE_SAME)
122 * statements. (Particularly no compound statements are allowed,
123 * except FOR loops containing only the above types.<br><br>
124 *
125 * Returns -1 0 1 as sl1 < == > sl2.
126 * If cmp != 0, diff is the position of the first type incompatible statement.
127 * If the lists are of different length, but the longer is contentwise
128 * identical up to the length of the shorter, then diff will be
129 * the length of the shorter list+1.
130 * Returns the position of the first statement which is not
131 * compatible between sl1 and sl2.
132 * Returns 0 if there is no incompatibility.<br><br>
133 *
134 * Special usage notes:
135 * In this function, order matters: sl2 statements should be 'more refined'
136 * than sl1 statements.
137 * In particular, incompatibility exists unless the type given in
138 * sl2 == or MoreRefined() than the type given in sl1.
139 */
140
141 extern void AppendStatement(struct StatementList *sl, struct Statement *s);
142 /**<
143 * Add s to sl, copying s by reference.
144 * sl may be empty, but not NULL. s must not be NULL.
145 */
146
147 extern struct StatementList
148 *AppendStatementLists(CONST struct StatementList *sl1,
149 struct StatementList *sl2);
150 /**<
151 * Make a _new_ list, slr, that contains all the statements
152 * (copied by reference) from sl1 followed by
153 * all the statements from sl2 (copied by reference).
154 * Then destroy list sl2. (not its statements).
155 * sl1 and sl2 may be empty, but not NULL.<br><br>
156 *
157 * sl1 is not destroyed, on the assumption that it belongs
158 * to someone else who isn't done with it yet.<br><br>
159 *
160 * This is the function to use to copy an existing list by
161 * refering to its statements rather than by just upping the
162 * reference count on the slist.
163 * e.g. to copy:
164 * newlist = AppendStatementList(oldlist,EmptyStatementList());
165 */
166
167 ASC_DLLSPEC void DestroyStatementList(struct StatementList *sl);
168 /**<
169 * Destroy a statement list. Tolerates null input.
170 */
171
172 /* @} */
173
174 #endif /* ASC_SLIST_H */

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