stage4/generate_c/generate_c_il.cc
changeset 233 3d23a68183d3
parent 231 b8527b0abe75
child 235 ed66dc50f31a
equal deleted inserted replaced
232:29ab33687333 233:3d23a68183d3
   832   DECLARE_PARAM_LIST()
   832   DECLARE_PARAM_LIST()
   833   
   833   
   834   symbol_c *param_data_type = default_variable_name.current_type;
   834   symbol_c *param_data_type = default_variable_name.current_type;
   835   symbol_c *return_data_type = NULL;
   835   symbol_c *return_data_type = NULL;
   836   
   836   
       
   837   function_call_param_iterator_c function_call_param_iterator(symbol);
       
   838 
   837   if (f_decl == function_symtable.end_value()) {
   839   if (f_decl == function_symtable.end_value()) {
   838     function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name);
   840     function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name);
   839     if (current_function_type == function_none) ERROR;
   841     if (current_function_type == function_none) ERROR;
   840     
   842     
   841     return_data_type = (symbol_c *)search_expression_type->compute_standard_function_il(symbol, param_data_type);
   843     return_data_type = (symbol_c *)search_expression_type->compute_standard_function_il(symbol, param_data_type);
   842     if (NULL == return_data_type) ERROR;
   844     if (NULL == return_data_type) ERROR;
   843     
       
   844     function_call_param_iterator_c function_call_param_iterator(symbol);
       
   845     
   845     
   846     identifier_c en_param_name("EN");
   846     identifier_c en_param_name("EN");
   847     /* Add the value from EN param */
   847     /* Add the value from EN param */
   848     ADD_PARAM_LIST(&en_param_name,
   848     ADD_PARAM_LIST(&en_param_name,
   849                    (symbol_c*)(new boolean_literal_c((symbol_c*)(new bool_type_name_c()), new boolean_true_c())),
   849                    (symbol_c*)(new boolean_literal_c((symbol_c*)(new bool_type_name_c()), new boolean_true_c())),
   873      * to it, and then output the c equivalent...
   873      * to it, and then output the c equivalent...
   874      */
   874      */
   875   
   875   
   876     function_param_iterator_c fp_iterator(f_decl);
   876     function_param_iterator_c fp_iterator(f_decl);
   877     identifier_c *param_name;
   877     identifier_c *param_name;
   878     function_call_param_iterator_c function_call_param_iterator(symbol);
       
   879     for(int i = 1; (param_name = fp_iterator.next()) != NULL; i++) {
   878     for(int i = 1; (param_name = fp_iterator.next()) != NULL; i++) {
   880       symbol_c *param_type = fp_iterator.param_type();
   879       symbol_c *param_type = fp_iterator.param_type();
   881       if (param_type == NULL) ERROR;
   880       if (param_type == NULL) ERROR;
   882       
   881       
   883       function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction();
   882       function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction();
   900        */
   899        */
   901       if (param_value == NULL)
   900       if (param_value == NULL)
   902         param_value = function_call_param_iterator.search_f(param_name);
   901         param_value = function_call_param_iterator.search_f(param_name);
   903   
   902   
   904       /* Get the value from a foo(<param_value>) style call */
   903       /* Get the value from a foo(<param_value>) style call */
   905       if (param_value == NULL)
   904       if (param_value == NULL) {
   906         param_value = function_call_param_iterator.next_nf();
   905         param_value = function_call_param_iterator.next_nf();
       
   906         if (param_value != NULL && fp_iterator.is_en_eno_param_implicit()) ERROR;
       
   907       }
   907       
   908       
   908       if (param_value == NULL && param_direction == function_param_iterator_c::direction_in) {
   909       if (param_value == NULL && param_direction == function_param_iterator_c::direction_in) {
   909         /* No value given for parameter, so we must use the default... */
   910         /* No value given for parameter, so we must use the default... */
   910         /* First check whether default value specified in function declaration...*/
   911         /* First check whether default value specified in function declaration...*/
   911         param_value = fp_iterator.default_value();
   912         param_value = fp_iterator.default_value();
   913       
   914       
   914       ADD_PARAM_LIST(param_name, param_value, param_type, fp_iterator.param_direction())
   915       ADD_PARAM_LIST(param_name, param_value, param_type, fp_iterator.param_direction())
   915     } /* for(...) */
   916     } /* for(...) */
   916   }
   917   }
   917   
   918   
       
   919   if (function_call_param_iterator.next_nf() != NULL) ERROR;
       
   920 
   918   bool has_output_params = false;
   921   bool has_output_params = false;
   919 
   922 
   920   if (!this->is_variable_prefix_null()) {
   923   if (!this->is_variable_prefix_null()) {
   921     PARAM_LIST_ITERATOR() {
   924     PARAM_LIST_ITERATOR() {
   922 	  if ((PARAM_DIRECTION == function_param_iterator_c::direction_out ||
   925 	  if ((PARAM_DIRECTION == function_param_iterator_c::direction_out ||
  1194   symbol_c* function_type_suffix = NULL;
  1197   symbol_c* function_type_suffix = NULL;
  1195   DECLARE_PARAM_LIST()
  1198   DECLARE_PARAM_LIST()
  1196 
  1199 
  1197   symbol_c *return_data_type = NULL;
  1200   symbol_c *return_data_type = NULL;
  1198 
  1201 
       
  1202   function_call_param_iterator_c function_call_param_iterator(symbol);
       
  1203 
  1199   if (f_decl == function_symtable.end_value()) {
  1204   if (f_decl == function_symtable.end_value()) {
  1200     function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name);
  1205     function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name);
  1201     if (current_function_type == function_none) ERROR;
  1206     if (current_function_type == function_none) ERROR;
  1202     
  1207     
  1203     return_data_type = (symbol_c *)search_expression_type->compute_standard_function_default(NULL, symbol);
  1208     return_data_type = (symbol_c *)search_expression_type->compute_standard_function_default(NULL, symbol);
  1204     if (NULL == return_data_type) ERROR;
  1209     if (NULL == return_data_type) ERROR;
  1205     
       
  1206     function_call_param_iterator_c function_call_param_iterator(symbol);
       
  1207     
  1210     
  1208     int nb_param = 0;
  1211     int nb_param = 0;
  1209     if (symbol->il_param_list != NULL)
  1212     if (symbol->il_param_list != NULL)
  1210       nb_param += ((list_c *)symbol->il_param_list)->n;
  1213       nb_param += ((list_c *)symbol->il_param_list)->n;
  1211     
  1214     
  1240      * to it, and then output the c equivalent...
  1243      * to it, and then output the c equivalent...
  1241      */
  1244      */
  1242   
  1245   
  1243     function_param_iterator_c fp_iterator(f_decl);
  1246     function_param_iterator_c fp_iterator(f_decl);
  1244     identifier_c *param_name;
  1247     identifier_c *param_name;
  1245     function_call_param_iterator_c function_call_param_iterator(symbol);
       
  1246     for(int i = 1; (param_name = fp_iterator.next()) != NULL; i++) {
  1248     for(int i = 1; (param_name = fp_iterator.next()) != NULL; i++) {
  1247       symbol_c *param_type = fp_iterator.param_type();
  1249       symbol_c *param_type = fp_iterator.param_type();
  1248       if (param_type == NULL) ERROR;
  1250       if (param_type == NULL) ERROR;
  1249   
  1251   
  1250       function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction();
  1252       function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction();
  1262        * it will always return NULL.
  1264        * it will always return NULL.
  1263        * We leave it in in case we later decide to merge this part of the code together
  1265        * We leave it in in case we later decide to merge this part of the code together
  1264        * with the function calling code in generate_c_st_c, which does require
  1266        * with the function calling code in generate_c_st_c, which does require
  1265        * the following line...
  1267        * the following line...
  1266        */
  1268        */
  1267       if (param_value == NULL)
  1269       if (param_value == NULL) {
  1268         param_value = function_call_param_iterator.next_nf();
  1270         param_value = function_call_param_iterator.next_nf();
       
  1271         if (param_value != NULL && fp_iterator.is_en_eno_param_implicit()) ERROR;
       
  1272       }
  1269       
  1273       
  1270       if (param_value == NULL) {
  1274       if (param_value == NULL) {
  1271         /* No value given for parameter, so we must use the default... */
  1275         /* No value given for parameter, so we must use the default... */
  1272         /* First check whether default value specified in function declaration...*/
  1276         /* First check whether default value specified in function declaration...*/
  1273         param_value = fp_iterator.default_value();
  1277         param_value = fp_iterator.default_value();
  1275       
  1279       
  1276       ADD_PARAM_LIST(param_name, param_value, param_type, fp_iterator.param_direction())
  1280       ADD_PARAM_LIST(param_name, param_value, param_type, fp_iterator.param_direction())
  1277     }
  1281     }
  1278   }
  1282   }
  1279   
  1283   
       
  1284   if (function_call_param_iterator.next_nf() != NULL) ERROR;
       
  1285 
  1280   bool has_output_params = false;
  1286   bool has_output_params = false;
  1281 
  1287 
  1282   if (!this->is_variable_prefix_null()) {
  1288   if (!this->is_variable_prefix_null()) {
  1283     PARAM_LIST_ITERATOR() {
  1289     PARAM_LIST_ITERATOR() {
  1284 	  if ((PARAM_DIRECTION == function_param_iterator_c::direction_out ||
  1290 	  if ((PARAM_DIRECTION == function_param_iterator_c::direction_out ||