88 int next_param, param_count; |
88 int next_param, param_count; |
89 identifier_c *current_param_name; |
89 identifier_c *current_param_name; |
90 symbol_c *current_param_type; |
90 symbol_c *current_param_type; |
91 symbol_c *current_param_default_value; |
91 symbol_c *current_param_default_value; |
92 param_direction_t current_param_direction; |
92 param_direction_t current_param_direction; |
|
93 bool en_declared; |
|
94 bool eno_declared; |
93 |
95 |
94 private: |
96 private: |
95 void* handle_param_list(list_c *list) { |
97 void* handle_param_list(list_c *list) { |
96 if (next_param <= param_count + list->n) |
98 if (next_param <= param_count + list->n) |
97 return list->elements[next_param - param_count - 1]; |
99 return list->elements[next_param - param_count - 1]; |
125 /* start off at the first parameter once again... */ |
127 /* start off at the first parameter once again... */ |
126 void reset(void) { |
128 void reset(void) { |
127 next_param = param_count = 0; |
129 next_param = param_count = 0; |
128 current_param_name = NULL; |
130 current_param_name = NULL; |
129 current_param_type = current_param_default_value = NULL; |
131 current_param_type = current_param_default_value = NULL; |
|
132 en_declared = false; |
|
133 eno_declared = false; |
130 } |
134 } |
131 |
135 |
132 /* initialise the iterator object. |
136 /* initialise the iterator object. |
133 * We must be given a reference to the function declaration |
137 * We must be given a reference to the function declaration |
134 * that will be analysed... |
138 * that will be analysed... |
163 * |
167 * |
164 * Returns the parameter's name! |
168 * Returns the parameter's name! |
165 */ |
169 */ |
166 identifier_c *next(void) { |
170 identifier_c *next(void) { |
167 void *res; |
171 void *res; |
|
172 identifier_c *identifier; |
168 param_count = 0; |
173 param_count = 0; |
169 next_param++; |
174 next_param++; |
170 res = f_decl->accept(*this); |
175 res = f_decl->accept(*this); |
171 if (res == NULL) |
176 if (res != NULL) { |
|
177 symbol_c *sym = (symbol_c *)res; |
|
178 identifier = dynamic_cast<identifier_c *>(sym); |
|
179 if (identifier == NULL) |
|
180 ERROR; |
|
181 } |
|
182 else if (!en_declared) { |
|
183 current_param_direction = direction_in; |
|
184 identifier = declare_en_param(); |
|
185 } |
|
186 else if (!eno_declared) { |
|
187 current_param_direction = direction_out; |
|
188 identifier = declare_eno_param(); |
|
189 } |
|
190 else |
172 return NULL; |
191 return NULL; |
173 |
192 |
174 symbol_c *sym = (symbol_c *)res; |
|
175 identifier_c *identifier = dynamic_cast<identifier_c *>(sym); |
|
176 if (identifier == NULL) |
|
177 ERROR; |
|
178 |
|
179 current_param_name = identifier; |
193 current_param_name = identifier; |
180 return current_param_name; |
194 return current_param_name; |
|
195 } |
|
196 |
|
197 identifier_c *declare_en_param(void) { |
|
198 en_declared = true; |
|
199 identifier_c *identifier = new identifier_c("EN"); |
|
200 current_param_type = (symbol_c*)(new bool_type_name_c()); |
|
201 current_param_default_value = (symbol_c*)(new boolean_literal_c(current_param_type, new boolean_true_c())); |
|
202 return identifier; |
|
203 } |
|
204 |
|
205 identifier_c *declare_eno_param(void) { |
|
206 eno_declared = true; |
|
207 identifier_c *identifier = new identifier_c("ENO"); |
|
208 current_param_type = (symbol_c*)(new bool_type_name_c()); |
|
209 current_param_default_value = NULL; |
|
210 return identifier; |
181 } |
211 } |
182 |
212 |
183 /* Returns the currently referenced parameter's default value, |
213 /* Returns the currently referenced parameter's default value, |
184 * or NULL if none is specified in the function declrataion itself. |
214 * or NULL if none is specified in the function declrataion itself. |
185 */ |
215 */ |
207 current_param_direction = direction_in; |
237 current_param_direction = direction_in; |
208 return symbol->input_declaration_list->accept(*this); |
238 return symbol->input_declaration_list->accept(*this); |
209 } |
239 } |
210 void *visit(input_declaration_list_c *symbol) {TRACE("input_declaration_list_c"); return iterate_list(symbol);} |
240 void *visit(input_declaration_list_c *symbol) {TRACE("input_declaration_list_c"); return iterate_list(symbol);} |
211 void *visit(edge_declaration_c *symbol) {TRACE("edge_declaration_c"); return symbol->var1_list->accept(*this);} |
241 void *visit(edge_declaration_c *symbol) {TRACE("edge_declaration_c"); return symbol->var1_list->accept(*this);} |
212 |
242 void *visit(en_param_declaration_c *symbol) { |
|
243 TRACE("en_param_declaration_c"); |
|
244 if (en_declared) ERROR; |
|
245 return (void *)declare_en_param(); |
|
246 } |
213 #if 0 |
247 #if 0 |
214 /* var1_list ':' array_spec_init */ |
248 /* var1_list ':' array_spec_init */ |
215 SYM_REF2(array_var_init_decl_c, var1_list, array_spec_init) |
249 SYM_REF2(array_var_init_decl_c, var1_list, array_spec_init) |
216 |
250 |
217 /* var1_list ':' initialized_structure */ |
251 /* var1_list ':' initialized_structure */ |
227 |
261 |
228 void *visit(output_declarations_c *symbol) { |
262 void *visit(output_declarations_c *symbol) { |
229 TRACE("output_declarations_c"); |
263 TRACE("output_declarations_c"); |
230 current_param_direction = direction_out; |
264 current_param_direction = direction_out; |
231 return symbol->var_init_decl_list->accept(*this); |
265 return symbol->var_init_decl_list->accept(*this); |
|
266 } |
|
267 void *visit(eno_param_declaration_c *symbol) { |
|
268 TRACE("eno_param_declaration_c"); |
|
269 if (eno_declared) ERROR; |
|
270 return (void *)declare_eno_param(); |
232 } |
271 } |
233 void *visit(input_output_declarations_c *symbol) { |
272 void *visit(input_output_declarations_c *symbol) { |
234 TRACE("input_output_declarations_c"); |
273 TRACE("input_output_declarations_c"); |
235 current_param_direction = direction_inout; |
274 current_param_direction = direction_inout; |
236 return symbol->var_declaration_list->accept(*this); |
275 return symbol->var_declaration_list->accept(*this); |