stage4/generate_c/generate_c_st.cc
changeset 233 3d23a68183d3
parent 231 b8527b0abe75
child 235 ed66dc50f31a
equal deleted inserted replaced
232:29ab33687333 233:3d23a68183d3
   595   symbol_c *parameter_assignment_list = NULL;
   595   symbol_c *parameter_assignment_list = NULL;
   596   if (NULL != symbol->   formal_param_list) parameter_assignment_list = symbol->   formal_param_list;
   596   if (NULL != symbol->   formal_param_list) parameter_assignment_list = symbol->   formal_param_list;
   597   if (NULL != symbol->nonformal_param_list) parameter_assignment_list = symbol->nonformal_param_list;
   597   if (NULL != symbol->nonformal_param_list) parameter_assignment_list = symbol->nonformal_param_list;
   598   if (NULL == parameter_assignment_list) ERROR;
   598   if (NULL == parameter_assignment_list) ERROR;
   599 
   599 
       
   600   function_call_param_iterator_c function_call_param_iterator(symbol);
       
   601 
   600   function_declaration_c *f_decl = function_symtable.find_value(symbol->function_name);
   602   function_declaration_c *f_decl = function_symtable.find_value(symbol->function_name);
   601   if (f_decl == function_symtable.end_value()) {
   603   if (f_decl == function_symtable.end_value()) {
   602     /* The function called is not in the symtable, so we test if it is a
   604     /* The function called is not in the symtable, so we test if it is a
   603      * standard function defined in standard */
   605      * standard function defined in standard */
   604 
   606 
   605     function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name);
   607     function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name);
   606     if (current_function_type == function_none) ERROR;
   608     if (current_function_type == function_none) ERROR;
   607 
   609 
   608     symbol_c *function_return_type = search_expression_type->get_type(symbol);
   610     symbol_c *function_return_type = search_expression_type->get_type(symbol);
   609 
       
   610     function_call_param_iterator_c function_call_param_iterator(symbol);
       
   611 
   611 
   612     int nb_param = ((list_c *)parameter_assignment_list)->n;
   612     int nb_param = ((list_c *)parameter_assignment_list)->n;
   613 
   613 
   614     identifier_c en_param_name("EN");
   614     identifier_c en_param_name("EN");
   615     /* Get the value from EN param */
   615     /* Get the value from EN param */
   636 	/* loop through each function parameter, find the value we should pass
   636 	/* loop through each function parameter, find the value we should pass
   637      * to it, and then output the c equivalent...
   637      * to it, and then output the c equivalent...
   638      */
   638      */
   639     function_param_iterator_c fp_iterator(f_decl);
   639     function_param_iterator_c fp_iterator(f_decl);
   640     identifier_c *param_name;
   640     identifier_c *param_name;
   641     function_call_param_iterator_c function_call_param_iterator(symbol);
       
   642     for(int i = 1; (param_name = fp_iterator.next()) != NULL; i++) {
   641     for(int i = 1; (param_name = fp_iterator.next()) != NULL; i++) {
   643       
   642       
       
   643       symbol_c *param_type = fp_iterator.param_type();
       
   644       if (param_type == NULL) ERROR;
       
   645 
   644       function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction();
   646       function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction();
   645       
   647       
   646       /* Get the value from a foo(<param_name> = <param_value>) style call */
   648       /* Get the value from a foo(<param_name> = <param_value>) style call */
   647       symbol_c *param_value = function_call_param_iterator.search_f(param_name);
   649       symbol_c *param_value = function_call_param_iterator.search_f(param_name);
   648   
   650   
   649       /* Get the value from a foo(<param_value>) style call */
   651       /* Get the value from a foo(<param_value>) style call */
   650       if (param_value == NULL)
   652       if (param_value == NULL) {
   651         param_value = function_call_param_iterator.next_nf();
   653         param_value = function_call_param_iterator.next_nf();
       
   654         if (param_value != NULL && fp_iterator.is_en_eno_param_implicit()) ERROR;
       
   655       }
   652       
   656       
   653       if (param_value == NULL && param_direction == function_param_iterator_c::direction_in) {
   657       if (param_value == NULL && param_direction == function_param_iterator_c::direction_in) {
   654         /* No value given for parameter, so we must use the default... */
   658         /* No value given for parameter, so we must use the default... */
   655         /* First check whether default value specified in function declaration...*/
   659         /* First check whether default value specified in function declaration...*/
   656         param_value = fp_iterator.default_value();
   660         param_value = fp_iterator.default_value();
   657       }
   661       }
   658       
   662       
   659       symbol_c *param_type = fp_iterator.param_type();
       
   660       if (param_type == NULL) ERROR;
       
   661       
       
   662       ADD_PARAM_LIST(param_name, param_value, param_type, param_direction)
   663       ADD_PARAM_LIST(param_name, param_value, param_type, param_direction)
   663     } /* for(...) */
   664     } /* for(...) */
   664     // symbol->parameter_assignment->accept(*this);
   665     // symbol->parameter_assignment->accept(*this);
   665   }
   666   }
   666   
   667   
       
   668   if (function_call_param_iterator.next_nf() != NULL) ERROR;
       
   669 
   667   bool has_output_params = false;
   670   bool has_output_params = false;
   668 
   671 
   669   if (!this->is_variable_prefix_null()) {
   672   if (!this->is_variable_prefix_null()) {
   670     PARAM_LIST_ITERATOR() {
   673     PARAM_LIST_ITERATOR() {
   671 	  if ((PARAM_DIRECTION == function_param_iterator_c::direction_out ||
   674 	  if ((PARAM_DIRECTION == function_param_iterator_c::direction_out ||