generate_IEC_std.py
changeset 406 af07b091bbee
parent 404 d5a5eaea7844
child 410 e1d4e9a93186
equal deleted inserted replaced
405:2c598d24205f 406:af07b091bbee
   148             else:
   148             else:
   149                 res += """
   149                 res += """
   150 {
   150 {
   151     identifier_c param_name("%(input_name)s");
   151     identifier_c param_name("%(input_name)s");
   152     /* Get the value from a foo(<param_name> = <param_value>) style call */
   152     /* Get the value from a foo(<param_name> = <param_value>) style call */
   153     symbol_c *%(input_name)s_param_value = function_call_param_iterator.search(&param_name);
   153     symbol_c *%(input_name)s_param_value = function_call_param_iterator.search_f(&param_name);
   154     symbol_c *%(input_name)s_type_symbol = NULL;
   154     symbol_c *%(input_name)s_type_symbol = NULL;
   155     
   155     
   156     /* Get the value from a foo(<param_value>) style call */
   156     /* Get the value from a foo(<param_value>) style call */
   157     if (%(input_name)s_param_value == NULL)
   157     if (%(input_name)s_param_value == NULL)
   158       %(input_name)s_param_value = function_call_param_iterator.next();
   158       %(input_name)s_param_value = function_call_param_iterator.next_nf();
   159     if (%(input_name)s_param_value != NULL) {
   159     if (%(input_name)s_param_value != NULL) {
   160       %(input_name)s_type_symbol = search_expression_type->get_type(%(input_name)s_param_value);
   160       %(input_name)s_type_symbol = search_expression_type->get_type(%(input_name)s_param_value);
   161       last_type_symbol = last_type_symbol && %(input_name)s_type_symbol && search_expression_type->is_same_type(%(input_name)s_type_symbol, last_type_symbol) ? search_expression_type->common_type(%(input_name)s_type_symbol, last_type_symbol) : %(input_name)s_type_symbol ;
   161       last_type_symbol = last_type_symbol && %(input_name)s_type_symbol && search_expression_type->is_same_type(%(input_name)s_type_symbol, last_type_symbol) ? search_expression_type->common_type(%(input_name)s_type_symbol, last_type_symbol) : %(input_name)s_type_symbol ;
   162     }
   162     }
   163 """%{"input_name":Paramname}
   163 """%{"input_name":Paramname}
   211     char my_name[10];
   211     char my_name[10];
   212     sprintf(my_name, "IN%%d", base_num++);
   212     sprintf(my_name, "IN%%d", base_num++);
   213     identifier_c param_name(my_name);
   213     identifier_c param_name(my_name);
   214     
   214     
   215     /* Get the value from a foo(<param_name> = <param_value>) style call */
   215     /* Get the value from a foo(<param_name> = <param_value>) style call */
   216     param_value = function_call_param_iterator.search(&param_name);
   216     param_value = function_call_param_iterator.search_f(&param_name);
   217     
   217     
   218     /* Get the value from a foo(<param_value>) style call */
   218     /* Get the value from a foo(<param_value>) style call */
   219     if (param_value == NULL)
   219     if (param_value == NULL)
   220       param_value = function_call_param_iterator.next();
   220       param_value = function_call_param_iterator.next_nf();
   221     if (param_value != NULL){
   221     if (param_value != NULL){
   222         symbol_c *current_type_symbol = search_expression_type->get_type(param_value);
   222         symbol_c *current_type_symbol = search_expression_type->get_type(param_value);
   223         last_type_symbol = last_type_symbol && search_expression_type->is_same_type(current_type_symbol, last_type_symbol) ? search_expression_type->common_type(current_type_symbol, last_type_symbol) : current_type_symbol ;
   223         last_type_symbol = last_type_symbol && search_expression_type->is_same_type(current_type_symbol, last_type_symbol) ? search_expression_type->common_type(current_type_symbol, last_type_symbol) : current_type_symbol ;
   224     
   224     
   225         /*Function specific CODE */
   225         /*Function specific CODE */
   378 Generate the part of search_expression_type_c::visit(function_invocation)
   378 Generate the part of search_expression_type_c::visit(function_invocation)
   379 that is responsible of returning type symbol for function invocation.
   379 that is responsible of returning type symbol for function invocation.
   380 """
   380 """
   381 search_type_code = matiec_header + """
   381 search_type_code = matiec_header + """
   382 
   382 
   383 void *compute_standard_function_default(function_invocation_c *st_symbol = NULL, il_formal_funct_call_c *il_symbol = NULL) {
   383 void *search_expression_type_c::compute_standard_function_default(function_invocation_c *st_symbol = NULL, il_formal_funct_call_c *il_symbol = NULL) {
   384   function_type_t current_function_type;
   384   function_type_t current_function_type;
   385   function_call_param_iterator_c *tmp_function_call_param_iterator;
   385   function_call_param_iterator_c *tmp_function_call_param_iterator;
   386   if (st_symbol != NULL && il_symbol == NULL) {
   386   if (st_symbol != NULL && il_symbol == NULL) {
   387     current_function_type = get_function_type((identifier_c *)st_symbol->function_name);
   387     current_function_type = get_function_type((identifier_c *)st_symbol->function_name);
   388     tmp_function_call_param_iterator = new function_call_param_iterator_c(st_symbol);
   388     tmp_function_call_param_iterator = new function_call_param_iterator_c(st_symbol);
   421     ERROR;
   421     ERROR;
   422   }
   422   }
   423   return NULL;
   423   return NULL;
   424 }
   424 }
   425 
   425 
   426 void *compute_standard_function_il(il_function_call_c *symbol, symbol_c *param_data_type) {
   426 void *search_expression_type_c::compute_standard_function_il(il_function_call_c *symbol, symbol_c *param_data_type) {
   427   
   427   
   428   function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name);
   428   function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name);
   429   function_call_param_iterator_c function_call_param_iterator(symbol);  
   429   function_call_param_iterator_c function_call_param_iterator(symbol);  
   430   search_expression_type_c* search_expression_type = this;
   430   search_expression_type_c* search_expression_type = this;
   431 
   431