stage4/generate_c/st_code_gen.c
changeset 165 83963465b773
parent 154 9114afe1f64b
child 169 bea932bc60b0
equal deleted inserted replaced
164:a0679c78143a 165:83963465b773
 13372             last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN_type_symbol, last_type_symbol) : IN_type_symbol ;
 13372             last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN_type_symbol, last_type_symbol) : IN_type_symbol ;
 13373             
 13373             
 13374             if(search_expression_type->is_real_type(IN_type_symbol))
 13374             if(search_expression_type->is_real_type(IN_type_symbol))
 13375             {
 13375             {
 13376         
 13376         
 13377                 function_name = (symbol_c*)(new pragma_c("sqrt"));
 13377                 function_name = (symbol_c*)(new pragma_c("__sqrt_"));
 13378                 ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in)
 13378                 ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in)
 13379                 symbol_c * return_type_symbol = IN_type_symbol;
 13379                 symbol_c * return_type_symbol = IN_type_symbol;
       
 13380                 function_type_suffix = IN_type_symbol;
 13380                 break;
 13381                 break;
 13381                 
 13382                 
 13382             }
 13383             }
 13383             
 13384             
 13384             
 13385             
 13407             last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN_type_symbol, last_type_symbol) : IN_type_symbol ;
 13408             last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN_type_symbol, last_type_symbol) : IN_type_symbol ;
 13408             
 13409             
 13409             if(search_expression_type->is_real_type(IN_type_symbol))
 13410             if(search_expression_type->is_real_type(IN_type_symbol))
 13410             {
 13411             {
 13411         
 13412         
 13412                 function_name = (symbol_c*)(new pragma_c("ln"));
 13413                 function_name = (symbol_c*)(new pragma_c("__ln_"));
 13413                 ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in)
 13414                 ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in)
 13414                 symbol_c * return_type_symbol = IN_type_symbol;
 13415                 symbol_c * return_type_symbol = IN_type_symbol;
       
 13416                 function_type_suffix = IN_type_symbol;
 13415                 break;
 13417                 break;
 13416                 
 13418                 
 13417             }
 13419             }
 13418             
 13420             
 13419             
 13421             
 13442             last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN_type_symbol, last_type_symbol) : IN_type_symbol ;
 13444             last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN_type_symbol, last_type_symbol) : IN_type_symbol ;
 13443             
 13445             
 13444             if(search_expression_type->is_real_type(IN_type_symbol))
 13446             if(search_expression_type->is_real_type(IN_type_symbol))
 13445             {
 13447             {
 13446         
 13448         
 13447                 function_name = (symbol_c*)(new pragma_c("log"));
 13449                 function_name = (symbol_c*)(new pragma_c("__log_"));
 13448                 ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in)
 13450                 ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in)
 13449                 symbol_c * return_type_symbol = IN_type_symbol;
 13451                 symbol_c * return_type_symbol = IN_type_symbol;
       
 13452                 function_type_suffix = IN_type_symbol;
 13450                 break;
 13453                 break;
 13451                 
 13454                 
 13452             }
 13455             }
 13453             
 13456             
 13454             
 13457             
 13477             last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN_type_symbol, last_type_symbol) : IN_type_symbol ;
 13480             last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN_type_symbol, last_type_symbol) : IN_type_symbol ;
 13478             
 13481             
 13479             if(search_expression_type->is_real_type(IN_type_symbol))
 13482             if(search_expression_type->is_real_type(IN_type_symbol))
 13480             {
 13483             {
 13481         
 13484         
 13482                 function_name = (symbol_c*)(new pragma_c("exp"));
 13485                 function_name = (symbol_c*)(new pragma_c("__exp_"));
 13483                 ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in)
 13486                 ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in)
 13484                 symbol_c * return_type_symbol = IN_type_symbol;
 13487                 symbol_c * return_type_symbol = IN_type_symbol;
       
 13488                 function_type_suffix = IN_type_symbol;
 13485                 break;
 13489                 break;
 13486                 
 13490                 
 13487             }
 13491             }
 13488             
 13492             
 13489             
 13493             
 13512             last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN_type_symbol, last_type_symbol) : IN_type_symbol ;
 13516             last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN_type_symbol, last_type_symbol) : IN_type_symbol ;
 13513             
 13517             
 13514             if(search_expression_type->is_real_type(IN_type_symbol))
 13518             if(search_expression_type->is_real_type(IN_type_symbol))
 13515             {
 13519             {
 13516         
 13520         
 13517                 function_name = (symbol_c*)(new pragma_c("sin"));
 13521                 function_name = (symbol_c*)(new pragma_c("__sin_"));
 13518                 ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in)
 13522                 ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in)
 13519                 symbol_c * return_type_symbol = IN_type_symbol;
 13523                 symbol_c * return_type_symbol = IN_type_symbol;
       
 13524                 function_type_suffix = IN_type_symbol;
 13520                 break;
 13525                 break;
 13521                 
 13526                 
 13522             }
 13527             }
 13523             
 13528             
 13524             
 13529             
 13547             last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN_type_symbol, last_type_symbol) : IN_type_symbol ;
 13552             last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN_type_symbol, last_type_symbol) : IN_type_symbol ;
 13548             
 13553             
 13549             if(search_expression_type->is_real_type(IN_type_symbol))
 13554             if(search_expression_type->is_real_type(IN_type_symbol))
 13550             {
 13555             {
 13551         
 13556         
 13552                 function_name = (symbol_c*)(new pragma_c("cos"));
 13557                 function_name = (symbol_c*)(new pragma_c("__cos_"));
 13553                 ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in)
 13558                 ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in)
 13554                 symbol_c * return_type_symbol = IN_type_symbol;
 13559                 symbol_c * return_type_symbol = IN_type_symbol;
       
 13560                 function_type_suffix = IN_type_symbol;
 13555                 break;
 13561                 break;
 13556                 
 13562                 
 13557             }
 13563             }
 13558             
 13564             
 13559             
 13565             
 13582             last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN_type_symbol, last_type_symbol) : IN_type_symbol ;
 13588             last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN_type_symbol, last_type_symbol) : IN_type_symbol ;
 13583             
 13589             
 13584             if(search_expression_type->is_real_type(IN_type_symbol))
 13590             if(search_expression_type->is_real_type(IN_type_symbol))
 13585             {
 13591             {
 13586         
 13592         
 13587                 function_name = (symbol_c*)(new pragma_c("tan"));
 13593                 function_name = (symbol_c*)(new pragma_c("__tan_"));
 13588                 ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in)
 13594                 ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in)
 13589                 symbol_c * return_type_symbol = IN_type_symbol;
 13595                 symbol_c * return_type_symbol = IN_type_symbol;
       
 13596                 function_type_suffix = IN_type_symbol;
 13590                 break;
 13597                 break;
 13591                 
 13598                 
 13592             }
 13599             }
 13593             
 13600             
 13594             
 13601             
 13617             last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN_type_symbol, last_type_symbol) : IN_type_symbol ;
 13624             last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN_type_symbol, last_type_symbol) : IN_type_symbol ;
 13618             
 13625             
 13619             if(search_expression_type->is_real_type(IN_type_symbol))
 13626             if(search_expression_type->is_real_type(IN_type_symbol))
 13620             {
 13627             {
 13621         
 13628         
 13622                 function_name = (symbol_c*)(new pragma_c("asin"));
 13629                 function_name = (symbol_c*)(new pragma_c("__asin_"));
 13623                 ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in)
 13630                 ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in)
 13624                 symbol_c * return_type_symbol = IN_type_symbol;
 13631                 symbol_c * return_type_symbol = IN_type_symbol;
       
 13632                 function_type_suffix = IN_type_symbol;
 13625                 break;
 13633                 break;
 13626                 
 13634                 
 13627             }
 13635             }
 13628             
 13636             
 13629             
 13637             
 13652             last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN_type_symbol, last_type_symbol) : IN_type_symbol ;
 13660             last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN_type_symbol, last_type_symbol) : IN_type_symbol ;
 13653             
 13661             
 13654             if(search_expression_type->is_real_type(IN_type_symbol))
 13662             if(search_expression_type->is_real_type(IN_type_symbol))
 13655             {
 13663             {
 13656         
 13664         
 13657                 function_name = (symbol_c*)(new pragma_c("acos"));
 13665                 function_name = (symbol_c*)(new pragma_c("__acos_"));
 13658                 ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in)
 13666                 ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in)
 13659                 symbol_c * return_type_symbol = IN_type_symbol;
 13667                 symbol_c * return_type_symbol = IN_type_symbol;
       
 13668                 function_type_suffix = IN_type_symbol;
 13660                 break;
 13669                 break;
 13661                 
 13670                 
 13662             }
 13671             }
 13663             
 13672             
 13664             
 13673             
 13687             last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN_type_symbol, last_type_symbol) : IN_type_symbol ;
 13696             last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN_type_symbol, last_type_symbol) : IN_type_symbol ;
 13688             
 13697             
 13689             if(search_expression_type->is_real_type(IN_type_symbol))
 13698             if(search_expression_type->is_real_type(IN_type_symbol))
 13690             {
 13699             {
 13691         
 13700         
 13692                 function_name = (symbol_c*)(new pragma_c("atan"));
 13701                 function_name = (symbol_c*)(new pragma_c("__atan_"));
 13693                 ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in)
 13702                 ADD_PARAM_LIST(IN_param_value, IN_type_symbol, function_param_iterator_c::direction_in)
 13694                 symbol_c * return_type_symbol = IN_type_symbol;
 13703                 symbol_c * return_type_symbol = IN_type_symbol;
       
 13704                 function_type_suffix = IN_type_symbol;
 13695                 break;
 13705                 break;
 13696                 
 13706                 
 13697             }
 13707             }
 13698             
 13708             
 13699             
 13709             
 14359             if (IN1_param_value == NULL)
 14369             if (IN1_param_value == NULL)
 14360               IN1_param_value = function_call_param_iterator.next();
 14370               IN1_param_value = function_call_param_iterator.next();
 14361             symbol_c *IN1_type_symbol = search_expression_type->get_type(IN1_param_value);
 14371             symbol_c *IN1_type_symbol = search_expression_type->get_type(IN1_param_value);
 14362             last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN1_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN1_type_symbol, last_type_symbol) : IN1_type_symbol ;
 14372             last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN1_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN1_type_symbol, last_type_symbol) : IN1_type_symbol ;
 14363             
 14373             
 14364             if(search_expression_type->is_num_type(IN1_type_symbol))
 14374             if(search_expression_type->is_real_type(IN1_type_symbol))
 14365             {
 14375             {
 14366         
 14376         
 14367                 {
 14377                 {
 14368                     identifier_c param_name("IN2");
 14378                     identifier_c param_name("IN2");
 14369                     /* Get the value from a foo(<param_name> = <param_value>) style call */
 14379                     /* Get the value from a foo(<param_name> = <param_value>) style call */
 14376                     last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN2_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN2_type_symbol, last_type_symbol) : IN2_type_symbol ;
 14386                     last_type_symbol = last_type_symbol && search_expression_type->is_same_type(IN2_type_symbol, last_type_symbol) ? search_expression_type->common_type(IN2_type_symbol, last_type_symbol) : IN2_type_symbol ;
 14377                     
 14387                     
 14378                     if(search_expression_type->is_num_type(IN2_type_symbol))
 14388                     if(search_expression_type->is_num_type(IN2_type_symbol))
 14379                     {
 14389                     {
 14380                 
 14390                 
 14381                         function_name = (symbol_c*)(new pragma_c("pow"));
 14391                         function_name = (symbol_c*)(new pragma_c("__expt_"));
 14382                         ADD_PARAM_LIST(IN1_param_value, IN1_type_symbol, function_param_iterator_c::direction_in)
 14392                         ADD_PARAM_LIST(IN1_param_value, IN1_type_symbol, function_param_iterator_c::direction_in)
 14383                         ADD_PARAM_LIST(IN2_param_value, IN2_type_symbol, function_param_iterator_c::direction_in)
 14393                         ADD_PARAM_LIST(IN2_param_value, IN2_type_symbol, function_param_iterator_c::direction_in)
 14384                         symbol_c * return_type_symbol = last_type_symbol;
 14394                         symbol_c * return_type_symbol = last_type_symbol;
       
 14395                         function_type_suffix = IN1_type_symbol;
 14385                         break;
 14396                         break;
 14386                         
 14397                         
 14387                     }
 14398                     }
 14388                     
 14399                     
 14389                     
 14400