stage4/generate_c/generate_c_st.cc
changeset 375 7a11f9e9e703
parent 349 b826f13c260e
parent 373 7af3b6bed2dd
child 376 7dcbd8418771
equal deleted inserted replaced
349:b826f13c260e 375:7a11f9e9e703
    33  * a C source program equivalent to the IL and ST, or SFC
    33  * a C source program equivalent to the IL and ST, or SFC
    34  * code.
    34  * code.
    35  */
    35  */
    36 
    36 
    37 
    37 
       
    38 
       
    39 #include "../../util/strdup.hh"
       
    40 
    38 /***********************************************************************/
    41 /***********************************************************************/
    39 /***********************************************************************/
    42 /***********************************************************************/
    40 /***********************************************************************/
    43 /***********************************************************************/
    41 /***********************************************************************/
    44 /***********************************************************************/
    42 
    45 
   460   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
   463   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
   461   if (!search_expression_type->is_same_type(left_type, right_type))
   464   if (!search_expression_type->is_same_type(left_type, right_type))
   462       ERROR;
   465       ERROR;
   463   if (search_expression_type->is_time_type(left_type) ||
   466   if (search_expression_type->is_time_type(left_type) ||
   464       search_expression_type->is_string_type(left_type))
   467       search_expression_type->is_string_type(left_type))
   465     return print_compare_function("__eq_", left_type, symbol->l_exp, symbol->r_exp);
   468     return print_compare_function("EQ_", left_type, symbol->l_exp, symbol->r_exp);
   466   return print_binary_expression(symbol->l_exp, symbol->r_exp, " == ");
   469   return print_binary_expression(symbol->l_exp, symbol->r_exp, " == ");
   467 }
   470 }
   468 
   471 
   469 void *visit(notequ_expression_c *symbol) {
   472 void *visit(notequ_expression_c *symbol) {
   470   symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
   473   symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
   471   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
   474   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
   472   if (!search_expression_type->is_same_type(left_type, right_type))
   475   if (!search_expression_type->is_same_type(left_type, right_type))
   473       ERROR;
   476       ERROR;
   474   if (search_expression_type->is_time_type(left_type) ||
   477   if (search_expression_type->is_time_type(left_type) ||
   475       search_expression_type->is_string_type(left_type))
   478       search_expression_type->is_string_type(left_type))
   476     return print_compare_function("__ne_", left_type, symbol->l_exp, symbol->r_exp);
   479     return print_compare_function("NE_", left_type, symbol->l_exp, symbol->r_exp);
   477   return print_binary_expression(symbol->l_exp, symbol->r_exp, " != ");
   480   return print_binary_expression(symbol->l_exp, symbol->r_exp, " != ");
   478 }
   481 }
   479 
   482 
   480 void *visit(lt_expression_c *symbol) {
   483 void *visit(lt_expression_c *symbol) {
   481   symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
   484   symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
   482   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
   485   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
   483   if (!search_expression_type->is_same_type(left_type, right_type))
   486   if (!search_expression_type->is_same_type(left_type, right_type))
   484       ERROR;
   487       ERROR;
   485   if (search_expression_type->is_time_type(left_type) ||
   488   if (search_expression_type->is_time_type(left_type) ||
   486       search_expression_type->is_string_type(left_type))
   489       search_expression_type->is_string_type(left_type))
   487     return print_compare_function("__lt_", left_type, symbol->l_exp, symbol->r_exp);
   490     return print_compare_function("LT_", left_type, symbol->l_exp, symbol->r_exp);
   488   if (!search_base_type.type_is_enumerated(left_type))
   491   if (!search_base_type.type_is_enumerated(left_type))
   489     return print_binary_expression(symbol->l_exp, symbol->r_exp, " < ");
   492     return print_binary_expression(symbol->l_exp, symbol->r_exp, " < ");
   490   ERROR;
   493   ERROR;
   491   return NULL;
   494   return NULL;
   492 }
   495 }
   496   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
   499   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
   497   if (!search_expression_type->is_same_type(left_type, right_type))
   500   if (!search_expression_type->is_same_type(left_type, right_type))
   498       ERROR;
   501       ERROR;
   499   if (search_expression_type->is_time_type(left_type) ||
   502   if (search_expression_type->is_time_type(left_type) ||
   500       search_expression_type->is_string_type(left_type))
   503       search_expression_type->is_string_type(left_type))
   501     return print_compare_function("__gt_", left_type, symbol->l_exp, symbol->r_exp);
   504     return print_compare_function("GT_", left_type, symbol->l_exp, symbol->r_exp);
   502   if (!search_base_type.type_is_enumerated(left_type))
   505   if (!search_base_type.type_is_enumerated(left_type))
   503     return print_binary_expression(symbol->l_exp, symbol->r_exp, " > ");
   506     return print_binary_expression(symbol->l_exp, symbol->r_exp, " > ");
   504   ERROR;
   507   ERROR;
   505   return NULL;
   508   return NULL;
   506 }
   509 }
   510   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
   513   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
   511   if (!search_expression_type->is_same_type(left_type, right_type))
   514   if (!search_expression_type->is_same_type(left_type, right_type))
   512       ERROR;
   515       ERROR;
   513   if (search_expression_type->is_time_type(left_type) ||
   516   if (search_expression_type->is_time_type(left_type) ||
   514       search_expression_type->is_string_type(left_type))
   517       search_expression_type->is_string_type(left_type))
   515     return print_compare_function("__le_", left_type, symbol->l_exp, symbol->r_exp);
   518     return print_compare_function("LE_", left_type, symbol->l_exp, symbol->r_exp);
   516   if (!search_base_type.type_is_enumerated(left_type))
   519   if (!search_base_type.type_is_enumerated(left_type))
   517     return print_binary_expression(symbol->l_exp, symbol->r_exp, " <= ");
   520     return print_binary_expression(symbol->l_exp, symbol->r_exp, " <= ");
   518   ERROR;
   521   ERROR;
   519   return NULL;
   522   return NULL;
   520 }
   523 }
   524   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
   527   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
   525   if (!search_expression_type->is_same_type(left_type, right_type))
   528   if (!search_expression_type->is_same_type(left_type, right_type))
   526       ERROR;
   529       ERROR;
   527   if (search_expression_type->is_time_type(left_type) ||
   530   if (search_expression_type->is_time_type(left_type) ||
   528       search_expression_type->is_string_type(left_type))
   531       search_expression_type->is_string_type(left_type))
   529     return print_compare_function("__ge_", left_type, symbol->l_exp, symbol->r_exp);
   532     return print_compare_function("GE_", left_type, symbol->l_exp, symbol->r_exp);
   530   if (!search_base_type.type_is_enumerated(left_type))
   533   if (!search_base_type.type_is_enumerated(left_type))
   531     return print_binary_expression(symbol->l_exp, symbol->r_exp, " >= ");
   534     return print_binary_expression(symbol->l_exp, symbol->r_exp, " >= ");
   532   ERROR;
   535   ERROR;
   533   return NULL;
   536   return NULL;
   534 }
   537 }
   537   symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
   540   symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
   538 	symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
   541 	symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
   539 	if ((typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) ||
   542 	if ((typeid(*left_type) == typeid(time_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) ||
   540       (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) ||
   543       (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) ||
   541       (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)))
   544       (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)))
   542     return print_binary_function("__TIME_ADD", symbol->l_exp, symbol->r_exp);
   545     return print_binary_function("__time_add", symbol->l_exp, symbol->r_exp);
   543   if (!search_expression_type->is_same_type(left_type, right_type))
   546   if (!search_expression_type->is_same_type(left_type, right_type))
   544       ERROR;
   547       ERROR;
   545   if (search_expression_type->is_integer_type(left_type) || search_expression_type->is_real_type(left_type))
   548   if (search_expression_type->is_integer_type(left_type) || search_expression_type->is_real_type(left_type))
   546     return print_binary_expression(symbol->l_exp, symbol->r_exp, " + ");
   549     return print_binary_expression(symbol->l_exp, symbol->r_exp, " + ");
   547   ERROR;
   550   ERROR;
   555       (typeid(*left_type) == typeid(date_type_name_c) && typeid(*right_type) == typeid(date_type_name_c)) ||
   558       (typeid(*left_type) == typeid(date_type_name_c) && typeid(*right_type) == typeid(date_type_name_c)) ||
   556       (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) ||
   559       (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) ||
   557       (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(tod_type_name_c)) ||
   560       (typeid(*left_type) == typeid(tod_type_name_c) && typeid(*right_type) == typeid(tod_type_name_c)) ||
   558       (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) ||
   561       (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(time_type_name_c)) ||
   559       (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(dt_type_name_c)))
   562       (typeid(*left_type) == typeid(dt_type_name_c) && typeid(*right_type) == typeid(dt_type_name_c)))
   560     return print_binary_function("__TIME_SUB", symbol->l_exp, symbol->r_exp);
   563     return print_binary_function("__time_sub", symbol->l_exp, symbol->r_exp);
   561   if (!search_expression_type->is_same_type(left_type, right_type))
   564   if (!search_expression_type->is_same_type(left_type, right_type))
   562       ERROR;
   565       ERROR;
   563   if (search_expression_type->is_integer_type(left_type) || search_expression_type->is_real_type(left_type))
   566   if (search_expression_type->is_integer_type(left_type) || search_expression_type->is_real_type(left_type))
   564     return print_binary_expression(symbol->l_exp, symbol->r_exp, " - ");
   567     return print_binary_expression(symbol->l_exp, symbol->r_exp, " - ");
   565   ERROR;
   568   ERROR;
   569 void *visit(mul_expression_c *symbol) {
   572 void *visit(mul_expression_c *symbol) {
   570   symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
   573   symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
   571   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
   574   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
   572   if ((typeid(*left_type) == typeid(time_type_name_c) && search_expression_type->is_integer_type(right_type)) ||
   575   if ((typeid(*left_type) == typeid(time_type_name_c) && search_expression_type->is_integer_type(right_type)) ||
   573       (typeid(*left_type) == typeid(time_type_name_c) && search_expression_type->is_real_type(right_type)))
   576       (typeid(*left_type) == typeid(time_type_name_c) && search_expression_type->is_real_type(right_type)))
   574     return print_binary_function("__TIME_MUL", symbol->l_exp, symbol->r_exp);
   577     return print_binary_function("__time_mul", symbol->l_exp, symbol->r_exp);
   575   if (!search_expression_type->is_same_type(left_type, right_type))
   578   if (!search_expression_type->is_same_type(left_type, right_type))
   576       ERROR;
   579       ERROR;
   577   if (search_expression_type->is_integer_type(left_type) || search_expression_type->is_real_type(left_type))
   580   if (search_expression_type->is_integer_type(left_type) || search_expression_type->is_real_type(left_type))
   578     return print_binary_expression(symbol->l_exp, symbol->r_exp, " * ");
   581     return print_binary_expression(symbol->l_exp, symbol->r_exp, " * ");
   579   ERROR;
   582   ERROR;
   583 void *visit(div_expression_c *symbol) {
   586 void *visit(div_expression_c *symbol) {
   584   symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
   587   symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
   585   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
   588   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
   586   if ((typeid(*left_type) == typeid(time_type_name_c) && search_expression_type->is_integer_type(right_type)) ||
   589   if ((typeid(*left_type) == typeid(time_type_name_c) && search_expression_type->is_integer_type(right_type)) ||
   587       (typeid(*left_type) == typeid(time_type_name_c) && search_expression_type->is_real_type(right_type)))
   590       (typeid(*left_type) == typeid(time_type_name_c) && search_expression_type->is_real_type(right_type)))
   588     return print_binary_function("__TIME_DIV", symbol->l_exp, symbol->r_exp);
   591     return print_binary_function("__time_div", symbol->l_exp, symbol->r_exp);
   589   if (!search_expression_type->is_same_type(left_type, right_type))
   592   if (!search_expression_type->is_same_type(left_type, right_type))
   590       ERROR;
   593       ERROR;
   591   if (search_expression_type->is_integer_type(left_type) || search_expression_type->is_real_type(left_type))
   594   if (search_expression_type->is_integer_type(left_type) || search_expression_type->is_real_type(left_type))
   592     return print_binary_expression(symbol->l_exp, symbol->r_exp, " / ");
   595     return print_binary_expression(symbol->l_exp, symbol->r_exp, " / ");
   593   ERROR;
   596   ERROR;
   613 
   616 
   614 void *visit(power_expression_c *symbol) {
   617 void *visit(power_expression_c *symbol) {
   615   symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
   618   symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
   616   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
   619   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
   617   if (search_expression_type->is_real_type(left_type) && search_expression_type->is_num_type(right_type)) {
   620   if (search_expression_type->is_real_type(left_type) && search_expression_type->is_num_type(right_type)) {
   618 	s4o.print("__expt_LREAL((BOOL)__BOOL_LITERAL(TRUE),\n");
   621 	s4o.print("EXPT__LREAL__LREAL__LREAL((BOOL)__BOOL_LITERAL(TRUE),\n");
   619 	s4o.indent_right();
   622 	s4o.indent_right();
   620 	s4o.print(s4o.indent_spaces + "NULL,\n");
   623 	s4o.print(s4o.indent_spaces + "NULL,\n");
   621 	s4o.print(s4o.indent_spaces + "(LREAL)(");
   624 	s4o.print(s4o.indent_spaces + "(LREAL)(");
   622 	symbol->l_exp->accept(*this);
   625 	symbol->l_exp->accept(*this);
   623 	s4o.print("),\n");
   626 	s4o.print("),\n");
   625 	symbol->r_exp->accept(*this);
   628 	symbol->r_exp->accept(*this);
   626 	s4o.print("))");
   629 	s4o.print("))");
   627     return NULL;
   630     return NULL;
   628   }
   631   }
   629   ERROR;
   632   ERROR;
       
   633   return NULL;
   630 }
   634 }
   631 
   635 
   632 void *visit(neg_expression_c *symbol) {
   636 void *visit(neg_expression_c *symbol) {
   633   return print_unary_expression(symbol->exp, " -");
   637   return print_unary_expression(symbol->exp, " -");
   634 }
   638 }
   640   ERROR;
   644   ERROR;
   641   return NULL;
   645   return NULL;
   642 }
   646 }
   643 
   647 
   644 void *visit(function_invocation_c *symbol) {
   648 void *visit(function_invocation_c *symbol) {
   645   symbol_c* function_type_prefix = NULL;
       
   646   symbol_c* function_name = NULL;
   649   symbol_c* function_name = NULL;
   647   symbol_c* function_type_suffix = NULL;
       
   648   DECLARE_PARAM_LIST()
   650   DECLARE_PARAM_LIST()
   649 
   651 
   650   symbol_c *parameter_assignment_list = NULL;
   652   symbol_c *parameter_assignment_list = NULL;
   651   if (NULL != symbol->   formal_param_list) parameter_assignment_list = symbol->   formal_param_list;
   653   if (NULL != symbol->   formal_param_list) parameter_assignment_list = symbol->   formal_param_list;
   652   if (NULL != symbol->nonformal_param_list) parameter_assignment_list = symbol->nonformal_param_list;
   654   if (NULL != symbol->nonformal_param_list) parameter_assignment_list = symbol->nonformal_param_list;
   653   if (NULL == parameter_assignment_list) ERROR;
   655   if (NULL == parameter_assignment_list) ERROR;
   654 
   656 
   655   function_call_param_iterator_c function_call_param_iterator(symbol);
   657   function_call_param_iterator_c function_call_param_iterator(symbol);
   656 
   658 
   657   function_declaration_c *f_decl = function_symtable.find_value(symbol->function_name);
   659   function_declaration_c *f_decl = (function_declaration_c *)symbol->called_function_declaration;
   658   if (f_decl == function_symtable.end_value()) {
   660   if (f_decl == NULL) ERROR;
   659     /* The function called is not in the symtable, so we test if it is a
   661   
   660      * standard function defined in standard */
   662   function_name = symbol->function_name;
   661 
   663   
   662     function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name);
   664   /* loop through each function parameter, find the value we should pass
   663     if (current_function_type == function_none) ERROR;
   665    * to it, and then output the c equivalent...
   664 
   666    */
   665     symbol_c *function_return_type = search_expression_type->get_type(symbol);
   667   function_param_iterator_c fp_iterator(f_decl);
   666 
   668   identifier_c *param_name;
   667     int nb_param = ((list_c *)parameter_assignment_list)->n;
   669     /* flag to cirreclty handle calls to extensible standard functions (i.e. functions with variable number of input parameters) */
   668 
   670   bool found_first_extensible_parameter = false;  
   669     symbol_c *en_param_name = (symbol_c *)(new identifier_c("EN"));
   671   for(int i = 1; (param_name = fp_iterator.next()) != NULL; i++) {
   670     /* Get the value from EN param */
   672     if (fp_iterator.is_extensible_param() && (!found_first_extensible_parameter)) {
   671     symbol_c *EN_param_value = function_call_param_iterator.search_f(en_param_name);
   673       /* We are calling an extensible function. Before passing the extensible
   672     if (EN_param_value == NULL)
   674        * parameters, we must add a dummy paramater value to tell the called
   673       EN_param_value = (symbol_c*)(new boolean_literal_c((symbol_c*)(new bool_type_name_c()), new boolean_true_c()));
   675        * function how many extensible parameters we will be passing.
   674     else
   676        *
   675       nb_param --;
   677        * Note that stage 3 has already determined the number of extensible
   676     ADD_PARAM_LIST(en_param_name, EN_param_value, (symbol_c*)(new bool_type_name_c()), function_param_iterator_c::direction_in)
   678        * paramters, and stored that info in the abstract syntax tree. We simply
   677 
   679        * re-use that value.
   678     symbol_c *eno_param_name = (symbol_c *)(new identifier_c("ENO"));
   680        */
   679     /* Get the value from ENO param */
   681       /* NOTE: we are not freeing the malloc'd memory. This is not really a bug.
   680     symbol_c *ENO_param_value = function_call_param_iterator.search_f(eno_param_name);
   682        *       Since we are writing a compiler, which runs to termination quickly,
   681     if (ENO_param_value != NULL)
   683        *       we can consider this as just memory required for the compilation process
   682       nb_param --;
   684        *       that will be free'd when the program terminates.
   683     ADD_PARAM_LIST(eno_param_name, ENO_param_value, (symbol_c*)(new bool_type_name_c()), function_param_iterator_c::direction_out)
   685        */
   684 
   686       char *tmp = (char *)malloc(32); /* enough space for a call with 10^31 (larger than 2^64) input parameters! */
   685     #include "st_code_gen.c"
   687       if (tmp == NULL) ERROR;
   686 
   688       int res = snprintf(tmp, 32, "%d", symbol->extensible_param_count);
   687   }
   689       if ((res >= 32) || (res < 0)) ERROR;
   688   else {
   690       identifier_c *param_value = new identifier_c(tmp);
   689 	function_name = symbol->function_name;
   691       uint_type_name_c *param_type  = new uint_type_name_c();
   690 
   692       identifier_c *param_name = new identifier_c("");
   691 	/* loop through each function parameter, find the value we should pass
   693       ADD_PARAM_LIST(param_name, param_value, param_type, function_param_iterator_c::direction_in)
   692      * to it, and then output the c equivalent...
   694       found_first_extensible_parameter = true;
       
   695     }
       
   696 
       
   697     if (fp_iterator.is_extensible_param()) {      
       
   698       /* since we are handling an extensible parameter, we must add the index to the
       
   699        * parameter name so we can go looking for the value passed to the correct
       
   700        * extended parameter (e.g. IN1, IN2, IN3, IN4, ...)
       
   701        */
       
   702       char *tmp = (char *)malloc(32); /* enough space for a call with 10^31 (larger than 2^64) input parameters! */
       
   703       int res = snprintf(tmp, 32, "%d", fp_iterator.extensible_param_index());
       
   704       if ((res >= 32) || (res < 0)) ERROR;
       
   705       param_name = new identifier_c(strdup2(param_name->value, tmp));
       
   706       if (param_name->value == NULL) ERROR;
       
   707     }
       
   708     
       
   709     symbol_c *param_type = fp_iterator.param_type();
       
   710     if (param_type == NULL) ERROR;
       
   711 
       
   712     function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction();
       
   713     
       
   714     symbol_c *param_value = NULL;
       
   715     
       
   716     /* Get the value from a foo(<param_name> = <param_value>) style call */
       
   717     if (param_value == NULL)
       
   718       param_value = function_call_param_iterator.search_f(param_name);
       
   719 
       
   720     /* Get the value from a foo(<param_value>) style call */
       
   721     if ((param_value == NULL) && !fp_iterator.is_en_eno_param_implicit()) {
       
   722       param_value = function_call_param_iterator.next_nf();
       
   723     }
       
   724 
       
   725     /* if no more parameter values in function call, and the current parameter
       
   726      * of the function declaration is an extensible parameter, we
       
   727      * have reached the end, and should simply jump out of the for loop.
   693      */
   728      */
   694     function_param_iterator_c fp_iterator(f_decl);
   729     if ((param_value == NULL) && (fp_iterator.is_extensible_param())) {
   695     identifier_c *param_name;
   730       break;
   696     for(int i = 1; (param_name = fp_iterator.next()) != NULL; i++) {
   731     }
   697       
   732     
   698       symbol_c *param_type = fp_iterator.param_type();
   733     if ((param_value == NULL) && (param_direction == function_param_iterator_c::direction_in)) {
   699       if (param_type == NULL) ERROR;
   734       /* No value given for parameter, so we must use the default... */
   700 
   735       /* First check whether default value specified in function declaration...*/
   701       function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction();
   736       param_value = fp_iterator.default_value();
   702       
   737     }
   703       /* Get the value from a foo(<param_name> = <param_value>) style call */
   738     
   704       symbol_c *param_value = function_call_param_iterator.search_f(param_name);
   739     ADD_PARAM_LIST(param_name, param_value, param_type, param_direction)
   705   
   740   } /* for(...) */
   706       /* Get the value from a foo(<param_value>) style call */
   741   // symbol->parameter_assignment->accept(*this);
   707       if (param_value == NULL) {
       
   708         param_value = function_call_param_iterator.next_nf();
       
   709         if (param_value != NULL && fp_iterator.is_en_eno_param_implicit()) ERROR;
       
   710       }
       
   711       
       
   712       if (param_value == NULL && param_direction == function_param_iterator_c::direction_in) {
       
   713         /* No value given for parameter, so we must use the default... */
       
   714         /* First check whether default value specified in function declaration...*/
       
   715         param_value = fp_iterator.default_value();
       
   716       }
       
   717       
       
   718       ADD_PARAM_LIST(param_name, param_value, param_type, param_direction)
       
   719     } /* for(...) */
       
   720     // symbol->parameter_assignment->accept(*this);
       
   721   }
       
   722   
   742   
   723   if (function_call_param_iterator.next_nf() != NULL) ERROR;
   743   if (function_call_param_iterator.next_nf() != NULL) ERROR;
   724 
   744 
   725   bool has_output_params = false;
   745   bool has_output_params = false;
   726 
   746 
   727   if (!this->is_variable_prefix_null()) {
   747   if (!this->is_variable_prefix_null()) {
   728     PARAM_LIST_ITERATOR() {
   748     PARAM_LIST_ITERATOR() {
   729 	  if ((PARAM_DIRECTION == function_param_iterator_c::direction_out ||
   749       if ((PARAM_DIRECTION == function_param_iterator_c::direction_out ||
   730 		   PARAM_DIRECTION == function_param_iterator_c::direction_inout) &&
   750            PARAM_DIRECTION == function_param_iterator_c::direction_inout) &&
   731 		  PARAM_VALUE != NULL) {
   751            PARAM_VALUE != NULL) {
   732 	    if (!has_output_params) {
   752         has_output_params = true;
   733 		  has_output_params = true;
   753       }
   734 		}
   754     }
   735 	  }
   755   }
   736     }
   756 
   737   }
   757   /* Check whether we are calling an overloaded function! */
   738 
   758   /* (fdecl_mutiplicity==2)  => calling overloaded function */
   739   if (function_type_prefix != NULL) {
   759   int fdecl_mutiplicity =  function_symtable.multiplicity(symbol->function_name);
   740     s4o.print("(");
   760   if (fdecl_mutiplicity == 0) ERROR;
   741     search_expression_type->default_literal_type(function_type_prefix)->accept(*this);
   761 
   742     s4o.print(")");
       
   743   }
       
   744   if (function_type_suffix != NULL) {
       
   745 	function_type_suffix = search_expression_type->default_literal_type(function_type_suffix);
       
   746   }
       
   747   if (has_output_params) {
   762   if (has_output_params) {
   748 	fcall_number++;
   763     fcall_number++;
   749 	s4o.print("__");
   764     s4o.print("__");
   750     fbname->accept(*this);
   765     fbname->accept(*this);
   751     s4o.print("_");
   766     s4o.print("_");
   752     function_name->accept(*this);
   767     function_name->accept(*this);
   753     if (function_type_suffix != NULL)
   768     if (fdecl_mutiplicity == 2) {
   754       function_type_suffix->accept(*this);
   769       /* function being called is overloaded! */
       
   770       s4o.print("__");
       
   771       print_function_parameter_data_types_c overloaded_func_suf(&s4o);
       
   772       f_decl->accept(overloaded_func_suf);
       
   773     }
   755     s4o.print_integer(fcall_number);
   774     s4o.print_integer(fcall_number);
   756   }
   775   }
   757   else {
   776   else {
   758     function_name->accept(*this);
   777     function_name->accept(*this);
   759     if (function_type_suffix != NULL)
   778     if (fdecl_mutiplicity == 2) {
   760       function_type_suffix->accept(*this);
   779       /* function being called is overloaded! */
       
   780       s4o.print("__");
       
   781       print_function_parameter_data_types_c overloaded_func_suf(&s4o);
       
   782       f_decl->accept(overloaded_func_suf);
       
   783     }
   761   }
   784   }
   762   s4o.print("(");
   785   s4o.print("(");
   763   s4o.indent_right();
   786   s4o.indent_right();
   764   
   787   
   765   int nb_param = 0;
   788   int nb_param = 0;
   883     
   906     
   884     /* Get the value from a foo(<param_name> = <param_value>) style call */
   907     /* Get the value from a foo(<param_name> = <param_value>) style call */
   885     symbol_c *param_value = function_call_param_iterator.search_f(param_name);
   908     symbol_c *param_value = function_call_param_iterator.search_f(param_name);
   886 
   909 
   887     /* Get the value from a foo(<param_value>) style call */
   910     /* Get the value from a foo(<param_value>) style call */
   888     if (param_value == NULL)
   911     /* When using the informal invocation style, user can not pass values to EN or ENO parameters if these
       
   912      * were implicitly defined!
       
   913      */
       
   914     if ((param_value == NULL) && !fp_iterator.is_en_eno_param_implicit())
   889       param_value = function_call_param_iterator.next_nf();
   915       param_value = function_call_param_iterator.next_nf();
   890 
   916 
   891     symbol_c *param_type = fp_iterator.param_type();
   917     symbol_c *param_type = fp_iterator.param_type();
   892     if (param_type == NULL) ERROR;
   918     if (param_type == NULL) ERROR;
   893     
   919     
   927 
   953 
   928     /* Get the value from a foo(<param_name> = <param_value>) style call */
   954     /* Get the value from a foo(<param_name> = <param_value>) style call */
   929     symbol_c *param_value = function_call_param_iterator.search_f(param_name);
   955     symbol_c *param_value = function_call_param_iterator.search_f(param_name);
   930 
   956 
   931     /* Get the value from a foo(<param_value>) style call */
   957     /* Get the value from a foo(<param_value>) style call */
   932     if (param_value == NULL)
   958     /* When using the informal invocation style, user can not pass values to EN or ENO parameters if these
       
   959      * were implicitly defined!
       
   960      */
       
   961     if ((param_value == NULL) && !fp_iterator.is_en_eno_param_implicit())
   933       param_value = function_call_param_iterator.next_nf();
   962       param_value = function_call_param_iterator.next_nf();
   934 
   963 
   935     /* now output the value assignment */
   964     /* now output the value assignment */
   936     if (param_value != NULL)
   965     if (param_value != NULL)
   937       if ((param_direction == function_param_iterator_c::direction_out) ||
   966       if ((param_direction == function_param_iterator_c::direction_out) ||