122 return (symbol_c *)symbol->accept(search_base_type); |
122 return (symbol_c *)symbol->accept(search_base_type); |
123 } |
123 } |
124 |
124 |
125 |
125 |
126 |
126 |
127 |
|
128 void print_datatypes_error_c::check_used_operation_status(symbol_c *symbol, symbol_c *left, symbol_c *right, const struct widen_entry widen_table[]) { |
|
129 /* find a compatible entry in the widening table */ |
|
130 for (int k = 0; NULL != widen_table[k].left; k++) |
|
131 if (is_type_equal(left, widen_table[k].left) && is_type_equal(right, widen_table[k].right)) |
|
132 if (widen_entry::deprecated == widen_table[k].status) |
|
133 STAGE3_WARNING(symbol, symbol, "Deprecated operation."); |
|
134 } |
|
135 |
|
136 |
|
137 /* |
127 /* |
138 typedef struct { |
128 typedef struct { |
139 symbol_c *function_name, |
129 symbol_c *function_name, |
140 symbol_c *nonformal_operand_list, |
130 symbol_c *nonformal_operand_list, |
141 symbol_c * formal_operand_list, |
131 symbol_c * formal_operand_list, |
971 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'ORN' operator."); |
961 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'ORN' operator."); |
972 return NULL; |
962 return NULL; |
973 } |
963 } |
974 |
964 |
975 void *print_datatypes_error_c::visit(ADD_operator_c *symbol) { |
965 void *print_datatypes_error_c::visit(ADD_operator_c *symbol) { |
976 /* TODO: print warning messages for deprecated operations! */ |
|
977 if ((symbol->candidate_datatypes.size() == 0) && |
966 if ((symbol->candidate_datatypes.size() == 0) && |
978 (il_operand->candidate_datatypes.size() > 0)) |
967 (il_operand->candidate_datatypes.size() > 0)) |
979 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'ADD' operator."); |
968 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'ADD' operator."); |
|
969 if (symbol->deprecated_operation) |
|
970 STAGE3_WARNING(symbol, symbol, "Deprecated operation for 'ADD' operator."); |
980 return NULL; |
971 return NULL; |
981 } |
972 } |
982 |
973 |
983 void *print_datatypes_error_c::visit(SUB_operator_c *symbol) { |
974 void *print_datatypes_error_c::visit(SUB_operator_c *symbol) { |
984 /* TODO: print warning messages for deprecated operations! */ |
|
985 if ((symbol->candidate_datatypes.size() == 0) && |
975 if ((symbol->candidate_datatypes.size() == 0) && |
986 (il_operand->candidate_datatypes.size() > 0)) |
976 (il_operand->candidate_datatypes.size() > 0)) |
987 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'SUB' operator."); |
977 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'SUB' operator."); |
|
978 if (symbol->deprecated_operation) |
|
979 STAGE3_WARNING(symbol, symbol, "Deprecated operation for 'SUB' operator."); |
988 return NULL; |
980 return NULL; |
989 } |
981 } |
990 |
982 |
991 void *print_datatypes_error_c::visit(MUL_operator_c *symbol) { |
983 void *print_datatypes_error_c::visit(MUL_operator_c *symbol) { |
992 /* TODO: print warning messages for deprecated operations! */ |
|
993 if ((symbol->candidate_datatypes.size() == 0) && |
984 if ((symbol->candidate_datatypes.size() == 0) && |
994 (il_operand->candidate_datatypes.size() > 0)) |
985 (il_operand->candidate_datatypes.size() > 0)) |
995 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'MUL' operator."); |
986 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'MUL' operator."); |
|
987 if (symbol->deprecated_operation) |
|
988 STAGE3_WARNING(symbol, symbol, "Deprecated operation for 'MUL' operator."); |
996 return NULL; |
989 return NULL; |
997 } |
990 } |
998 |
991 |
999 void *print_datatypes_error_c::visit(DIV_operator_c *symbol) { |
992 void *print_datatypes_error_c::visit(DIV_operator_c *symbol) { |
1000 /* TODO: print warning messages for deprecated operations! */ |
|
1001 if ((symbol->candidate_datatypes.size() == 0) && |
993 if ((symbol->candidate_datatypes.size() == 0) && |
1002 (il_operand->candidate_datatypes.size() > 0)) |
994 (il_operand->candidate_datatypes.size() > 0)) |
1003 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'DIV' operator."); |
995 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'DIV' operator."); |
|
996 if (symbol->deprecated_operation) |
|
997 STAGE3_WARNING(symbol, symbol, "Deprecated operation for 'DIV' operator."); |
1004 return NULL; |
998 return NULL; |
1005 } |
999 } |
1006 |
1000 |
1007 void *print_datatypes_error_c::visit(MOD_operator_c *symbol) { |
1001 void *print_datatypes_error_c::visit(MOD_operator_c *symbol) { |
1008 if ((symbol->candidate_datatypes.size() == 0) && |
1002 if ((symbol->candidate_datatypes.size() == 0) && |
1194 symbol->r_exp->accept(*this); |
1188 symbol->r_exp->accept(*this); |
1195 if ((symbol->candidate_datatypes.size() == 0) && |
1189 if ((symbol->candidate_datatypes.size() == 0) && |
1196 (symbol->l_exp->candidate_datatypes.size() > 0) && |
1190 (symbol->l_exp->candidate_datatypes.size() > 0) && |
1197 (symbol->r_exp->candidate_datatypes.size() > 0)) |
1191 (symbol->r_exp->candidate_datatypes.size() > 0)) |
1198 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for '+' expression."); |
1192 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for '+' expression."); |
1199 |
1193 if (symbol->deprecated_operation) |
1200 check_used_operation_status(symbol, symbol->l_exp->datatype,symbol->r_exp->datatype, widen_ADD_table); |
1194 STAGE3_WARNING(symbol, symbol, "Deprecated operation for '+' expression."); |
1201 return NULL; |
1195 return NULL; |
1202 } |
1196 } |
1203 |
1197 |
1204 |
1198 |
1205 |
1199 |
1207 symbol->l_exp->accept(*this); |
1201 symbol->l_exp->accept(*this); |
1208 symbol->r_exp->accept(*this); |
1202 symbol->r_exp->accept(*this); |
1209 if ((symbol->candidate_datatypes.size() == 0) && |
1203 if ((symbol->candidate_datatypes.size() == 0) && |
1210 (symbol->l_exp->candidate_datatypes.size() > 0) && |
1204 (symbol->l_exp->candidate_datatypes.size() > 0) && |
1211 (symbol->r_exp->candidate_datatypes.size() > 0)) |
1205 (symbol->r_exp->candidate_datatypes.size() > 0)) |
1212 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for '-' expression."); |
1206 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for '-' expression."); |
1213 check_used_operation_status(symbol, symbol->l_exp->datatype,symbol->r_exp->datatype, widen_SUB_table); |
1207 if (symbol->deprecated_operation) |
|
1208 STAGE3_WARNING(symbol, symbol, "Deprecated operation for '-' expression."); |
1214 return NULL; |
1209 return NULL; |
1215 } |
1210 } |
1216 |
1211 |
1217 void *print_datatypes_error_c::visit(mul_expression_c *symbol) { |
1212 void *print_datatypes_error_c::visit(mul_expression_c *symbol) { |
1218 symbol->l_exp->accept(*this); |
1213 symbol->l_exp->accept(*this); |
1219 symbol->r_exp->accept(*this); |
1214 symbol->r_exp->accept(*this); |
1220 if ((symbol->candidate_datatypes.size() == 0) && |
1215 if ((symbol->candidate_datatypes.size() == 0) && |
1221 (symbol->l_exp->candidate_datatypes.size() > 0) && |
1216 (symbol->l_exp->candidate_datatypes.size() > 0) && |
1222 (symbol->r_exp->candidate_datatypes.size() > 0)) |
1217 (symbol->r_exp->candidate_datatypes.size() > 0)) |
1223 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for '*' expression."); |
1218 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for '*' expression."); |
1224 check_used_operation_status(symbol, symbol->l_exp->datatype,symbol->r_exp->datatype, widen_MUL_table); |
1219 if (symbol->deprecated_operation) |
|
1220 STAGE3_WARNING(symbol, symbol, "Deprecated operation for '*' expression."); |
1225 return NULL; |
1221 return NULL; |
1226 } |
1222 } |
1227 |
1223 |
1228 void *print_datatypes_error_c::visit(div_expression_c *symbol) { |
1224 void *print_datatypes_error_c::visit(div_expression_c *symbol) { |
1229 symbol->l_exp->accept(*this); |
1225 symbol->l_exp->accept(*this); |
1230 symbol->r_exp->accept(*this); |
1226 symbol->r_exp->accept(*this); |
1231 if ((symbol->candidate_datatypes.size() == 0) && |
1227 if ((symbol->candidate_datatypes.size() == 0) && |
1232 (symbol->l_exp->candidate_datatypes.size() > 0) && |
1228 (symbol->l_exp->candidate_datatypes.size() > 0) && |
1233 (symbol->r_exp->candidate_datatypes.size() > 0)) |
1229 (symbol->r_exp->candidate_datatypes.size() > 0)) |
1234 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for '/' expression."); |
1230 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for '/' expression."); |
1235 check_used_operation_status(symbol, symbol->l_exp->datatype,symbol->r_exp->datatype, widen_DIV_table); |
1231 if (symbol->deprecated_operation) |
|
1232 STAGE3_WARNING(symbol, symbol, "Deprecated operation for '/' expression."); |
1236 return NULL; |
1233 return NULL; |
1237 } |
1234 } |
1238 |
1235 |
1239 |
1236 |
1240 void *print_datatypes_error_c::visit(mod_expression_c *symbol) { |
1237 void *print_datatypes_error_c::visit(mod_expression_c *symbol) { |