1014 } |
1014 } |
1015 |
1015 |
1016 |
1016 |
1017 void *print_datatypes_error_c::visit(function_invocation_c *symbol) { |
1017 void *print_datatypes_error_c::visit(function_invocation_c *symbol) { |
1018 list_c *parameter_list; |
1018 list_c *parameter_list; |
1019 function_declaration_c * f_decl; |
1019 |
1020 |
|
1021 if (NULL != symbol->datatype) return NULL; |
|
1022 if (NULL != symbol->formal_param_list) |
1020 if (NULL != symbol->formal_param_list) |
1023 parameter_list = (list_c *)symbol->formal_param_list; |
1021 parameter_list = (list_c *)symbol->formal_param_list; |
1024 else if (NULL != symbol->nonformal_param_list) |
1022 else if (NULL != symbol->nonformal_param_list) |
1025 parameter_list = (list_c *)symbol->nonformal_param_list; |
1023 parameter_list = (list_c *)symbol->nonformal_param_list; |
1026 else ERROR; |
1024 else ERROR; |
|
1025 |
1027 parameter_list->accept(*this); |
1026 parameter_list->accept(*this); |
1028 if (symbol->candidate_datatypes.size() == 0) { |
1027 |
1029 identifier_c *fname = (identifier_c *)symbol->function_name; |
1028 if (symbol->candidate_datatypes.size() == 0) { |
1030 f_decl = (function_declaration_c *)symbol->called_function_declaration; |
1029 /* No compatible function exists */ |
1031 /* |
1030 STAGE3_ERROR(symbol, symbol, "Invalid parameters in function invocation: %s\n", ((identifier_c *)symbol->function_name)->value); |
1032 * Manuele: In the future we have to test parameter number |
1031 } |
1033 * and show a specific message. |
1032 #if 0 |
1034 */ |
1033 else |
1035 STAGE3_ERROR(symbol, symbol, "No matching overloaded '%s' function call.", fname->value); |
1034 if (NULL == symbol->datatype) { |
1036 } |
1035 /* One or compatible functions exists, but none chosen! */ |
|
1036 STAGE3_ERROR(symbol, symbol, "Invalid parameters in function invocation: %s\n", f_name->value); |
|
1037 } |
|
1038 #endif |
|
1039 |
1037 return NULL; |
1040 return NULL; |
1038 } |
1041 } |
1039 |
1042 |
1040 /********************/ |
1043 /********************/ |
1041 /* B 3.2 Statements */ |
1044 /* B 3.2 Statements */ |
1052 (symbol->l_exp->candidate_datatypes.size() > 0) && |
1055 (symbol->l_exp->candidate_datatypes.size() > 0) && |
1053 (symbol->r_exp->candidate_datatypes.size() > 0)) |
1056 (symbol->r_exp->candidate_datatypes.size() > 0)) |
1054 STAGE3_ERROR(symbol, symbol, "Invalid data types for ':=' operation."); |
1057 STAGE3_ERROR(symbol, symbol, "Invalid data types for ':=' operation."); |
1055 return NULL; |
1058 return NULL; |
1056 } |
1059 } |
|
1060 |
|
1061 |
|
1062 /*****************************************/ |
|
1063 /* B 3.2.2 Subprogram Control Statements */ |
|
1064 /*****************************************/ |
|
1065 /* fb_name '(' [param_assignment_list] ')' */ |
|
1066 /* formal_param_list -> may be NULL ! */ |
|
1067 /* nonformal_param_list -> may be NULL ! */ |
|
1068 /* NOTES: |
|
1069 * The parameter 'called_fb_declaration'... |
|
1070 * ...is used to pass data between two passes of stage 3. |
|
1071 * (actually set in fill_candidate_datatypes_c, and used in narrow_candidate_datatypes_c and print_datatypes_error_c). |
|
1072 * This allows fill_candidate_datatypes_c to figure out whether it is a valid FB call, |
|
1073 * and let the other classes handle it aproproately. |
|
1074 * It could also be used in stage 4, if required. |
|
1075 */ |
|
1076 // SYM_REF3(fb_invocation_c, fb_name, formal_param_list, nonformal_param_list, symbol_c *called_fb_declaration;) |
|
1077 void *print_datatypes_error_c::visit(fb_invocation_c *symbol) { |
|
1078 list_c *parameter_list; |
|
1079 |
|
1080 if (NULL != symbol->formal_param_list) |
|
1081 parameter_list = (list_c *)symbol->formal_param_list; |
|
1082 else if (NULL != symbol->nonformal_param_list) |
|
1083 parameter_list = (list_c *)symbol->nonformal_param_list; |
|
1084 else ERROR; |
|
1085 |
|
1086 parameter_list->accept(*this); |
|
1087 |
|
1088 if (NULL == symbol->called_fb_declaration) { |
|
1089 /* Invalid parameters for FB call! */ |
|
1090 STAGE3_ERROR(symbol, symbol, "Invalid parameters in FB invocation: %s\n", ((identifier_c *)symbol->fb_name)->value); |
|
1091 } |
|
1092 |
|
1093 return NULL; |
|
1094 } |
|
1095 |
1057 |
1096 |
1058 /********************************/ |
1097 /********************************/ |
1059 /* B 3.2.3 Selection Statements */ |
1098 /* B 3.2.3 Selection Statements */ |
1060 /********************************/ |
1099 /********************************/ |
1061 |
1100 |