930 |
928 |
931 /*******************/ |
929 /*******************/ |
932 /* B 2.2 Operators */ |
930 /* B 2.2 Operators */ |
933 /*******************/ |
931 /*******************/ |
934 void *print_datatypes_error_c::print_binary_operator_errors(const char *il_operator, symbol_c *symbol, bool deprecated_operation) { |
932 void *print_datatypes_error_c::print_binary_operator_errors(const char *il_operator, symbol_c *symbol, bool deprecated_operation) { |
935 if ((symbol->candidate_datatypes.size() == 0) && (il_operand->candidate_datatypes.size() > 0)) { |
933 if (NULL == il_operand) { |
936 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for '%s' operator.", il_operator); |
934 STAGE3_ERROR(0, symbol, symbol, "Missing operand for %s operator.", il_operator); // message (a) |
937 } else if (NULL == symbol->datatype) { |
935 } else if ((symbol->candidate_datatypes.size() == 0) && (il_operand->candidate_datatypes.size() > 0)) { |
938 STAGE3_WARNING(symbol, symbol, "Result of '%s' operation is never used.", il_operator); |
936 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for '%s' operator.", il_operator); // message (b) |
|
937 } else if (NULL == symbol->datatype) { |
|
938 STAGE3_WARNING(symbol, symbol, "Result of '%s' operation is never used.", il_operator); // message (c) |
939 } else if (deprecated_operation) |
939 } else if (deprecated_operation) |
940 STAGE3_WARNING(symbol, symbol, "Deprecated operation for '%s' operator.", il_operator); |
940 STAGE3_WARNING(symbol, symbol, "Deprecated operation for '%s' operator.", il_operator); // message (d) |
941 return NULL; |
941 return NULL; |
942 } |
942 } |
943 |
943 |
944 |
944 |
945 void *print_datatypes_error_c::visit(LD_operator_c *symbol) { |
945 void *print_datatypes_error_c::visit( LD_operator_c *symbol) {return print_binary_operator_errors("LD" , symbol);} // I believe it will never emit messages (b) and (c)!! |
946 return NULL; |
946 void *print_datatypes_error_c::visit( LDN_operator_c *symbol) {return print_binary_operator_errors("LDN" , symbol);} // I believe it will never emit message (c) |
947 } |
947 void *print_datatypes_error_c::visit( ST_operator_c *symbol) {return print_binary_operator_errors("ST" , symbol);} // I believe it will never emit message (c) |
948 |
948 void *print_datatypes_error_c::visit( STN_operator_c *symbol) {return print_binary_operator_errors("STN" , symbol);} // I believe it will never emit message (c) |
949 void *print_datatypes_error_c::visit(LDN_operator_c *symbol) { |
|
950 if ((symbol->candidate_datatypes.size() == 0) && |
|
951 (il_operand->candidate_datatypes.size() > 0)) |
|
952 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'LDN' operator."); |
|
953 return NULL; |
|
954 } |
|
955 |
|
956 void *print_datatypes_error_c::visit(ST_operator_c *symbol) { |
|
957 /* MANU: |
|
958 * if prev_instruction is NULL we can print a message error or warning error like: |
|
959 * we can't use a ST like first instruction. |
|
960 * What do you think? |
|
961 */ |
|
962 if ((symbol->candidate_datatypes.size() == 0) && |
|
963 (il_operand->candidate_datatypes.size() > 0)) |
|
964 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'ST' operator."); |
|
965 return NULL; |
|
966 } |
|
967 |
|
968 void *print_datatypes_error_c::visit(STN_operator_c *symbol) { |
|
969 /* MANU: |
|
970 * if prev_instruction is NULL we can print a message error or warning error like: |
|
971 * we can't use a ST like first instruction. |
|
972 * What do you think? |
|
973 */ |
|
974 if ((symbol->candidate_datatypes.size() == 0) && |
|
975 (il_operand->candidate_datatypes.size() > 0)) |
|
976 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'STN' operator."); |
|
977 return NULL; |
|
978 } |
|
979 |
949 |
980 void *print_datatypes_error_c::visit(NOT_operator_c *symbol) { |
950 void *print_datatypes_error_c::visit(NOT_operator_c *symbol) { |
981 /* NOTE: the standard allows syntax in which the NOT operator is followed by an optional <il_operand> |
951 /* NOTE: the standard allows syntax in which the NOT operator is followed by an optional <il_operand> |
982 * NOT [<il_operand>] |
952 * NOT [<il_operand>] |
983 * However, it does not define the semantic of the NOT operation when the <il_operand> is specified. |
953 * However, it does not define the semantic of the NOT operation when the <il_operand> is specified. |
984 * We therefore consider it an error if an il_operand is specified! |
954 * We therefore consider it an error if an il_operand is specified! |
985 */ |
955 */ |
986 if (il_operand != NULL) |
956 if (il_operand != NULL) { |
987 STAGE3_ERROR(0, symbol, symbol, "'NOT' operator may not have an operand."); |
957 STAGE3_ERROR(0, symbol, symbol, "'NOT' operator may not have an operand."); |
988 if (symbol->candidate_datatypes.size() == 0) |
958 } else if (symbol->candidate_datatypes.size() == 0) |
989 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'NOT' operator."); |
959 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'NOT' operator."); |
990 return NULL; |
960 return NULL; |
991 } |
961 } |
992 |
962 |
993 void *print_datatypes_error_c::visit(S_operator_c *symbol) { |
963 void *print_datatypes_error_c::visit(S_operator_c *symbol) { |
994 /* TODO: what if this is a FB call ?? */ |
964 if (NULL != symbol->called_fb_declaration) /* FB call semantics */ return handle_implicit_il_fb_invocation("S", symbol, symbol->called_fb_declaration); |
995 if ((symbol->candidate_datatypes.size() == 0) && |
965 else /* Reset semantics */ return print_binary_operator_errors ("S", symbol); |
996 (il_operand->candidate_datatypes.size() > 0)) |
|
997 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'S' operator."); |
|
998 return NULL; |
|
999 } |
966 } |
1000 |
967 |
1001 void *print_datatypes_error_c::visit(R_operator_c *symbol) { |
968 void *print_datatypes_error_c::visit(R_operator_c *symbol) { |
1002 /* TODO: what if this is a FB call ?? */ |
969 if (NULL != symbol->called_fb_declaration) /* FB call semantics */ return handle_implicit_il_fb_invocation("R", symbol, symbol->called_fb_declaration); |
1003 if ((symbol->candidate_datatypes.size() == 0) && |
970 else /* Reset semantics */ return print_binary_operator_errors ("R", symbol); |
1004 (il_operand->candidate_datatypes.size() > 0)) |
|
1005 STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'R' operator."); |
|
1006 return NULL; |
|
1007 } |
971 } |
1008 |
972 |
1009 void *print_datatypes_error_c::visit( S1_operator_c *symbol) {return handle_implicit_il_fb_invocation( "S1", symbol, symbol->called_fb_declaration);} |
973 void *print_datatypes_error_c::visit( S1_operator_c *symbol) {return handle_implicit_il_fb_invocation( "S1", symbol, symbol->called_fb_declaration);} |
1010 void *print_datatypes_error_c::visit( R1_operator_c *symbol) {return handle_implicit_il_fb_invocation( "R1", symbol, symbol->called_fb_declaration);} |
974 void *print_datatypes_error_c::visit( R1_operator_c *symbol) {return handle_implicit_il_fb_invocation( "R1", symbol, symbol->called_fb_declaration);} |
1011 void *print_datatypes_error_c::visit(CLK_operator_c *symbol) {return handle_implicit_il_fb_invocation("CLK", symbol, symbol->called_fb_declaration);} |
975 void *print_datatypes_error_c::visit(CLK_operator_c *symbol) {return handle_implicit_il_fb_invocation("CLK", symbol, symbol->called_fb_declaration);} |