absyntax_utils/function_call_param_iterator.cc
changeset 449 3c6225521059
parent 350 2c3c4dc34979
child 596 4efb11e44065
equal deleted inserted replaced
448:1bd18fc06911 449:3c6225521059
   182  * You can determine the value being passed by calling 
   182  * You can determine the value being passed by calling 
   183  * function_call_param_iterator_c::search_f()
   183  * function_call_param_iterator_c::search_f()
   184  */
   184  */
   185 symbol_c *function_call_param_iterator_c::next_f(void) {
   185 symbol_c *function_call_param_iterator_c::next_f(void) {
   186   current_value = NULL;
   186   current_value = NULL;
       
   187   current_assign_direction = assign_none;
   187   param_count = 0;
   188   param_count = 0;
   188   iterate_f_next_param++;
   189   iterate_f_next_param++;
   189   current_operation = function_call_param_iterator_c::iterate_f_op;
   190   current_operation = function_call_param_iterator_c::iterate_f_op;
   190   void *res = f_call->accept(*this);
   191   void *res = f_call->accept(*this);
   191   return (symbol_c *)res;
   192   return (symbol_c *)res;
   199  *
   200  *
   200  * Returns whatever is being passed to the parameter!
   201  * Returns whatever is being passed to the parameter!
   201  */
   202  */
   202 symbol_c *function_call_param_iterator_c::next_nf(void) {
   203 symbol_c *function_call_param_iterator_c::next_nf(void) {
   203   current_value = NULL;
   204   current_value = NULL;
       
   205   current_assign_direction = assign_none;
   204   param_count = 0;
   206   param_count = 0;
   205   iterate_nf_next_param++;
   207   iterate_nf_next_param++;
   206   current_operation = function_call_param_iterator_c::iterate_nf_op;
   208   current_operation = function_call_param_iterator_c::iterate_nf_op;
   207   void *res = f_call->accept(*this);
   209   void *res = f_call->accept(*this);
   208   current_value = (symbol_c *)res;
   210   current_value = (symbol_c *)res;
   210 }
   212 }
   211 
   213 
   212 /* Search for the value passed to the parameter named <param_name>...  */
   214 /* 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) {
   215 symbol_c *function_call_param_iterator_c::search_f(symbol_c *param_name) {
   214   current_value = NULL;
   216   current_value = NULL;
       
   217   current_assign_direction = assign_none;
   215   if (NULL == param_name) ERROR;
   218   if (NULL == param_name) ERROR;
   216   search_param_name = dynamic_cast<identifier_c *>(param_name);
   219   search_param_name = dynamic_cast<identifier_c *>(param_name);
   217   if (NULL == search_param_name) ERROR;
   220   if (NULL == search_param_name) ERROR;
   218   current_operation = function_call_param_iterator_c::search_f_op;
   221   current_operation = function_call_param_iterator_c::search_f_op;
   219   void *res = f_call->accept(*this);
   222   void *res = f_call->accept(*this);
   231 /* Returns the value being passed to the current parameter. */
   234 /* Returns the value being passed to the current parameter. */
   232 symbol_c *function_call_param_iterator_c::get_current_value(void) {
   235 symbol_c *function_call_param_iterator_c::get_current_value(void) {
   233   return current_value;
   236   return current_value;
   234 }
   237 }
   235 
   238 
       
   239 /* Returns the value being passed to the current parameter. */
       
   240 function_call_param_iterator_c::assign_direction_t function_call_param_iterator_c::get_assign_direction(void) {
       
   241   return current_assign_direction;
       
   242 }
       
   243 
       
   244 
   236 /********************************/
   245 /********************************/
   237 /* B 1.7 Configuration elements */
   246 /* B 1.7 Configuration elements */
   238 /********************************/
   247 /********************************/
   239 
   248 
   240 /*
   249 /*
   337    */
   346    */
   338   symbolic_variable_c *symb_var = dynamic_cast<symbolic_variable_c *>(symbol->symbolic_variable);
   347   symbolic_variable_c *symb_var = dynamic_cast<symbolic_variable_c *>(symbol->symbolic_variable);
   339   if (NULL == symb_var)
   348   if (NULL == symb_var)
   340     ERROR;
   349     ERROR;
   341 
   350 
       
   351   current_assign_direction = assign_in;
   342   return handle_parameter_assignment(symb_var->var_name, symbol->prog_data_source);
   352   return handle_parameter_assignment(symb_var->var_name, symbol->prog_data_source);
   343 }
   353 }
   344 
   354 
   345 /* any_symbolic_variable SENDTO data_sink */
   355 /* any_symbolic_variable SENDTO data_sink */
   346 // SYM_REF2(prog_cnxn_sendto_c, symbolic_variable, prog_data_source)
   356 // SYM_REF2(prog_cnxn_sendto_c, symbolic_variable, prog_data_source)
   353    */
   363    */
   354   symbolic_variable_c *symb_var = dynamic_cast<symbolic_variable_c *>(symbol->symbolic_variable);
   364   symbolic_variable_c *symb_var = dynamic_cast<symbolic_variable_c *>(symbol->symbolic_variable);
   355   if (NULL == symb_var)
   365   if (NULL == symb_var)
   356     ERROR;
   366     ERROR;
   357 
   367 
       
   368   current_assign_direction = assign_out;
   358   return handle_parameter_assignment(symb_var->var_name, symbol->data_sink);
   369   return handle_parameter_assignment(symb_var->var_name, symbol->data_sink);
   359 }
   370 }
   360 
   371 
   361 /* VAR_CONFIG instance_specific_init_list END_VAR */
   372 /* VAR_CONFIG instance_specific_init_list END_VAR */
   362 /*
   373 /*
   457 
   468 
   458   // TODO : We do not yet handle a instruction list passed as parameter !!!
   469   // 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...
   470   // 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;
   471   if (NULL != symbol->simple_instr_list) ERROR;
   461 
   472 
       
   473   current_assign_direction = assign_in;
   462   return handle_parameter_assignment((symbol_c *)symbol->il_assign_operator->accept(*this), symbol->il_operand);
   474   return handle_parameter_assignment((symbol_c *)symbol->il_assign_operator->accept(*this), symbol->il_operand);
   463 }
   475 }
   464 
   476 
   465 /*  il_assign_out_operator variable */
   477 /*  il_assign_out_operator variable */
   466 // SYM_REF2(il_param_out_assignment_c, il_assign_out_operator, variable);
   478 // 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) {
   479 void *function_call_param_iterator_c::visit(il_param_out_assignment_c *symbol) {
   468   TRACE("il_param_out_assignment_c");
   480   TRACE("il_param_out_assignment_c");
       
   481   current_assign_direction = assign_out;
   469   return handle_parameter_assignment((symbol_c *)symbol->il_assign_out_operator->accept(*this), symbol->variable);
   482   return handle_parameter_assignment((symbol_c *)symbol->il_assign_out_operator->accept(*this), symbol->variable);
   470 }
   483 }
   471 
   484 
   472 
   485 
   473 /*******************/
   486 /*******************/
   562 
   575 
   563 /*  variable_name ASSIGN expression */
   576 /*  variable_name ASSIGN expression */
   564 // SYM_REF2(input_variable_param_assignment_c, variable_name, expression)
   577 // SYM_REF2(input_variable_param_assignment_c, variable_name, expression)
   565 void *function_call_param_iterator_c::visit(input_variable_param_assignment_c *symbol) {
   578 void *function_call_param_iterator_c::visit(input_variable_param_assignment_c *symbol) {
   566   TRACE("input_variable_param_assignment_c");
   579   TRACE("input_variable_param_assignment_c");
       
   580   current_assign_direction = assign_in;
   567   return handle_parameter_assignment(symbol->variable_name, symbol->expression);
   581   return handle_parameter_assignment(symbol->variable_name, symbol->expression);
   568 }
   582 }
   569 
   583 
   570 /* [NOT] variable_name '=>' variable */
   584 /* [NOT] variable_name '=>' variable */
   571 // SYM_REF4(output_variable_param_assignment_c, not_param, variable_name, variable, unused)
   585 // 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) {
   586 void *function_call_param_iterator_c::visit(output_variable_param_assignment_c *symbol) {
   573   TRACE("output_variable_param_assignment_c");
   587   TRACE("output_variable_param_assignment_c");
   574   // TODO : Handle not_param !!!
   588   // 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...
   589   if (NULL != symbol->not_param) ERROR;  // we do not yet support it, so it is best to simply stop than to fail silently...
   576 
   590 
       
   591   current_assign_direction = assign_out;
   577   return handle_parameter_assignment(symbol->variable_name, symbol->variable);
   592   return handle_parameter_assignment(symbol->variable_name, symbol->variable);
   578 }
   593 }
   579 
   594 
   580 /* helper CLASS for output_variable_param_assignment */
   595 /* helper CLASS for output_variable_param_assignment */
   581 // SYM_REF0(not_paramassign_c)
   596 // SYM_REF0(not_paramassign_c)