46 |
46 |
47 |
47 |
48 |
48 |
49 #include "function_call_param_iterator.hh" |
49 #include "function_call_param_iterator.hh" |
50 #include <strings.h> |
50 #include <strings.h> |
|
51 #include "../main.hh" // required for ERROR() and ERROR_MSG() macros. |
51 |
52 |
52 |
53 |
53 //#define DEBUG |
54 //#define DEBUG |
54 #ifdef DEBUG |
55 #ifdef DEBUG |
55 #define TRACE(classname) printf("\n____%s____\n",classname); |
56 #define TRACE(classname) printf("\n____%s____\n",classname); |
56 #else |
57 #else |
57 #define TRACE(classname) |
58 #define TRACE(classname) |
58 #endif |
59 #endif |
59 |
60 |
60 #define ERROR error_exit(__FILE__,__LINE__) |
|
61 /* function defined in main.cc */ |
|
62 extern void error_exit(const char *file_name, int line_no); |
|
63 |
61 |
64 |
62 |
65 |
63 |
66 |
64 |
67 |
65 |
182 * You can determine the value being passed by calling |
180 * You can determine the value being passed by calling |
183 * function_call_param_iterator_c::search_f() |
181 * function_call_param_iterator_c::search_f() |
184 */ |
182 */ |
185 symbol_c *function_call_param_iterator_c::next_f(void) { |
183 symbol_c *function_call_param_iterator_c::next_f(void) { |
186 current_value = NULL; |
184 current_value = NULL; |
|
185 current_assign_direction = assign_none; |
187 param_count = 0; |
186 param_count = 0; |
188 iterate_f_next_param++; |
187 iterate_f_next_param++; |
189 current_operation = function_call_param_iterator_c::iterate_f_op; |
188 current_operation = function_call_param_iterator_c::iterate_f_op; |
190 void *res = f_call->accept(*this); |
189 void *res = f_call->accept(*this); |
191 return (symbol_c *)res; |
190 return (symbol_c *)res; |
199 * |
198 * |
200 * Returns whatever is being passed to the parameter! |
199 * Returns whatever is being passed to the parameter! |
201 */ |
200 */ |
202 symbol_c *function_call_param_iterator_c::next_nf(void) { |
201 symbol_c *function_call_param_iterator_c::next_nf(void) { |
203 current_value = NULL; |
202 current_value = NULL; |
|
203 current_assign_direction = assign_none; |
204 param_count = 0; |
204 param_count = 0; |
205 iterate_nf_next_param++; |
205 iterate_nf_next_param++; |
206 current_operation = function_call_param_iterator_c::iterate_nf_op; |
206 current_operation = function_call_param_iterator_c::iterate_nf_op; |
207 void *res = f_call->accept(*this); |
207 void *res = f_call->accept(*this); |
208 current_value = (symbol_c *)res; |
208 current_value = (symbol_c *)res; |
210 } |
210 } |
211 |
211 |
212 /* Search for the value passed to the parameter named <param_name>... */ |
212 /* Search for the value passed to the parameter named <param_name>... */ |
213 symbol_c *function_call_param_iterator_c::search_f(symbol_c *param_name) { |
213 symbol_c *function_call_param_iterator_c::search_f(symbol_c *param_name) { |
214 current_value = NULL; |
214 current_value = NULL; |
|
215 current_assign_direction = assign_none; |
215 if (NULL == param_name) ERROR; |
216 if (NULL == param_name) ERROR; |
216 search_param_name = dynamic_cast<identifier_c *>(param_name); |
217 search_param_name = dynamic_cast<identifier_c *>(param_name); |
217 if (NULL == search_param_name) ERROR; |
218 if (NULL == search_param_name) ERROR; |
218 current_operation = function_call_param_iterator_c::search_f_op; |
219 current_operation = function_call_param_iterator_c::search_f_op; |
219 void *res = f_call->accept(*this); |
220 void *res = f_call->accept(*this); |
231 /* Returns the value being passed to the current parameter. */ |
232 /* Returns the value being passed to the current parameter. */ |
232 symbol_c *function_call_param_iterator_c::get_current_value(void) { |
233 symbol_c *function_call_param_iterator_c::get_current_value(void) { |
233 return current_value; |
234 return current_value; |
234 } |
235 } |
235 |
236 |
|
237 /* Returns the value being passed to the current parameter. */ |
|
238 function_call_param_iterator_c::assign_direction_t function_call_param_iterator_c::get_assign_direction(void) { |
|
239 return current_assign_direction; |
|
240 } |
|
241 |
|
242 |
236 /********************************/ |
243 /********************************/ |
237 /* B 1.7 Configuration elements */ |
244 /* B 1.7 Configuration elements */ |
238 /********************************/ |
245 /********************************/ |
239 |
246 |
240 /* |
247 /* |
337 */ |
344 */ |
338 symbolic_variable_c *symb_var = dynamic_cast<symbolic_variable_c *>(symbol->symbolic_variable); |
345 symbolic_variable_c *symb_var = dynamic_cast<symbolic_variable_c *>(symbol->symbolic_variable); |
339 if (NULL == symb_var) |
346 if (NULL == symb_var) |
340 ERROR; |
347 ERROR; |
341 |
348 |
|
349 current_assign_direction = assign_in; |
342 return handle_parameter_assignment(symb_var->var_name, symbol->prog_data_source); |
350 return handle_parameter_assignment(symb_var->var_name, symbol->prog_data_source); |
343 } |
351 } |
344 |
352 |
345 /* any_symbolic_variable SENDTO data_sink */ |
353 /* any_symbolic_variable SENDTO data_sink */ |
346 // SYM_REF2(prog_cnxn_sendto_c, symbolic_variable, prog_data_source) |
354 // SYM_REF2(prog_cnxn_sendto_c, symbolic_variable, prog_data_source) |
353 */ |
361 */ |
354 symbolic_variable_c *symb_var = dynamic_cast<symbolic_variable_c *>(symbol->symbolic_variable); |
362 symbolic_variable_c *symb_var = dynamic_cast<symbolic_variable_c *>(symbol->symbolic_variable); |
355 if (NULL == symb_var) |
363 if (NULL == symb_var) |
356 ERROR; |
364 ERROR; |
357 |
365 |
|
366 current_assign_direction = assign_out; |
358 return handle_parameter_assignment(symb_var->var_name, symbol->data_sink); |
367 return handle_parameter_assignment(symb_var->var_name, symbol->data_sink); |
359 } |
368 } |
360 |
369 |
361 /* VAR_CONFIG instance_specific_init_list END_VAR */ |
370 /* VAR_CONFIG instance_specific_init_list END_VAR */ |
362 /* |
371 /* |
457 |
466 |
458 // TODO : We do not yet handle a instruction list passed as parameter !!! |
467 // TODO : We do not yet handle a instruction list passed as parameter !!! |
459 // since we do not yet support it, it is best to simply stop than to fail silently... |
468 // since we do not yet support it, it is best to simply stop than to fail silently... |
460 if (NULL != symbol->simple_instr_list) ERROR; |
469 if (NULL != symbol->simple_instr_list) ERROR; |
461 |
470 |
|
471 current_assign_direction = assign_in; |
462 return handle_parameter_assignment((symbol_c *)symbol->il_assign_operator->accept(*this), symbol->il_operand); |
472 return handle_parameter_assignment((symbol_c *)symbol->il_assign_operator->accept(*this), symbol->il_operand); |
463 } |
473 } |
464 |
474 |
465 /* il_assign_out_operator variable */ |
475 /* il_assign_out_operator variable */ |
466 // SYM_REF2(il_param_out_assignment_c, il_assign_out_operator, variable); |
476 // SYM_REF2(il_param_out_assignment_c, il_assign_out_operator, variable); |
467 void *function_call_param_iterator_c::visit(il_param_out_assignment_c *symbol) { |
477 void *function_call_param_iterator_c::visit(il_param_out_assignment_c *symbol) { |
468 TRACE("il_param_out_assignment_c"); |
478 TRACE("il_param_out_assignment_c"); |
|
479 current_assign_direction = assign_out; |
469 return handle_parameter_assignment((symbol_c *)symbol->il_assign_out_operator->accept(*this), symbol->variable); |
480 return handle_parameter_assignment((symbol_c *)symbol->il_assign_out_operator->accept(*this), symbol->variable); |
470 } |
481 } |
471 |
482 |
472 |
483 |
473 /*******************/ |
484 /*******************/ |
562 |
573 |
563 /* variable_name ASSIGN expression */ |
574 /* variable_name ASSIGN expression */ |
564 // SYM_REF2(input_variable_param_assignment_c, variable_name, expression) |
575 // SYM_REF2(input_variable_param_assignment_c, variable_name, expression) |
565 void *function_call_param_iterator_c::visit(input_variable_param_assignment_c *symbol) { |
576 void *function_call_param_iterator_c::visit(input_variable_param_assignment_c *symbol) { |
566 TRACE("input_variable_param_assignment_c"); |
577 TRACE("input_variable_param_assignment_c"); |
|
578 current_assign_direction = assign_in; |
567 return handle_parameter_assignment(symbol->variable_name, symbol->expression); |
579 return handle_parameter_assignment(symbol->variable_name, symbol->expression); |
568 } |
580 } |
569 |
581 |
570 /* [NOT] variable_name '=>' variable */ |
582 /* [NOT] variable_name '=>' variable */ |
571 // SYM_REF4(output_variable_param_assignment_c, not_param, variable_name, variable, unused) |
583 // SYM_REF4(output_variable_param_assignment_c, not_param, variable_name, variable, unused) |
572 void *function_call_param_iterator_c::visit(output_variable_param_assignment_c *symbol) { |
584 void *function_call_param_iterator_c::visit(output_variable_param_assignment_c *symbol) { |
573 TRACE("output_variable_param_assignment_c"); |
585 TRACE("output_variable_param_assignment_c"); |
574 // TODO : Handle not_param !!! |
586 // TODO : Handle not_param !!! |
575 if (NULL != symbol->not_param) ERROR; // we do not yet support it, so it is best to simply stop than to fail silently... |
587 if (NULL != symbol->not_param) ERROR; // we do not yet support it, so it is best to simply stop than to fail silently... |
576 |
588 |
|
589 current_assign_direction = assign_out; |
577 return handle_parameter_assignment(symbol->variable_name, symbol->variable); |
590 return handle_parameter_assignment(symbol->variable_name, symbol->variable); |
578 } |
591 } |
579 |
592 |
580 /* helper CLASS for output_variable_param_assignment */ |
593 /* helper CLASS for output_variable_param_assignment */ |
581 // SYM_REF0(not_paramassign_c) |
594 // SYM_REF0(not_paramassign_c) |