Clean code for comparison operations & operators.
--- a/stage3/datatype_functions.cc Wed Mar 14 10:51:49 2012 +0000
+++ b/stage3/datatype_functions.cc Wed Mar 14 11:14:41 2012 +0000
@@ -52,7 +52,7 @@
#define __ANY(DO) __ANY_DERIVED(DO) __ANY_ELEMENTARY(DO)
#define __ANY_DERIVED(DO)
#define __ANY_ELEMENTARY(DO) __ANY_MAGNITUDE(DO) __ANY_BIT(DO) __ANY_STRING(DO) __ANY_DATE(DO)
-#define __ANY_MAGNITUDE(DO) __ANY_NUM(DO) DO(TIME)
+#define __ANY_MAGNITUDE(DO) __ANY_NUM(DO) DO(time)
#define __ANY_BIT(DO) __ANY_NBIT(DO) DO(bool)
#define __ANY_NBIT(DO) DO(byte) DO(word) DO(dword) DO(lword)
//#define __ANY_STRING(DO) DO(string) DO(wstring)
@@ -67,8 +67,8 @@
#define __ANY_1(DO,P1) __ANY_DERIVED_1(DO,P1) __ANY_ELEMENTARY_1(DO,P1)
#define __ANY_DERIVED_1(DO,P1)
#define __ANY_ELEMENTARY_1(DO,P1) __ANY_MAGNITUDE_1(DO,P1) __ANY_BIT_1(DO,P1) __ANY_STRING_1(DO,P1) __ANY_DATE_1(DO,P1)
-#define __ANY_MAGNITUDE_1(DO,P1) __ANY_NUM_1(DO,P1) DO(TIME,P1)
-#define __ANY_BIT_1(DO,P1) __ANY_NBIT_1(DO,P1) DO(BOOL,P1)
+#define __ANY_MAGNITUDE_1(DO,P1) __ANY_NUM_1(DO,P1) DO(time,P1)
+#define __ANY_BIT_1(DO,P1) __ANY_NBIT_1(DO,P1) DO(bool,P1)
#define __ANY_NBIT_1(DO,P1) DO(byte,P1) DO(word,P1) DO(dword,P1) DO(lword,P1)
// #define __ANY_STRING_1(DO,P1) DO(string,P1) DO(wstring,P1)
#define __ANY_STRING_1(DO,P1) DO(string,P1)
@@ -345,6 +345,27 @@
{ NULL, NULL, NULL, widen_entry::ok },
};
+/**************************************************************/
+/**************************************************************/
+/**************************************************************/
+/******* *******/
+/******* TABLE 28: Standard comparison functions *******/
+/******* *******/
+/**************************************************************/
+/**************************************************************/
+/**************************************************************/
+/* table used by GT, GE, EQ, LE, LT, and NE operators, and equivalent ST expressions. */
+const struct widen_entry widen_CMP_table[] = {
+#define __cmp(TYPE) \
+ { &search_constant_type_c::TYPE##_type_name, &search_constant_type_c::TYPE##_type_name, &search_constant_type_c::bool_type_name, widen_entry::ok }, \
+ { &search_constant_type_c::safe##TYPE##_type_name, &search_constant_type_c::TYPE##_type_name, &search_constant_type_c::bool_type_name, widen_entry::ok }, \
+ { &search_constant_type_c::TYPE##_type_name, &search_constant_type_c::safe##TYPE##_type_name, &search_constant_type_c::bool_type_name, widen_entry::ok }, \
+ { &search_constant_type_c::safe##TYPE##_type_name, &search_constant_type_c::safe##TYPE##_type_name, &search_constant_type_c::safebool_type_name, widen_entry::ok },
+ __ANY_ELEMENTARY(__cmp)
+#undef __cmp
+
+ { NULL, NULL, NULL, widen_entry::ok },
+};
/* Search for a datatype inside a candidate_datatypes list.
--- a/stage3/datatype_functions.hh Wed Mar 14 10:51:49 2012 +0000
+++ b/stage3/datatype_functions.hh Wed Mar 14 11:14:41 2012 +0000
@@ -136,6 +136,7 @@
extern const struct widen_entry widen_AND_table[];
extern const struct widen_entry widen_OR_table[];
extern const struct widen_entry widen_XOR_table[];
+extern const struct widen_entry widen_CMP_table[];
/* Search for a datatype inside a candidate_datatypes list.
* Returns: position of datatype in the list, or -1 if not found.
--- a/stage3/fill_candidate_datatypes.cc Wed Mar 14 10:51:49 2012 +0000
+++ b/stage3/fill_candidate_datatypes.cc Wed Mar 14 11:14:41 2012 +0000
@@ -1119,109 +1119,14 @@
void *fill_candidate_datatypes_c::visit(DIV_operator_c *symbol) {return handle_binary_operator(widen_DIV_table, symbol, prev_il_instruction, il_operand);}
void *fill_candidate_datatypes_c::visit(MOD_operator_c *symbol) {return handle_binary_operator(widen_MOD_table, symbol, prev_il_instruction, il_operand);}
-
-
-void *fill_candidate_datatypes_c::visit(GT_operator_c *symbol) {
- bool found = false;
-
- if (NULL == prev_il_instruction) return NULL;
- for(unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
- for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
- if (is_type_equal(prev_il_instruction->candidate_datatypes[i], il_operand->candidate_datatypes[j])
- && is_ANY_ELEMENTARY_compatible(prev_il_instruction->candidate_datatypes[i])) {
- found = true;
- break;
- }
- }
- }
- if (found) add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
- return NULL;
-}
-
-void *fill_candidate_datatypes_c::visit(GE_operator_c *symbol) {
- bool found = false;
-
- if (NULL == prev_il_instruction) return NULL;
- for(unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
- for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
- if (is_type_equal(prev_il_instruction->candidate_datatypes[i], il_operand->candidate_datatypes[j])
- && is_ANY_ELEMENTARY_compatible(prev_il_instruction->candidate_datatypes[i])) {
- found = true;
- break;
- }
- }
- }
- if (found) add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
- return NULL;
-}
-
-void *fill_candidate_datatypes_c::visit(EQ_operator_c *symbol) {
- bool found = false;
-
- if (NULL == prev_il_instruction) return NULL;
- for(unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
- for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
- if (is_type_equal(prev_il_instruction->candidate_datatypes[i], il_operand->candidate_datatypes[j])
- && is_ANY_ELEMENTARY_compatible(prev_il_instruction->candidate_datatypes[i])) {
- found = true;
- break;
- }
- }
- }
- if (found) add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
- return NULL;
-}
-
-void *fill_candidate_datatypes_c::visit(LT_operator_c *symbol) {
- bool found = false;
-
- if (NULL == prev_il_instruction) return NULL;
- for(unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
- for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
- if (is_type_equal(prev_il_instruction->candidate_datatypes[i], il_operand->candidate_datatypes[j])
- && is_ANY_ELEMENTARY_compatible(prev_il_instruction->candidate_datatypes[i])) {
- found = true;
- break;
- }
- }
- }
- if (found) add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
- return NULL;
-}
-
-void *fill_candidate_datatypes_c::visit(LE_operator_c *symbol) {
- bool found = false;
-
- if (NULL == prev_il_instruction) return NULL;
- for(unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
- for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
- if (is_type_equal(prev_il_instruction->candidate_datatypes[i], il_operand->candidate_datatypes[j])
- && is_ANY_ELEMENTARY_compatible(prev_il_instruction->candidate_datatypes[i])) {
- found = true;
- break;
- }
- }
- }
- if (found) add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
- return NULL;
-}
-
-void *fill_candidate_datatypes_c::visit(NE_operator_c *symbol) {
- bool found = false;
-
- if (NULL == prev_il_instruction) return NULL;
- for(unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) {
- for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) {
- if (is_type_equal(prev_il_instruction->candidate_datatypes[i], il_operand->candidate_datatypes[j])
- && is_ANY_ELEMENTARY_compatible(prev_il_instruction->candidate_datatypes[i])) {
- found = true;
- break;
- }
- }
- }
- if (found) add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
- return NULL;
-}
+void *fill_candidate_datatypes_c::visit( GT_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);}
+void *fill_candidate_datatypes_c::visit( GE_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);}
+void *fill_candidate_datatypes_c::visit( EQ_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);}
+void *fill_candidate_datatypes_c::visit( LT_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);}
+void *fill_candidate_datatypes_c::visit( LE_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);}
+void *fill_candidate_datatypes_c::visit( NE_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);}
+
+
void *fill_candidate_datatypes_c::visit(CAL_operator_c *symbol) {
if (NULL == prev_il_instruction) return NULL;
@@ -1321,126 +1226,16 @@
/***********************/
/* B 3.1 - Expressions */
/***********************/
-void *fill_candidate_datatypes_c::visit(or_expression_c *symbol) {return handle_binary_expression(widen_OR_table, symbol, symbol->l_exp, symbol->r_exp);}
-void *fill_candidate_datatypes_c::visit(xor_expression_c *symbol) {return handle_binary_expression(widen_XOR_table, symbol, symbol->l_exp, symbol->r_exp);}
-void *fill_candidate_datatypes_c::visit(and_expression_c *symbol) {return handle_binary_expression(widen_AND_table, symbol, symbol->l_exp, symbol->r_exp);}
-
-
-void *fill_candidate_datatypes_c::visit(equ_expression_c *symbol) {
- symbol->l_exp->accept(*this);
- symbol->r_exp->accept(*this);
- bool found = false;
-
- for (unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
- for (unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
- if (is_type_equal(symbol->l_exp->candidate_datatypes[i], symbol->r_exp->candidate_datatypes[j])
- && is_ANY_ELEMENTARY_compatible(symbol->l_exp->candidate_datatypes[i])) {
- found = true;
- break;
- }
- }
- }
- if (found) add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
- return NULL;
-}
-
-
-void *fill_candidate_datatypes_c::visit(notequ_expression_c *symbol) {
- symbol->l_exp->accept(*this);
- symbol->r_exp->accept(*this);
- bool found = false;
-
- for (unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
- for (unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
- if (is_type_equal(symbol->l_exp->candidate_datatypes[i], symbol->r_exp->candidate_datatypes[j])
- && is_ANY_ELEMENTARY_compatible(symbol->l_exp->candidate_datatypes[i])) {
- found = true;
- break;
- }
- }
- }
- if (found)
- add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
- return NULL;
-}
-
-
-void *fill_candidate_datatypes_c::visit(lt_expression_c *symbol) {
- symbol->l_exp->accept(*this);
- symbol->r_exp->accept(*this);
- bool found = false;
-
- for (unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
- for (unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
- if (is_type_equal(symbol->l_exp->candidate_datatypes[i], symbol->r_exp->candidate_datatypes[j])
- && is_ANY_ELEMENTARY_compatible(symbol->l_exp->candidate_datatypes[i])) {
- found = true;
- break;
- }
- }
- }
- if (found)
- add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
- return NULL;
-}
-
-
-void *fill_candidate_datatypes_c::visit(gt_expression_c *symbol) {
- symbol->l_exp->accept(*this);
- symbol->r_exp->accept(*this);
- bool found = false;
-
- for (unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
- for (unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
- if (is_type_equal(symbol->l_exp->candidate_datatypes[i], symbol->r_exp->candidate_datatypes[j])
- && is_ANY_ELEMENTARY_compatible(symbol->l_exp->candidate_datatypes[i])) {
- found = true;
- break;
- }
- }
- }
- if (found)
- add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
- return NULL;
-}
-
-void *fill_candidate_datatypes_c::visit(le_expression_c *symbol) {
- symbol->l_exp->accept(*this);
- symbol->r_exp->accept(*this);
- bool found = false;
-
- for (unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
- for (unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
- if (is_type_equal(symbol->l_exp->candidate_datatypes[i], symbol->r_exp->candidate_datatypes[j])
- && is_ANY_ELEMENTARY_compatible(symbol->l_exp->candidate_datatypes[i])) {
- found = true;
- break;
- }
- }
- }
- if (found)
- add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
- return NULL;
-}
-
-void *fill_candidate_datatypes_c::visit(ge_expression_c *symbol) {
- symbol->l_exp->accept(*this);
- symbol->r_exp->accept(*this);
- bool found = false;
-
- for (unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
- for (unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
- if (is_type_equal(symbol->l_exp->candidate_datatypes[i], symbol->r_exp->candidate_datatypes[j])
- && is_ANY_ELEMENTARY_compatible(symbol->l_exp->candidate_datatypes[i])) {
- found = true;
- break;
- }
- }
- }
- if (found)
- add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name);
- return NULL;
-}
+void *fill_candidate_datatypes_c::visit( or_expression_c *symbol) {return handle_binary_expression(widen_OR_table, symbol, symbol->l_exp, symbol->r_exp);}
+void *fill_candidate_datatypes_c::visit( xor_expression_c *symbol) {return handle_binary_expression(widen_XOR_table, symbol, symbol->l_exp, symbol->r_exp);}
+void *fill_candidate_datatypes_c::visit( and_expression_c *symbol) {return handle_binary_expression(widen_AND_table, symbol, symbol->l_exp, symbol->r_exp);}
+
+void *fill_candidate_datatypes_c::visit( equ_expression_c *symbol) {return handle_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);}
+void *fill_candidate_datatypes_c::visit(notequ_expression_c *symbol) {return handle_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);}
+void *fill_candidate_datatypes_c::visit( lt_expression_c *symbol) {return handle_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);}
+void *fill_candidate_datatypes_c::visit( gt_expression_c *symbol) {return handle_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);}
+void *fill_candidate_datatypes_c::visit( le_expression_c *symbol) {return handle_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);}
+void *fill_candidate_datatypes_c::visit( ge_expression_c *symbol) {return handle_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);}
/* The following code is correct when handling the addition of 2 symbolic_variables
--- a/stage3/narrow_candidate_datatypes.cc Wed Mar 14 10:51:49 2012 +0000
+++ b/stage3/narrow_candidate_datatypes.cc Wed Mar 14 11:14:41 2012 +0000
@@ -910,7 +910,6 @@
void *narrow_candidate_datatypes_c::visit( IN_operator_c *symbol) {return narrow_implicit_il_fb_call(symbol, "IN", symbol->called_fb_declaration);}
void *narrow_candidate_datatypes_c::visit( PT_operator_c *symbol) {return narrow_implicit_il_fb_call(symbol, "PT", symbol->called_fb_declaration);}
-
void *narrow_candidate_datatypes_c::visit( AND_operator_c *symbol) {return narrow_binary_operator(widen_AND_table, symbol);}
void *narrow_candidate_datatypes_c::visit( OR_operator_c *symbol) {return narrow_binary_operator( widen_OR_table, symbol);}
void *narrow_candidate_datatypes_c::visit( XOR_operator_c *symbol) {return narrow_binary_operator(widen_XOR_table, symbol);}
@@ -922,12 +921,12 @@
void *narrow_candidate_datatypes_c::visit( MUL_operator_c *symbol) {return narrow_binary_operator(widen_MUL_table, symbol, &(symbol->deprecated_operation));}
void *narrow_candidate_datatypes_c::visit( DIV_operator_c *symbol) {return narrow_binary_operator(widen_DIV_table, symbol, &(symbol->deprecated_operation));}
void *narrow_candidate_datatypes_c::visit( MOD_operator_c *symbol) {return narrow_binary_operator(widen_MOD_table, symbol);}
-void *narrow_candidate_datatypes_c::visit( GT_operator_c *symbol) {return handle_il_instruction(symbol);}
-void *narrow_candidate_datatypes_c::visit( GE_operator_c *symbol) {return handle_il_instruction(symbol);}
-void *narrow_candidate_datatypes_c::visit( EQ_operator_c *symbol) {return handle_il_instruction(symbol);}
-void *narrow_candidate_datatypes_c::visit( LT_operator_c *symbol) {return handle_il_instruction(symbol);}
-void *narrow_candidate_datatypes_c::visit( LE_operator_c *symbol) {return handle_il_instruction(symbol);}
-void *narrow_candidate_datatypes_c::visit( NE_operator_c *symbol) {return handle_il_instruction(symbol);}
+void *narrow_candidate_datatypes_c::visit( GT_operator_c *symbol) {return narrow_binary_operator(widen_CMP_table, symbol);}
+void *narrow_candidate_datatypes_c::visit( GE_operator_c *symbol) {return narrow_binary_operator(widen_CMP_table, symbol);}
+void *narrow_candidate_datatypes_c::visit( EQ_operator_c *symbol) {return narrow_binary_operator(widen_CMP_table, symbol);}
+void *narrow_candidate_datatypes_c::visit( LT_operator_c *symbol) {return narrow_binary_operator(widen_CMP_table, symbol);}
+void *narrow_candidate_datatypes_c::visit( LE_operator_c *symbol) {return narrow_binary_operator(widen_CMP_table, symbol);}
+void *narrow_candidate_datatypes_c::visit( NE_operator_c *symbol) {return narrow_binary_operator(widen_CMP_table, symbol);}
// SYM_REF0(CAL_operator_c)
@@ -1037,170 +1036,22 @@
-void *narrow_candidate_datatypes_c::visit( or_expression_c *symbol) {return narrow_binary_expression( widen_OR_table, symbol, symbol->l_exp, symbol->r_exp);}
-void *narrow_candidate_datatypes_c::visit(xor_expression_c *symbol) {return narrow_binary_expression(widen_XOR_table, symbol, symbol->l_exp, symbol->r_exp);}
-void *narrow_candidate_datatypes_c::visit(and_expression_c *symbol) {return narrow_binary_expression(widen_AND_table, symbol, symbol->l_exp, symbol->r_exp);}
-
-
-void *narrow_candidate_datatypes_c::visit(equ_expression_c *symbol) {
- /* Here symbol->datatype has already assigned to BOOL
- * In conditional symbols like =, <>, =<, <, >, >= we have to set
- * l_exp and r_exp expression matched with compatible type.
- * Example:
- * INT#14 = INT#81
- * equ_expression_c symbol->datatype = BOOL from top visit
- * symbol->l_exp->datatype => INT
- * symbol->r_exp->datatype => INT
- */
- symbol_c * selected_type = NULL;
- for(unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
- for(unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
- if (typeid(*symbol->l_exp->candidate_datatypes[i]) == typeid(*symbol->r_exp->candidate_datatypes[j])) {
- /*
- * We do not need to check whether the type is an ANY_ELEMENTARY here.
- * That was already done in fill_candidate_datatypes_c.
- */
- selected_type = symbol->l_exp->candidate_datatypes[i];
- break;
- }
- }
- }
-
- if (NULL != selected_type) {
- symbol->l_exp->datatype = selected_type;
- symbol->r_exp->datatype = selected_type;
- }
- else
- ERROR;
-
- symbol->l_exp->accept(*this);
- symbol->r_exp->accept(*this);
- return NULL;
-}
-
-void *narrow_candidate_datatypes_c::visit(notequ_expression_c *symbol) {
- symbol_c * selected_type = NULL;
- for(unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
- for(unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
- if (typeid(*symbol->l_exp->candidate_datatypes[i]) == typeid(*symbol->r_exp->candidate_datatypes[j])) {
- selected_type = symbol->l_exp->candidate_datatypes[i];
- break;
- }
- }
- }
-
- if (NULL != selected_type) {
- symbol->l_exp->datatype = selected_type;
- symbol->l_exp->accept(*this);
- symbol->r_exp->datatype = selected_type;
- symbol->r_exp->accept(*this);
- }
- else
- ERROR;
- return NULL;
-}
-
-
-void *narrow_candidate_datatypes_c::visit(lt_expression_c *symbol) {
- symbol_c * selected_type = NULL;
- for(unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
- for(unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
- if (typeid(*symbol->l_exp->candidate_datatypes[i]) == typeid(*symbol->r_exp->candidate_datatypes[j])
- && is_ANY_ELEMENTARY_type(symbol->l_exp->candidate_datatypes[i])) {
- selected_type = symbol->l_exp->candidate_datatypes[i];
- break;
- }
- }
- }
-
- if (NULL != selected_type) {
- symbol->l_exp->datatype = selected_type;
- symbol->l_exp->accept(*this);
- symbol->r_exp->datatype = selected_type;
- symbol->r_exp->accept(*this);
- }
- else
- ERROR;
- return NULL;
-}
-
-
-void *narrow_candidate_datatypes_c::visit(gt_expression_c *symbol) {
- symbol_c * selected_type = NULL;
- for(unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
- for(unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
- if (typeid(*symbol->l_exp->candidate_datatypes[i]) == typeid(*symbol->r_exp->candidate_datatypes[j])
- && is_ANY_ELEMENTARY_type(symbol->l_exp->candidate_datatypes[i])) {
- selected_type = symbol->l_exp->candidate_datatypes[i];
- break;
- }
- }
- }
-
- if (NULL != selected_type) {
- symbol->l_exp->datatype = selected_type;
- symbol->l_exp->accept(*this);
- symbol->r_exp->datatype = selected_type;
- symbol->r_exp->accept(*this);
- }
- else
- ERROR;
- return NULL;
-}
-
-
-void *narrow_candidate_datatypes_c::visit(le_expression_c *symbol) {
- symbol_c * selected_type = NULL;
- for(unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
- for(unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
- if (typeid(*symbol->l_exp->candidate_datatypes[i]) == typeid(*symbol->r_exp->candidate_datatypes[j])
- && is_ANY_ELEMENTARY_type(symbol->l_exp->candidate_datatypes[i])) {
- selected_type = symbol->l_exp->candidate_datatypes[i];
- break;
- }
- }
- }
-
- if (NULL != selected_type) {
- symbol->l_exp->datatype = selected_type;
- symbol->l_exp->accept(*this);
- symbol->r_exp->datatype = selected_type;
- symbol->r_exp->accept(*this);
- }
- else
- ERROR;
- return NULL;
-}
-
-
-void *narrow_candidate_datatypes_c::visit(ge_expression_c *symbol) {
- symbol_c * selected_type = NULL;
- for(unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) {
- for(unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) {
- if (typeid(*symbol->l_exp->candidate_datatypes[i]) == typeid(*symbol->r_exp->candidate_datatypes[j])
- && is_ANY_ELEMENTARY_type(symbol->l_exp->candidate_datatypes[i])) {
- selected_type = symbol->l_exp->candidate_datatypes[i];
- break;
- }
- }
- }
-
- if (NULL != selected_type) {
- symbol->l_exp->datatype = selected_type;
- symbol->l_exp->accept(*this);
- symbol->r_exp->datatype = selected_type;
- symbol->r_exp->accept(*this);
- }
- else
- ERROR;
- return NULL;
-}
-
-void *narrow_candidate_datatypes_c::visit(add_expression_c *symbol) {return narrow_binary_expression(widen_ADD_table, symbol, symbol->l_exp, symbol->r_exp, &symbol->deprecated_operation);}
-void *narrow_candidate_datatypes_c::visit(sub_expression_c *symbol) {return narrow_binary_expression(widen_SUB_table, symbol, symbol->l_exp, symbol->r_exp, &symbol->deprecated_operation);}
-void *narrow_candidate_datatypes_c::visit(mul_expression_c *symbol) {return narrow_binary_expression(widen_MUL_table, symbol, symbol->l_exp, symbol->r_exp, &symbol->deprecated_operation);}
-void *narrow_candidate_datatypes_c::visit(div_expression_c *symbol) {return narrow_binary_expression(widen_DIV_table, symbol, symbol->l_exp, symbol->r_exp, &symbol->deprecated_operation);}
-void *narrow_candidate_datatypes_c::visit(mod_expression_c *symbol) {return narrow_binary_expression(widen_MOD_table, symbol, symbol->l_exp, symbol->r_exp);}
+void *narrow_candidate_datatypes_c::visit( or_expression_c *symbol) {return narrow_binary_expression( widen_OR_table, symbol, symbol->l_exp, symbol->r_exp);}
+void *narrow_candidate_datatypes_c::visit( xor_expression_c *symbol) {return narrow_binary_expression(widen_XOR_table, symbol, symbol->l_exp, symbol->r_exp);}
+void *narrow_candidate_datatypes_c::visit( and_expression_c *symbol) {return narrow_binary_expression(widen_AND_table, symbol, symbol->l_exp, symbol->r_exp);}
+
+void *narrow_candidate_datatypes_c::visit( equ_expression_c *symbol) {return narrow_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);}
+void *narrow_candidate_datatypes_c::visit(notequ_expression_c *symbol) {return narrow_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);}
+void *narrow_candidate_datatypes_c::visit( lt_expression_c *symbol) {return narrow_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);}
+void *narrow_candidate_datatypes_c::visit( gt_expression_c *symbol) {return narrow_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);}
+void *narrow_candidate_datatypes_c::visit( le_expression_c *symbol) {return narrow_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);}
+void *narrow_candidate_datatypes_c::visit( ge_expression_c *symbol) {return narrow_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);}
+
+void *narrow_candidate_datatypes_c::visit( add_expression_c *symbol) {return narrow_binary_expression(widen_ADD_table, symbol, symbol->l_exp, symbol->r_exp, &symbol->deprecated_operation);}
+void *narrow_candidate_datatypes_c::visit( sub_expression_c *symbol) {return narrow_binary_expression(widen_SUB_table, symbol, symbol->l_exp, symbol->r_exp, &symbol->deprecated_operation);}
+void *narrow_candidate_datatypes_c::visit( mul_expression_c *symbol) {return narrow_binary_expression(widen_MUL_table, symbol, symbol->l_exp, symbol->r_exp, &symbol->deprecated_operation);}
+void *narrow_candidate_datatypes_c::visit( div_expression_c *symbol) {return narrow_binary_expression(widen_DIV_table, symbol, symbol->l_exp, symbol->r_exp, &symbol->deprecated_operation);}
+void *narrow_candidate_datatypes_c::visit( mod_expression_c *symbol) {return narrow_binary_expression(widen_MOD_table, symbol, symbol->l_exp, symbol->r_exp);}
--- a/stage3/print_datatypes_error.cc Wed Mar 14 10:51:49 2012 +0000
+++ b/stage3/print_datatypes_error.cc Wed Mar 14 11:14:41 2012 +0000
@@ -912,30 +912,14 @@
void *print_datatypes_error_c::visit( DIV_operator_c *symbol) {return print_binary_operator_errors("DIV" , symbol, symbol->deprecated_operation);}
void *print_datatypes_error_c::visit( MOD_operator_c *symbol) {return print_binary_operator_errors("MOD" , symbol);}
-void *print_datatypes_error_c::visit(GT_operator_c *symbol) {
- return NULL;
-}
-
-void *print_datatypes_error_c::visit(GE_operator_c *symbol) {
- return NULL;
-}
-
-void *print_datatypes_error_c::visit(EQ_operator_c *symbol) {
- return NULL;
-}
-
-void *print_datatypes_error_c::visit(LT_operator_c *symbol) {
- return NULL;
-}
-
-void *print_datatypes_error_c::visit(LE_operator_c *symbol) {
- return NULL;
-}
-
-void *print_datatypes_error_c::visit(NE_operator_c *symbol) {
- return NULL;
-}
-
+void *print_datatypes_error_c::visit( GT_operator_c *symbol) {return print_binary_operator_errors( "GT" , symbol);}
+void *print_datatypes_error_c::visit( GE_operator_c *symbol) {return print_binary_operator_errors( "GE" , symbol);}
+void *print_datatypes_error_c::visit( EQ_operator_c *symbol) {return print_binary_operator_errors( "EQ" , symbol);}
+void *print_datatypes_error_c::visit( LT_operator_c *symbol) {return print_binary_operator_errors( "LT" , symbol);}
+void *print_datatypes_error_c::visit( LE_operator_c *symbol) {return print_binary_operator_errors( "LE" , symbol);}
+void *print_datatypes_error_c::visit( NE_operator_c *symbol) {return print_binary_operator_errors( "NE" , symbol);}
+
+
void *print_datatypes_error_c::visit(CAL_operator_c *symbol) {
return NULL;
}