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