generate_IEC_std.py
changeset 458 6e4ad5af894d
parent 410 e1d4e9a93186
child 486 0daecbcbfbf4
equal deleted inserted replaced
457:91b28dd0c9c9 458:6e4ad5af894d
   136             if do_il:
   136             if do_il:
   137                 res += """
   137                 res += """
   138 {"""
   138 {"""
   139                 if not do_type_search_only:
   139                 if not do_type_search_only:
   140                     res += """
   140                     res += """
       
   141     identifier_c %(input_name)s_param_name("%(input_name)s");
   141     /* Get the value from a foo(<param_name> = <param_value>) style call */
   142     /* Get the value from a foo(<param_name> = <param_value>) style call */
   142     symbol_c *%(input_name)s_param_value = &this->default_variable_name;
   143     symbol_c *%(input_name)s_param_value = &this->default_variable_name;
   143 """%{"input_name":Paramname}
   144 """%{"input_name":Paramname}
   144                 res += """
   145                 res += """
   145     symbol_c *%(input_name)s_type_symbol = param_data_type;
   146     symbol_c *%(input_name)s_type_symbol = param_data_type;
   146     last_type_symbol = param_data_type;
   147     last_type_symbol = param_data_type;
   147 """%{"input_name":Paramname}
   148 """%{"input_name":Paramname}
   148             else:
   149             else:
   149                 res += """
   150                 res += """
   150 {
   151 {
   151     identifier_c param_name("%(input_name)s");
   152     identifier_c %(input_name)s_param_name("%(input_name)s");
   152     /* Get the value from a foo(<param_name> = <param_value>) style call */
   153     /* 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_f(&param_name);
   154     symbol_c *%(input_name)s_param_value = function_call_param_iterator.search_f(&%(input_name)s_param_name);
   154     symbol_c *%(input_name)s_type_symbol = NULL;
   155     symbol_c *%(input_name)s_type_symbol = NULL;
   155     
   156     
   156     /* Get the value from a foo(<param_value>) style call */
   157     /* Get the value from a foo(<param_value>) style call */
   157     if (%(input_name)s_param_value == NULL)
   158     if (%(input_name)s_param_value == NULL)
   158       %(input_name)s_param_value = function_call_param_iterator.next_nf();
   159       %(input_name)s_param_value = function_call_param_iterator.next_nf();
   193                 res += """
   194                 res += """
   194 if (nb_param < %(min_nb_param)d)
   195 if (nb_param < %(min_nb_param)d)
   195   nb_param = %(min_nb_param)d;
   196   nb_param = %(min_nb_param)d;
   196 char* nb_param_str = new char[10];
   197 char* nb_param_str = new char[10];
   197 sprintf(nb_param_str, "%%d", nb_param);
   198 sprintf(nb_param_str, "%%d", nb_param);
   198 ADD_PARAM_LIST((symbol_c*)(new integer_c((const char *)nb_param_str)), (symbol_c*)(new int_type_name_c()), function_param_iterator_c::direction_in)
   199 identifier_c nb_param_name("nb_param");
       
   200 ADD_PARAM_LIST(&nb_param_name, (symbol_c*)(new integer_c((const char *)nb_param_str)), (symbol_c*)(new int_type_name_c()), function_param_iterator_c::direction_in)
   199 """%{"min_nb_param" : len(fdecl["inputs"])}
   201 """%{"min_nb_param" : len(fdecl["inputs"])}
   200             for paramname,paramtype,unused in fdecl["inputs"]:
   202             for paramname,paramtype,unused in fdecl["inputs"]:
   201                 res += """
   203                 res += """
   202 if (%(input_name)s_type_symbol == NULL)
   204 if (%(input_name)s_type_symbol == NULL)
   203   %(input_name)s_type_symbol = last_type_symbol;
   205   %(input_name)s_type_symbol = last_type_symbol;
   204 ADD_PARAM_LIST(%(input_name)s_param_value, %(input_name)s_type_symbol, function_param_iterator_c::direction_in)
   206 ADD_PARAM_LIST(&%(input_name)s_param_name, %(input_name)s_param_value, %(input_name)s_type_symbol, function_param_iterator_c::direction_in)
   205 """%{"input_name" : paramname}
   207 """%{"input_name" : paramname}
   206             if fdecl["extensible"]:
   208             if fdecl["extensible"]:
   207                 res += """
   209                 res += """
   208 int base_num = %d;
   210 int base_num = %d;
   209 symbol_c *param_value = NULL;
   211 symbol_c *param_value = NULL;
   221     if (param_value != NULL){
   223     if (param_value != NULL){
   222         symbol_c *current_type_symbol = search_expression_type->get_type(param_value);
   224         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 ;
   225         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     
   226     
   225         /*Function specific CODE */
   227         /*Function specific CODE */
   226         ADD_PARAM_LIST(param_value, current_type_symbol, function_param_iterator_c::direction_in)
   228         ADD_PARAM_LIST(&param_name, param_value, current_type_symbol, function_param_iterator_c::direction_in)
   227     }
   229     }
   228     
   230     
   229 }while(param_value != NULL);
   231 }while(param_value != NULL);
   230 """%(fdecl["baseinputnumber"] + 2)
   232 """%(fdecl["baseinputnumber"] + 2)
   231         
   233