1 |
jds |
54 |
/* |
2 |
aw0a |
1 |
* FOR Loop Index Variable Table |
3 |
|
|
* by Tom Epperly |
4 |
|
|
* Created: 1/14/89 |
5 |
|
|
* Version: $Revision: 1.8 $ |
6 |
|
|
* Version control file: $RCSfile: forvars.h,v $ |
7 |
|
|
* Date last modified: $Date: 1998/02/05 16:36:08 $ |
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 |
|
|
* FOR Loop Index Variable Table. |
32 |
|
|
* <pre> |
33 |
aw0a |
1 |
* When #including forvars.h, make sure these files are #included first: |
34 |
jds |
54 |
* #include "utilities/ascConfig.h" |
35 |
aw0a |
1 |
* #include "compiler.h" |
36 |
jds |
54 |
* </pre> |
37 |
aw0a |
1 |
*/ |
38 |
|
|
|
39 |
jds |
54 |
#ifndef __FORVARS_H_SEEN__ |
40 |
|
|
#define __FORVARS_H_SEEN__ |
41 |
aw0a |
1 |
|
42 |
|
|
enum for_kind { |
43 |
|
|
f_untyped, |
44 |
|
|
f_integer, |
45 |
|
|
f_symbol, |
46 |
|
|
f_set |
47 |
|
|
}; |
48 |
|
|
|
49 |
|
|
union for_union_t{ |
50 |
|
|
long ivalue; |
51 |
|
|
symchar *sym_ptr; |
52 |
|
|
struct set_t *sptr; |
53 |
|
|
}; |
54 |
|
|
|
55 |
|
|
struct for_var_t { |
56 |
jds |
54 |
symchar *name; /**< internally used as a recycle ptr */ |
57 |
|
|
enum for_kind t; /**< what type of index variable it is */ |
58 |
aw0a |
1 |
union for_union_t value; |
59 |
|
|
}; |
60 |
|
|
|
61 |
|
|
#define for_table_t gl_list_t |
62 |
|
|
|
63 |
|
|
extern struct for_table_t *CreateForTable(void); |
64 |
jds |
54 |
/**< |
65 |
|
|
* <!-- struct for_table_t *CreateForTable() --> |
66 |
aw0a |
1 |
* This function creates an empty FOR table which is then ready for use. |
67 |
|
|
*/ |
68 |
|
|
|
69 |
jds |
54 |
extern void DestroyForTable(struct for_table_t *ft); |
70 |
|
|
/**< |
71 |
|
|
* <!-- void DestroyForTable(ft) --> |
72 |
|
|
* <!-- struct for_table_t *ft; --> |
73 |
aw0a |
1 |
* This procedure deallocates the memory associated with the for table. |
74 |
|
|
*/ |
75 |
|
|
|
76 |
jds |
54 |
extern void WriteForTable(FILE *out, struct for_table_t *ft); |
77 |
ben.allan |
33 |
/**< |
78 |
jds |
54 |
* <!-- void WriteForTable(out,ft) --> |
79 |
|
|
* <!-- FILE *out; --> |
80 |
|
|
* <!-- struct for_table_t *ft; --> |
81 |
aw0a |
1 |
* This procedure writes the contents of a for table. |
82 |
|
|
*/ |
83 |
|
|
|
84 |
jds |
54 |
extern unsigned long ActiveForLoops(CONST struct for_table_t *ft); |
85 |
ben.allan |
33 |
/**< |
86 |
jds |
54 |
* <!-- unsigned long ActiveForLoops(ft) --> |
87 |
|
|
* <!-- struct for_table_t *ft; --> |
88 |
aw0a |
1 |
* Returns the number of active FOR loops. |
89 |
|
|
*/ |
90 |
|
|
|
91 |
jds |
54 |
extern void AddLoopVariable(struct for_table_t *ft,struct for_var_t *var); |
92 |
ben.allan |
33 |
/**< |
93 |
jds |
54 |
* <!-- void AddLoopVariable(ft,var) --> |
94 |
|
|
* <!-- struct for_table_t *ft; --> |
95 |
|
|
* <!-- struct for_var_t *var; --> |
96 |
aw0a |
1 |
* Add another loop variable to the for table. Adding a loop variable to |
97 |
|
|
* the for table is like activating the FOR loop variable |
98 |
|
|
*/ |
99 |
|
|
|
100 |
jds |
54 |
extern struct for_var_t *LoopIndex(CONST struct for_table_t *ft, |
101 |
|
|
unsigned long num); |
102 |
|
|
/**< |
103 |
|
|
* <!-- struct for_var_t *LoopIndex(ft,num) --> |
104 |
|
|
* <!-- const struct for_table_t *ft; --> |
105 |
|
|
* <!-- unsigned long num; --> |
106 |
aw0a |
1 |
* Returns the num'th loop index. Loop indices are numbered in the |
107 |
|
|
* order they are added to the list. The first being one and the last |
108 |
|
|
* being the number given by ActiveForLoops(ft). |
109 |
|
|
*/ |
110 |
|
|
|
111 |
jds |
54 |
extern struct for_var_t *FindForVar(CONST struct for_table_t *ft, |
112 |
|
|
symchar *name); |
113 |
ben.allan |
33 |
/**< |
114 |
jds |
54 |
* <!-- struct for_var_t *FindForVar(ft,name) --> |
115 |
|
|
* <!-- CONST struct for_table_t *ft; --> |
116 |
|
|
* <!-- symchar *name; --> |
117 |
aw0a |
1 |
* Searches for a FOR index variable which matches name. If it finds a |
118 |
|
|
* match it returns the for_var_t; otherwise, it returns NULL. |
119 |
|
|
*/ |
120 |
|
|
|
121 |
jds |
54 |
extern void RemoveForVariable(struct for_table_t *ft); |
122 |
ben.allan |
33 |
/**< |
123 |
jds |
54 |
* <!-- void RemoveForVariable(ft) --> |
124 |
|
|
* <!-- struct for_table_t *ft; --> |
125 |
aw0a |
1 |
* This removes the most recently added FOR index variable. The |
126 |
|
|
* for_var_t is automatically deallocated. |
127 |
|
|
*/ |
128 |
|
|
|
129 |
jds |
54 |
/* |
130 |
aw0a |
1 |
* Routines to create, query, modify and destroy for_var_t's. |
131 |
|
|
*/ |
132 |
|
|
|
133 |
jds |
54 |
extern struct for_var_t *CreateForVar(symchar *name); |
134 |
ben.allan |
33 |
/**< |
135 |
jds |
54 |
* <!-- struct for_var_t *CreateForVar(name) --> |
136 |
|
|
* <!-- const char *name; --> |
137 |
aw0a |
1 |
* Create a for_var_t with the name given. This for_var_t starts out being |
138 |
|
|
* f_untyped. You can use the routines below to set type and values. |
139 |
|
|
* Never free a for_var_t except by using DestroyForVar below. |
140 |
|
|
*/ |
141 |
|
|
|
142 |
jds |
54 |
extern void SetForVarType(struct for_var_t *ft, enum for_kind t); |
143 |
ben.allan |
33 |
/**< |
144 |
jds |
54 |
* <!-- void SetForVarType(fv,t) --> |
145 |
|
|
* <!-- struct for_var_t *fv; --> |
146 |
|
|
* <!-- enum for_kind t; --> |
147 |
aw0a |
1 |
* Set the type to t. fv must be untyped. |
148 |
|
|
*/ |
149 |
|
|
|
150 |
jds |
54 |
extern void SetForInteger(struct for_var_t *fv, long ivalue); |
151 |
ben.allan |
33 |
/**< |
152 |
jds |
54 |
* <!-- void SetForInteger(fv,ivalue) --> |
153 |
|
|
* <!-- struct for_var_t *fv; --> |
154 |
|
|
* <!-- long ivalue; --> |
155 |
aw0a |
1 |
* Set an integer for variable's value to ivalue. |
156 |
|
|
*/ |
157 |
|
|
|
158 |
jds |
54 |
extern void SetForSymbol(struct for_var_t *fv, symchar *sym_ptr); |
159 |
ben.allan |
33 |
/**< |
160 |
jds |
54 |
* <!-- void SetForSymbol(fv,sym_ptr) --> |
161 |
|
|
* <!-- struct for_var_t *fv; --> |
162 |
|
|
* <!-- const char *sym_ptr; --> |
163 |
aw0a |
1 |
* Set a symbol for variable's value to sym_ptr. |
164 |
|
|
*/ |
165 |
|
|
|
166 |
jds |
54 |
extern void SetForSet(struct for_var_t *fv, struct set_t *sptr); |
167 |
|
|
/**< |
168 |
|
|
* <!-- void SetForSet(fv,sptr) --> |
169 |
|
|
* <!-- struct for_var_t *fv; --> |
170 |
|
|
* <!-- struct set_t *sptr; --> |
171 |
aw0a |
1 |
* Set a set for variable's value to sptr. |
172 |
|
|
*/ |
173 |
|
|
|
174 |
jds |
54 |
extern enum for_kind GetForKind(CONST struct for_var_t *fv); |
175 |
ben.allan |
33 |
/**< |
176 |
jds |
54 |
* <!-- for_kind GetForKind(fv) --> |
177 |
|
|
* <!-- const struct for_var_t *fv; --> |
178 |
aw0a |
1 |
* Return the type of the for variable. |
179 |
|
|
*/ |
180 |
|
|
|
181 |
jds |
54 |
extern symchar *GetForName(CONST struct for_var_t *fv); |
182 |
ben.allan |
33 |
/**< |
183 |
jds |
54 |
* <!-- symchar *GetForName(fv) --> |
184 |
|
|
* <!-- const struct for_var_t *fv; --> |
185 |
aw0a |
1 |
* Return the name of the for variable |
186 |
|
|
*/ |
187 |
|
|
|
188 |
jds |
54 |
extern long GetForInteger(CONST struct for_var_t *fv); |
189 |
ben.allan |
33 |
/**< |
190 |
jds |
54 |
* <!-- long GetForInteger(fv) --> |
191 |
|
|
* <!-- const struct for_var_t *fv; --> |
192 |
aw0a |
1 |
* Return the value of an integer for variable. |
193 |
|
|
*/ |
194 |
|
|
|
195 |
jds |
54 |
extern symchar *GetForSymbol(CONST struct for_var_t *fv); |
196 |
|
|
/**< |
197 |
|
|
* <!-- symchar *GetForSymbol(fv) --> |
198 |
|
|
* <!-- const struct for_var_t *fv; --> |
199 |
aw0a |
1 |
* Return the value of a symbol for variable. |
200 |
|
|
*/ |
201 |
|
|
|
202 |
jds |
54 |
extern CONST struct set_t *GetForSet(CONST struct for_var_t *fv); |
203 |
ben.allan |
33 |
/**< |
204 |
jds |
54 |
* <!-- const struct set_t *GetForSet(fv) --> |
205 |
|
|
* <!-- const struct for_var_t *fv; --> |
206 |
aw0a |
1 |
* Return the value of a set for variable. |
207 |
|
|
*/ |
208 |
|
|
|
209 |
jds |
54 |
extern void DestroyForVar(struct for_var_t *fv); |
210 |
ben.allan |
33 |
/**< |
211 |
jds |
54 |
* <!-- void DestroyForVar(fv) --> |
212 |
|
|
* <!-- struct for_var_t *fv; --> |
213 |
aw0a |
1 |
* Deallocate the memory of this for variable. In the case of a set |
214 |
|
|
* for variable, this will also deallocate the set. |
215 |
|
|
*/ |
216 |
|
|
|
217 |
|
|
extern int ClearForVarRecycle(void); |
218 |
ben.allan |
33 |
/**< |
219 |
jds |
54 |
* <!-- int ClearForVarRecycle(); --> |
220 |
aw0a |
1 |
* Deallocates the recycle list of forvar_t. returns the list length, |
221 |
|
|
* if anyone cares. |
222 |
|
|
* This function may be safely called at any time. |
223 |
|
|
* There is no recycle initialization function. |
224 |
|
|
*/ |
225 |
jds |
54 |
|
226 |
|
|
#endif /* __FORVARS_H_SEEN__ */ |
227 |
|
|
|