Deleting datatype checks no longer needed (with a view of making search_expression_type_c redundant).
authorMario de Sousa <msousa@fe.up.pt>
Fri, 31 Aug 2012 19:30:48 +0100
changeset 653 ea78924a1f60
parent 652 7fe1533d2260
child 654 7421cb63defa
Deleting datatype checks no longer needed (with a view of making search_expression_type_c redundant).
stage4/generate_c/generate_c_il.cc
stage4/generate_c/generate_c_inlinefcall.cc
stage4/generate_c/generate_c_st.cc
--- a/stage4/generate_c/generate_c_il.cc	Fri Aug 31 15:09:25 2012 +0100
+++ b/stage4/generate_c/generate_c_il.cc	Fri Aug 31 19:30:48 2012 +0100
@@ -1878,63 +1878,12 @@
   return NULL;
 }
 
-void *visit(GT_operator_c *symbol)	{
-  if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
-      search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
-    CMP_operator(this->current_operand, "GT_");
-  } else {
-    ERROR;
-  }
-  return NULL;
-}
-
-void *visit(GE_operator_c *symbol)	{
-  if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
-      search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
-    CMP_operator(this->current_operand, "GE_");
-  } else {
-    ERROR;
-  }
-  return NULL;
-}
-
-void *visit(EQ_operator_c *symbol)	{
-  if (search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
-    CMP_operator(this->current_operand, "EQ_");
-  } else {
-    ERROR;
-  }
-  return NULL;
-}
-
-void *visit(LT_operator_c *symbol)	{
-  if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
-      search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
-    CMP_operator(this->current_operand, "LT_");
-  } else {
-    ERROR;
-  }
-  return NULL;
-}
-
-void *visit(LE_operator_c *symbol)	{
-  if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
-      search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
-    CMP_operator(this->current_operand, "LE_");
-  } else {
-    ERROR;
-  }
-  return NULL;
-}
-
-void *visit(NE_operator_c *symbol)	{
-  if (search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
-    CMP_operator(this->current_operand, "NE_");
-  } else {
-    ERROR;
-  }
-  return NULL;
-}
+void *visit(GT_operator_c *symbol)	{CMP_operator(this->current_operand, "GT_"); return NULL;}
+void *visit(GE_operator_c *symbol)	{CMP_operator(this->current_operand, "GE_"); return NULL;}
+void *visit(EQ_operator_c *symbol)	{CMP_operator(this->current_operand, "EQ_"); return NULL;}
+void *visit(LT_operator_c *symbol)	{CMP_operator(this->current_operand, "LT_"); return NULL;}
+void *visit(LE_operator_c *symbol)	{CMP_operator(this->current_operand, "LE_"); return NULL;}
+void *visit(NE_operator_c *symbol)	{CMP_operator(this->current_operand, "NE_"); return NULL;}
 
 
 //SYM_REF0(CAL_operator_c)
--- a/stage4/generate_c/generate_c_inlinefcall.cc	Fri Aug 31 15:09:25 2012 +0100
+++ b/stage4/generate_c/generate_c_inlinefcall.cc	Fri Aug 31 19:30:48 2012 +0100
@@ -965,57 +965,12 @@
       return NULL;
     }
 
-    void *visit(GT_operator_c *symbol)	{
-      if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
-          search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
-        CMP_operator_result_type();
-      }
-      else {ERROR;}
-      return NULL;
-    }
-
-    void *visit(GE_operator_c *symbol)	{
-      if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
-          search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
-        CMP_operator_result_type();
-      }
-      else {ERROR;}
-      return NULL;
-    }
-
-    void *visit(EQ_operator_c *symbol)	{
-      if (search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
-        CMP_operator_result_type();
-      }
-      else {ERROR;}
-      return NULL;
-    }
-
-    void *visit(LT_operator_c *symbol)	{
-      if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
-          search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
-        CMP_operator_result_type();
-      }
-      else {ERROR;}
-      return NULL;
-    }
-
-    void *visit(LE_operator_c *symbol)	{
-      if (!search_base_type.type_is_enumerated(this->default_variable_name.current_type) &&
-          search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
-        CMP_operator_result_type();
-      }
-      else {ERROR;}
-      return NULL;
-    }
-
-    void *visit(NE_operator_c *symbol)	{
-      if (search_expression_type->is_same_type(this->default_variable_name.current_type, this->current_operand_type)) {
-        CMP_operator_result_type();
-      }
-      else {ERROR;}
-      return NULL;
-    }
+    void *visit(GT_operator_c *symbol)	{CMP_operator_result_type(); return NULL;}
+    void *visit(GE_operator_c *symbol)	{CMP_operator_result_type(); return NULL;}
+    void *visit(EQ_operator_c *symbol)	{CMP_operator_result_type(); return NULL;}
+    void *visit(LT_operator_c *symbol)	{CMP_operator_result_type(); return NULL;}
+    void *visit(LE_operator_c *symbol)	{CMP_operator_result_type(); return NULL;}
+    void *visit(NE_operator_c *symbol)	{CMP_operator_result_type(); return NULL;}
 
     /***************************************/
     /* B.3 - Language ST (Structured Text) */
--- a/stage4/generate_c/generate_c_st.cc	Fri Aug 31 15:09:25 2012 +0100
+++ b/stage4/generate_c/generate_c_st.cc	Fri Aug 31 19:30:48 2012 +0100
@@ -482,8 +482,7 @@
 void *visit(equ_expression_c *symbol) {
   symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
-  if (!search_expression_type->is_same_type(left_type, right_type))
-      ERROR;
+  // if (!search_expression_type->is_same_type(left_type, right_type))    ERROR;  // This check is no longer needed!
   if (search_expression_type->is_time_type(left_type) ||
       search_expression_type->is_string_type(left_type))
     return print_compare_function("EQ_", left_type, symbol->l_exp, symbol->r_exp);
@@ -493,8 +492,7 @@
 void *visit(notequ_expression_c *symbol) {
   symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
-  if (!search_expression_type->is_same_type(left_type, right_type))
-      ERROR;
+  // if (!search_expression_type->is_same_type(left_type, right_type))    ERROR;  // This check is no longer needed!
   if (search_expression_type->is_time_type(left_type) ||
       search_expression_type->is_string_type(left_type))
     return print_compare_function("NE_", left_type, symbol->l_exp, symbol->r_exp);
@@ -504,57 +502,41 @@
 void *visit(lt_expression_c *symbol) {
   symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
-  if (!search_expression_type->is_same_type(left_type, right_type))
-      ERROR;
+  // if (!search_expression_type->is_same_type(left_type, right_type))    ERROR;  // This check is no longer needed!
   if (search_expression_type->is_time_type(left_type) ||
       search_expression_type->is_string_type(left_type))
     return print_compare_function("LT_", left_type, symbol->l_exp, symbol->r_exp);
-  if (!search_base_type.type_is_enumerated(left_type))
-    return print_binary_expression(symbol->l_exp, symbol->r_exp, " < ");
-  ERROR;
-  return NULL;
+  return print_binary_expression(symbol->l_exp, symbol->r_exp, " < ");
 }
 
 void *visit(gt_expression_c *symbol) {
   symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
-  if (!search_expression_type->is_same_type(left_type, right_type))
-      ERROR;
+  // if (!search_expression_type->is_same_type(left_type, right_type))    ERROR;  // This check is no longer needed!
   if (search_expression_type->is_time_type(left_type) ||
       search_expression_type->is_string_type(left_type))
     return print_compare_function("GT_", left_type, symbol->l_exp, symbol->r_exp);
-  if (!search_base_type.type_is_enumerated(left_type))
-    return print_binary_expression(symbol->l_exp, symbol->r_exp, " > ");
-  ERROR;
-  return NULL;
+  return print_binary_expression(symbol->l_exp, symbol->r_exp, " > ");
 }
 
 void *visit(le_expression_c *symbol) {
   symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
-  if (!search_expression_type->is_same_type(left_type, right_type))
-      ERROR;
+  // if (!search_expression_type->is_same_type(left_type, right_type))    ERROR;  // This check is no longer needed!
   if (search_expression_type->is_time_type(left_type) ||
       search_expression_type->is_string_type(left_type))
     return print_compare_function("LE_", left_type, symbol->l_exp, symbol->r_exp);
-  if (!search_base_type.type_is_enumerated(left_type))
-    return print_binary_expression(symbol->l_exp, symbol->r_exp, " <= ");
-  ERROR;
-  return NULL;
+  return print_binary_expression(symbol->l_exp, symbol->r_exp, " <= ");
 }
 
 void *visit(ge_expression_c *symbol) {
   symbol_c *left_type = search_expression_type->get_type(symbol->l_exp);
   symbol_c *right_type = search_expression_type->get_type(symbol->r_exp);
-  if (!search_expression_type->is_same_type(left_type, right_type))
-      ERROR;
+  // if (!search_expression_type->is_same_type(left_type, right_type))    ERROR;  // This check is no longer needed!
   if (search_expression_type->is_time_type(left_type) ||
       search_expression_type->is_string_type(left_type))
     return print_compare_function("GE_", left_type, symbol->l_exp, symbol->r_exp);
-  if (!search_base_type.type_is_enumerated(left_type))
-    return print_binary_expression(symbol->l_exp, symbol->r_exp, " >= ");
-  ERROR;
-  return NULL;
+  return print_binary_expression(symbol->l_exp, symbol->r_exp, " >= ");
 }
 
 void *visit(add_expression_c *symbol) {