787 symbol_c *param_data_type = default_variable_name.current_type; |
787 symbol_c *param_data_type = default_variable_name.current_type; |
788 symbol_c *return_data_type = NULL; |
788 symbol_c *return_data_type = NULL; |
789 |
789 |
790 function_call_param_iterator_c function_call_param_iterator(symbol); |
790 function_call_param_iterator_c function_call_param_iterator(symbol); |
791 |
791 |
792 function_declaration_c *f_decl = function_symtable.find_value(symbol->function_name); |
792 function_declaration_c *f_decl = (function_declaration_c *)symbol->called_function_declaration; |
793 if (f_decl == function_symtable.end_value()) { |
793 if (f_decl == NULL) ERROR; |
794 function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name); |
794 |
795 if (current_function_type == function_none) ERROR; |
795 /* determine the base data type returned by the function being called... */ |
|
796 search_base_type_c search_base_type; |
|
797 return_data_type = (symbol_c *)f_decl->type_name->accept(search_base_type); |
|
798 if (NULL == return_data_type) ERROR; |
|
799 |
|
800 function_name = symbol->function_name; |
|
801 |
|
802 /* loop through each function parameter, find the value we should pass |
|
803 * to it, and then output the c equivalent... |
|
804 */ |
|
805 function_param_iterator_c fp_iterator(f_decl); |
|
806 identifier_c *param_name; |
|
807 /* flag to remember whether we have already used the value stored in the default variable to pass to the first parameter */ |
|
808 bool used_defvar = false; |
|
809 /* flag to cirreclty handle calls to extensible standard functions (i.e. functions with variable number of input parameters) */ |
|
810 bool found_first_extensible_parameter = false; |
|
811 for(int i = 1; (param_name = fp_iterator.next()) != NULL; i++) { |
|
812 if (fp_iterator.is_extensible_param() && (!found_first_extensible_parameter)) { |
|
813 /* We are calling an extensible function. Before passing the extensible |
|
814 * parameters, we must add a dummy paramater value to tell the called |
|
815 * function how many extensible parameters we will be passing. |
|
816 * |
|
817 * Note that stage 3 has already determined the number of extensible |
|
818 * paramters, and stored that info in the abstract syntax tree. We simply |
|
819 * re-use that value. |
|
820 */ |
|
821 /* NOTE: we are not freeing the malloc'd memory. This is not really a bug. |
|
822 * Since we are writing a compiler, which runs to termination quickly, |
|
823 * we can consider this as just memory required for the compilation process |
|
824 * that will be free'd when the program terminates. |
|
825 */ |
|
826 char *tmp = (char *)malloc(32); /* enough space for a call with 10^31 (larger than 2^64) input parameters! */ |
|
827 if (tmp == NULL) ERROR; |
|
828 int res = snprintf(tmp, 32, "%d", symbol->extensible_param_count); |
|
829 if ((res >= 32) || (res < 0)) ERROR; |
|
830 identifier_c *param_value = new identifier_c(tmp); |
|
831 uint_type_name_c *param_type = new uint_type_name_c(); |
|
832 identifier_c *param_name = new identifier_c(""); |
|
833 ADD_PARAM_LIST(param_name, param_value, param_type, function_param_iterator_c::direction_in) |
|
834 found_first_extensible_parameter = true; |
|
835 } |
796 |
836 |
797 return_data_type = (symbol_c *)search_expression_type->compute_standard_function_il(symbol, param_data_type); |
837 symbol_c *param_type = fp_iterator.param_type(); |
798 if (NULL == return_data_type) ERROR; |
838 if (param_type == NULL) ERROR; |
799 |
839 |
800 symbol_c *en_param_name = (symbol_c *)(new identifier_c("EN")); |
840 function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction(); |
801 /* Add the value from EN param */ |
|
802 ADD_PARAM_LIST(en_param_name, |
|
803 (symbol_c*)(new boolean_literal_c((symbol_c*)(new bool_type_name_c()), new boolean_true_c())), |
|
804 (symbol_c*)(new bool_type_name_c()), |
|
805 function_param_iterator_c::direction_in) |
|
806 |
841 |
807 symbol_c *eno_param_name = (symbol_c *)(new identifier_c("ENO")); |
842 symbol_c *param_value = NULL; |
808 /* Add the value from ENO param */ |
843 |
809 ADD_PARAM_LIST(eno_param_name, NULL, (symbol_c*)(new bool_type_name_c()), function_param_iterator_c::direction_out) |
844 /* Get the value from a foo(<param_name> = <param_value>) style call */ |
|
845 /* NOTE: Since the class il_function_call_c only references a non.formal function call, |
|
846 * the following line of code is not required in this case. However, it doesn't |
|
847 * harm to leave it in, as in the case of a non-formal syntax function call, |
|
848 * it will always return NULL. |
|
849 * We leave it in in case we later decide to merge this part of the code together |
|
850 * with the function calling code in generate_c_st_c, which does require |
|
851 * the following line... |
|
852 */ |
|
853 if (param_value == NULL) |
|
854 param_value = function_call_param_iterator.search_f(param_name); |
|
855 |
|
856 /* if it is the first parameter in a non-formal function call (which is the |
|
857 * case being handled!), semantics specifies that we should |
|
858 * get the value off the IL default variable! |
|
859 * |
|
860 * However, if the parameter is an implicitly defined EN or ENO parameter, we should not |
|
861 * use the default variable as a source of data to pass to those parameters! |
|
862 */ |
|
863 if ((param_value == NULL) && (!used_defvar) && !fp_iterator.is_en_eno_param_implicit()) { |
|
864 param_value = &this->default_variable_name; |
|
865 used_defvar = true; |
|
866 } |
|
867 |
|
868 /* Get the value from a foo(<param_value>) style call */ |
|
869 if ((param_value == NULL) && !fp_iterator.is_en_eno_param_implicit()) { |
|
870 param_value = function_call_param_iterator.next_nf(); |
|
871 } |
810 |
872 |
811 int nb_param = 1; |
873 /* if no more parameter values in function call, and the current parameter |
812 if (symbol->il_operand_list != NULL) |
874 * of the function declaration is an extensible parameter, we |
813 nb_param += ((list_c *)symbol->il_operand_list)->n; |
875 * have reached the end, and should simply jump out of the for loop. |
814 |
876 */ |
815 #include "il_code_gen.c" |
877 if ((param_value == NULL) && (fp_iterator.is_extensible_param())) { |
816 |
878 break; |
817 } |
879 } |
818 else { |
|
819 /* determine the base data type returned by the function being called... */ |
|
820 search_base_type_c search_base_type; |
|
821 return_data_type = (symbol_c *)f_decl->type_name->accept(search_base_type); |
|
822 if (NULL == return_data_type) ERROR; |
|
823 |
|
824 function_name = symbol->function_name; |
|
825 |
880 |
826 /* loop through each function parameter, find the value we should pass |
881 if ((param_value == NULL) && (param_direction == function_param_iterator_c::direction_in)) { |
827 * to it, and then output the c equivalent... |
882 /* No value given for parameter, so we must use the default... */ |
828 */ |
883 /* First check whether default value specified in function declaration...*/ |
829 |
884 param_value = fp_iterator.default_value(); |
830 function_param_iterator_c fp_iterator(f_decl); |
885 } |
831 identifier_c *param_name; |
886 |
832 for(int i = 1; (param_name = fp_iterator.next()) != NULL; i++) { |
887 ADD_PARAM_LIST(param_name, param_value, param_type, fp_iterator.param_direction()) |
833 symbol_c *param_type = fp_iterator.param_type(); |
888 } /* for(...) */ |
834 if (param_type == NULL) ERROR; |
889 |
835 |
|
836 function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction(); |
|
837 |
|
838 symbol_c *param_value = NULL; |
|
839 |
|
840 /* if it is the first parameter, semantics specifies that we should |
|
841 * get the value off the IL default variable! |
|
842 */ |
|
843 if (1 == i) |
|
844 param_value = &this->default_variable_name; |
|
845 |
|
846 /* Get the value from a foo(<param_name> = <param_value>) style call */ |
|
847 /* NOTE: the following line of code is not required in this case, but it doesn't |
|
848 * harm to leave it in, as in the case of a non-formal syntax function call, |
|
849 * it will always return NULL. |
|
850 * We leave it in in case we later decide to merge this part of the code together |
|
851 * with the function calling code in generate_c_st_c, which does require |
|
852 * the following line... |
|
853 */ |
|
854 if (param_value == NULL) |
|
855 param_value = function_call_param_iterator.search_f(param_name); |
|
856 |
|
857 /* Get the value from a foo(<param_value>) style call */ |
|
858 if (param_value == NULL) { |
|
859 param_value = function_call_param_iterator.next_nf(); |
|
860 if (param_value != NULL && fp_iterator.is_en_eno_param_implicit()) ERROR; |
|
861 } |
|
862 |
|
863 if (param_value == NULL && param_direction == function_param_iterator_c::direction_in) { |
|
864 /* No value given for parameter, so we must use the default... */ |
|
865 /* First check whether default value specified in function declaration...*/ |
|
866 param_value = fp_iterator.default_value(); |
|
867 } |
|
868 |
|
869 ADD_PARAM_LIST(param_name, param_value, param_type, fp_iterator.param_direction()) |
|
870 } /* for(...) */ |
|
871 } |
|
872 |
|
873 if (function_call_param_iterator.next_nf() != NULL) ERROR; |
890 if (function_call_param_iterator.next_nf() != NULL) ERROR; |
874 |
891 |
875 bool has_output_params = false; |
892 bool has_output_params = false; |
876 |
893 |
877 if (!this->is_variable_prefix_null()) { |
894 if (!this->is_variable_prefix_null()) { |
878 PARAM_LIST_ITERATOR() { |
895 PARAM_LIST_ITERATOR() { |
879 if ((PARAM_DIRECTION == function_param_iterator_c::direction_out || |
896 if ((PARAM_DIRECTION == function_param_iterator_c::direction_out || |
880 PARAM_DIRECTION == function_param_iterator_c::direction_inout) && |
897 PARAM_DIRECTION == function_param_iterator_c::direction_inout) && |
881 PARAM_VALUE != NULL) { |
898 PARAM_VALUE != NULL) { |
882 if (!has_output_params) { |
899 has_output_params = true; |
883 has_output_params = true; |
900 } |
884 } |
901 } |
885 } |
902 } |
886 } |
903 |
887 } |
904 /* Check whether we are calling an overloaded function! */ |
|
905 /* (fdecl_mutiplicity==2) => calling overloaded function */ |
|
906 int fdecl_mutiplicity = function_symtable.multiplicity(symbol->function_name); |
|
907 if (fdecl_mutiplicity == 0) ERROR; |
888 |
908 |
889 default_variable_name.current_type = return_data_type; |
909 default_variable_name.current_type = return_data_type; |
890 this->default_variable_name.accept(*this); |
910 this->default_variable_name.accept(*this); |
891 default_variable_name.current_type = param_data_type; |
911 default_variable_name.current_type = param_data_type; |
892 s4o.print(" = "); |
912 s4o.print(" = "); |
1156 |
1195 |
1157 symbol_c *return_data_type = NULL; |
1196 symbol_c *return_data_type = NULL; |
1158 |
1197 |
1159 function_call_param_iterator_c function_call_param_iterator(symbol); |
1198 function_call_param_iterator_c function_call_param_iterator(symbol); |
1160 |
1199 |
1161 function_declaration_c *f_decl = function_symtable.find_value(symbol->function_name); |
1200 function_declaration_c *f_decl = (function_declaration_c *)symbol->called_function_declaration; |
1162 if (f_decl == function_symtable.end_value()) { |
1201 if (f_decl == NULL) ERROR; |
1163 function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name); |
1202 |
1164 if (current_function_type == function_none) ERROR; |
1203 /* determine the base data type returned by the function being called... */ |
|
1204 search_base_type_c search_base_type; |
|
1205 return_data_type = (symbol_c *)f_decl->type_name->accept(search_base_type); |
|
1206 if (NULL == return_data_type) ERROR; |
|
1207 |
|
1208 function_name = symbol->function_name; |
|
1209 |
|
1210 /* loop through each function parameter, find the value we should pass |
|
1211 * to it, and then output the c equivalent... |
|
1212 */ |
|
1213 function_param_iterator_c fp_iterator(f_decl); |
|
1214 identifier_c *param_name; |
|
1215 |
|
1216 /* flag to cirreclty handle calls to extensible standard functions (i.e. functions with variable number of input parameters) */ |
|
1217 bool found_first_extensible_parameter = false; |
|
1218 for(int i = 1; (param_name = fp_iterator.next()) != NULL; i++) { |
|
1219 if (fp_iterator.is_extensible_param() && (!found_first_extensible_parameter)) { |
|
1220 /* We are calling an extensible function. Before passing the extensible |
|
1221 * parameters, we must add a dummy paramater value to tell the called |
|
1222 * function how many extensible parameters we will be passing. |
|
1223 * |
|
1224 * Note that stage 3 has already determined the number of extensible |
|
1225 * paramters, and stored that info in the abstract syntax tree. We simply |
|
1226 * re-use that value. |
|
1227 */ |
|
1228 /* NOTE: we are not freeing the malloc'd memory. This is not really a bug. |
|
1229 * Since we are writing a compiler, which runs to termination quickly, |
|
1230 * we can consider this as just memory required for the compilation process |
|
1231 * that will be free'd when the program terminates. |
|
1232 */ |
|
1233 char *tmp = (char *)malloc(32); /* enough space for a call with 10^31 (larger than 2^64) input parameters! */ |
|
1234 if (tmp == NULL) ERROR; |
|
1235 int res = snprintf(tmp, 32, "%d", symbol->extensible_param_count); |
|
1236 if ((res >= 32) || (res < 0)) ERROR; |
|
1237 identifier_c *param_value = new identifier_c(tmp); |
|
1238 uint_type_name_c *param_type = new uint_type_name_c(); |
|
1239 identifier_c *param_name = new identifier_c(""); |
|
1240 ADD_PARAM_LIST(param_name, param_value, param_type, function_param_iterator_c::direction_in) |
|
1241 found_first_extensible_parameter = true; |
|
1242 } |
1165 |
1243 |
1166 return_data_type = (symbol_c *)search_expression_type->compute_standard_function_default(NULL, symbol); |
1244 if (fp_iterator.is_extensible_param()) { |
1167 if (NULL == return_data_type) ERROR; |
1245 /* since we are handling an extensible parameter, we must add the index to the |
|
1246 * parameter name so we can go looking for the value passed to the correct |
|
1247 * extended parameter (e.g. IN1, IN2, IN3, IN4, ...) |
|
1248 */ |
|
1249 char *tmp = (char *)malloc(32); /* enough space for a call with 10^31 (larger than 2^64) input parameters! */ |
|
1250 int res = snprintf(tmp, 32, "%d", fp_iterator.extensible_param_index()); |
|
1251 if ((res >= 32) || (res < 0)) ERROR; |
|
1252 param_name = new identifier_c(strdup2(param_name->value, tmp)); |
|
1253 if (param_name->value == NULL) ERROR; |
|
1254 } |
|
1255 |
|
1256 symbol_c *param_type = fp_iterator.param_type(); |
|
1257 if (param_type == NULL) ERROR; |
|
1258 |
|
1259 function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction(); |
|
1260 |
|
1261 symbol_c *param_value = NULL; |
|
1262 |
|
1263 /* Get the value from a foo(<param_name> = <param_value>) style call */ |
|
1264 if (param_value == NULL) |
|
1265 param_value = function_call_param_iterator.search_f(param_name); |
|
1266 |
|
1267 /* Get the value from a foo(<param_value>) style call */ |
|
1268 /* NOTE: the following line of code is not required in this case, but it doesn't |
|
1269 * harm to leave it in, as in the case of a formal syntax function call, |
|
1270 * it will always return NULL. |
|
1271 * We leave it in in case we later decide to merge this part of the code together |
|
1272 * with the function calling code in generate_c_st_c, which does require |
|
1273 * the following line... |
|
1274 */ |
|
1275 if ((param_value == NULL) && !fp_iterator.is_en_eno_param_implicit()) { |
|
1276 param_value = function_call_param_iterator.next_nf(); |
|
1277 } |
1168 |
1278 |
1169 int nb_param = 0; |
1279 /* if no more parameter values in function call, and the current parameter |
1170 if (symbol->il_param_list != NULL) |
1280 * of the function declaration is an extensible parameter, we |
1171 nb_param += ((list_c *)symbol->il_param_list)->n; |
1281 * have reached the end, and should simply jump out of the for loop. |
|
1282 */ |
|
1283 if ((param_value == NULL) && (fp_iterator.is_extensible_param())) { |
|
1284 break; |
|
1285 } |
1172 |
1286 |
1173 symbol_c *en_param_name = (symbol_c *)(new identifier_c("EN")); |
1287 if ((param_value == NULL) && (param_direction == function_param_iterator_c::direction_in)) { |
1174 /* Get the value from EN param */ |
1288 /* No value given for parameter, so we must use the default... */ |
1175 symbol_c *EN_param_value = function_call_param_iterator.search_f(en_param_name); |
1289 /* First check whether default value specified in function declaration...*/ |
1176 if (EN_param_value == NULL) |
1290 param_value = fp_iterator.default_value(); |
1177 EN_param_value = (symbol_c*)(new boolean_literal_c((symbol_c*)(new bool_type_name_c()), new boolean_true_c())); |
1291 } |
1178 else |
|
1179 nb_param --; |
|
1180 ADD_PARAM_LIST(en_param_name, EN_param_value, (symbol_c*)(new bool_type_name_c()), function_param_iterator_c::direction_in) |
|
1181 |
1292 |
1182 symbol_c *eno_param_name = (symbol_c *)(new identifier_c("ENO")); |
1293 ADD_PARAM_LIST(param_name, param_value, param_type, fp_iterator.param_direction()) |
1183 /* Get the value from ENO param */ |
|
1184 symbol_c *ENO_param_value = function_call_param_iterator.search_f(eno_param_name); |
|
1185 if (ENO_param_value != NULL) |
|
1186 nb_param --; |
|
1187 ADD_PARAM_LIST(eno_param_name, ENO_param_value, (symbol_c*)(new bool_type_name_c()), function_param_iterator_c::direction_out) |
|
1188 |
|
1189 #include "st_code_gen.c" |
|
1190 |
|
1191 } |
|
1192 else { |
|
1193 /* determine the base data type returned by the function being called... */ |
|
1194 search_base_type_c search_base_type; |
|
1195 return_data_type = (symbol_c *)f_decl->type_name->accept(search_base_type); |
|
1196 if (NULL == return_data_type) ERROR; |
|
1197 |
|
1198 function_name = symbol->function_name; |
|
1199 |
|
1200 /* loop through each function parameter, find the value we should pass |
|
1201 * to it, and then output the c equivalent... |
|
1202 */ |
|
1203 |
|
1204 function_param_iterator_c fp_iterator(f_decl); |
|
1205 identifier_c *param_name; |
|
1206 for(int i = 1; (param_name = fp_iterator.next()) != NULL; i++) { |
|
1207 symbol_c *param_type = fp_iterator.param_type(); |
|
1208 if (param_type == NULL) ERROR; |
|
1209 |
|
1210 function_param_iterator_c::param_direction_t param_direction = fp_iterator.param_direction(); |
|
1211 |
|
1212 |
|
1213 symbol_c *param_value = NULL; |
|
1214 |
|
1215 /* Get the value from a foo(<param_name> = <param_value>) style call */ |
|
1216 if (param_value == NULL) |
|
1217 param_value = function_call_param_iterator.search_f(param_name); |
|
1218 |
|
1219 /* Get the value from a foo(<param_value>) style call */ |
|
1220 /* NOTE: the following line of code is not required in this case, but it doesn't |
|
1221 * harm to leave it in, as in the case of a formal syntax function call, |
|
1222 * it will always return NULL. |
|
1223 * We leave it in in case we later decide to merge this part of the code together |
|
1224 * with the function calling code in generate_c_st_c, which does require |
|
1225 * the following line... |
|
1226 */ |
|
1227 if (param_value == NULL) { |
|
1228 param_value = function_call_param_iterator.next_nf(); |
|
1229 if (param_value != NULL && fp_iterator.is_en_eno_param_implicit()) ERROR; |
|
1230 } |
|
1231 |
|
1232 if (param_value == NULL) { |
|
1233 /* No value given for parameter, so we must use the default... */ |
|
1234 /* First check whether default value specified in function declaration...*/ |
|
1235 param_value = fp_iterator.default_value(); |
|
1236 } |
|
1237 |
|
1238 ADD_PARAM_LIST(param_name, param_value, param_type, fp_iterator.param_direction()) |
|
1239 } |
|
1240 } |
1294 } |
1241 |
1295 |
1242 if (function_call_param_iterator.next_nf() != NULL) ERROR; |
1296 if (function_call_param_iterator.next_nf() != NULL) ERROR; |
1243 |
1297 |
1244 bool has_output_params = false; |
1298 bool has_output_params = false; |
1245 |
1299 |
1246 if (!this->is_variable_prefix_null()) { |
1300 if (!this->is_variable_prefix_null()) { |
1247 PARAM_LIST_ITERATOR() { |
1301 PARAM_LIST_ITERATOR() { |
1248 if ((PARAM_DIRECTION == function_param_iterator_c::direction_out || |
1302 if ((PARAM_DIRECTION == function_param_iterator_c::direction_out || |
1249 PARAM_DIRECTION == function_param_iterator_c::direction_inout) && |
1303 PARAM_DIRECTION == function_param_iterator_c::direction_inout) && |
1250 PARAM_VALUE != NULL) { |
1304 PARAM_VALUE != NULL) { |
1251 if (!has_output_params) { |
1305 has_output_params = true; |
1252 has_output_params = true; |
1306 } |
1253 } |
1307 } |
1254 } |
1308 } |
1255 } |
1309 |
1256 } |
1310 /* Check whether we are calling an overloaded function! */ |
|
1311 /* (fdecl_mutiplicity==2) => calling overloaded function */ |
|
1312 int fdecl_mutiplicity = function_symtable.multiplicity(symbol->function_name); |
|
1313 if (fdecl_mutiplicity == 0) ERROR; |
|
1314 if (fdecl_mutiplicity == 1) |
|
1315 /* function being called is NOT overloaded! */ |
|
1316 f_decl = NULL; |
1257 |
1317 |
1258 default_variable_name.current_type = return_data_type; |
1318 default_variable_name.current_type = return_data_type; |
1259 this->default_variable_name.accept(*this); |
1319 this->default_variable_name.accept(*this); |
1260 s4o.print(" = "); |
1320 s4o.print(" = "); |
1261 |
1321 |
1263 s4o.print("("); |
1323 s4o.print("("); |
1264 search_expression_type->default_literal_type(function_type_prefix)->accept(*this); |
1324 search_expression_type->default_literal_type(function_type_prefix)->accept(*this); |
1265 s4o.print(")"); |
1325 s4o.print(")"); |
1266 } |
1326 } |
1267 if (function_type_suffix != NULL) { |
1327 if (function_type_suffix != NULL) { |
1268 function_type_suffix = search_expression_type->default_literal_type(function_type_prefix); |
1328 function_type_suffix = search_expression_type->default_literal_type(function_type_prefix); |
1269 } |
1329 } |
1270 if (has_output_params) { |
1330 if (has_output_params) { |
1271 fcall_number++; |
1331 fcall_number++; |
1272 s4o.print("__"); |
1332 s4o.print("__"); |
1273 fbname->accept(*this); |
1333 fbname->accept(*this); |
1274 s4o.print("_"); |
1334 s4o.print("_"); |
1275 function_name->accept(*this); |
1335 function_name->accept(*this); |
|
1336 if (fdecl_mutiplicity == 2) { |
|
1337 /* function being called is overloaded! */ |
|
1338 s4o.print("__"); |
|
1339 print_function_parameter_data_types_c overloaded_func_suf(&s4o); |
|
1340 f_decl->accept(overloaded_func_suf); |
|
1341 } |
1276 s4o.print_integer(fcall_number); |
1342 s4o.print_integer(fcall_number); |
1277 } |
1343 } |
1278 else { |
1344 else { |
1279 if (function_name != NULL) |
1345 if (function_name != NULL) { |
1280 function_name->accept(*this); |
1346 function_name->accept(*this); |
|
1347 if (fdecl_mutiplicity == 2) { |
|
1348 /* function being called is overloaded! */ |
|
1349 s4o.print("__"); |
|
1350 print_function_parameter_data_types_c overloaded_func_suf(&s4o); |
|
1351 f_decl->accept(overloaded_func_suf); |
|
1352 } |
|
1353 } |
1281 if (function_type_suffix != NULL) |
1354 if (function_type_suffix != NULL) |
1282 function_type_suffix->accept(*this); |
1355 function_type_suffix->accept(*this); |
1283 } |
1356 } |
1284 s4o.print("("); |
1357 s4o.print("("); |
1285 s4o.indent_right(); |
1358 s4o.indent_right(); |
1286 |
1359 |
1287 int nb_param = 0; |
1360 int nb_param = 0; |
1288 PARAM_LIST_ITERATOR() { |
1361 PARAM_LIST_ITERATOR() { |
1289 symbol_c *param_value = PARAM_VALUE; |
1362 symbol_c *param_value = PARAM_VALUE; |
1290 current_param_type = PARAM_TYPE; |
1363 current_param_type = PARAM_TYPE; |
1291 |
|
1292 switch (PARAM_DIRECTION) { |
1364 switch (PARAM_DIRECTION) { |
1293 case function_param_iterator_c::direction_in: |
1365 case function_param_iterator_c::direction_in: |
1294 if (nb_param > 0) |
1366 if (nb_param > 0) |
1295 s4o.print(",\n"+s4o.indent_spaces); |
1367 s4o.print(",\n"+s4o.indent_spaces); |
1296 if (param_value == NULL) { |
1368 if (param_value == NULL) { |
1297 /* If not, get the default value of this variable's type */ |
1369 /* If not, get the default value of this variable's type */ |
1298 param_value = (symbol_c *)current_param_type->accept(*type_initial_value_c::instance()); |
1370 param_value = (symbol_c *)current_param_type->accept(*type_initial_value_c::instance()); |
1299 } |
1371 } |
1300 if (param_value == NULL) ERROR; |
1372 if (param_value == NULL) ERROR; |
1301 s4o.print("("); |
1373 s4o.print("("); |
1746 } |
1818 } |
1747 |
1819 |
1748 void *visit(GT_operator_c *symbol) { |
1820 void *visit(GT_operator_c *symbol) { |
1749 if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) && |
1821 if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) && |
1750 search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) |
1822 search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) |
1751 return CMP_operator(this->current_operand, "__gt_"); |
1823 return CMP_operator(this->current_operand, "GT_"); |
1752 ERROR; |
1824 ERROR; |
1753 return NULL; |
1825 return NULL; |
1754 } |
1826 } |
1755 |
1827 |
1756 void *visit(GE_operator_c *symbol) { |
1828 void *visit(GE_operator_c *symbol) { |
1757 if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) && |
1829 if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) && |
1758 search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) |
1830 search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) |
1759 return CMP_operator(this->current_operand, "__ge_"); |
1831 return CMP_operator(this->current_operand, "GE_"); |
1760 ERROR; |
1832 ERROR; |
1761 return NULL; |
1833 return NULL; |
1762 } |
1834 } |
1763 |
1835 |
1764 void *visit(EQ_operator_c *symbol) { |
1836 void *visit(EQ_operator_c *symbol) { |
1765 if (search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) |
1837 if (search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) |
1766 return CMP_operator(this->current_operand, "__eq_"); |
1838 return CMP_operator(this->current_operand, "EQ_"); |
1767 ERROR; |
1839 ERROR; |
1768 return NULL; |
1840 return NULL; |
1769 } |
1841 } |
1770 |
1842 |
1771 void *visit(LT_operator_c *symbol) { |
1843 void *visit(LT_operator_c *symbol) { |
1772 if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) && |
1844 if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) && |
1773 search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) |
1845 search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) |
1774 return CMP_operator(this->current_operand, "__lt_"); |
1846 return CMP_operator(this->current_operand, "LT_"); |
1775 ERROR; |
1847 ERROR; |
1776 return NULL; |
1848 return NULL; |
1777 } |
1849 } |
1778 |
1850 |
1779 void *visit(LE_operator_c *symbol) { |
1851 void *visit(LE_operator_c *symbol) { |
1780 if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) && |
1852 if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) && |
1781 search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) |
1853 search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) |
1782 return CMP_operator(this->current_operand, "__le_"); |
1854 return CMP_operator(this->current_operand, "LE_"); |
1783 ERROR; |
1855 ERROR; |
1784 return NULL; |
1856 return NULL; |
1785 } |
1857 } |
1786 |
1858 |
1787 void *visit(NE_operator_c *symbol) { |
1859 void *visit(NE_operator_c *symbol) { |
1788 if (search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) |
1860 if (search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) |
1789 return CMP_operator(this->current_operand, "__ne_"); |
1861 return CMP_operator(this->current_operand, "NE_"); |
1790 ERROR; |
1862 ERROR; |
1791 return NULL; |
1863 return NULL; |
1792 } |
1864 } |
1793 |
1865 |
1794 |
1866 |