stage4/generate_cc/search_expression_type.cc
changeset 42 b45c7f34dec1
parent 38 6cce7d14647e
child 65 c6d41c1287de
--- a/stage4/generate_cc/search_expression_type.cc	Fri Jul 13 19:20:26 2007 +0200
+++ b/stage4/generate_cc/search_expression_type.cc	Tue Jul 17 12:19:59 2007 +0200
@@ -430,16 +430,18 @@
   void *visit(mul_expression_c *symbol) {
     symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this));
     symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this));
-    if (typeid(*left_type) == typeid(time_type_name_c) && is_integer_type(right_type)) {return (void *)&time_type_name;}
-    if (typeid(*left_type) == typeid(time_type_name_c) && is_real_type(right_type)) {return (void *)&time_type_name;}
+    if (typeid(*left_type) == typeid(time_type_name_c) && is_num_type(right_type)) {
+        return (void *)&time_type_name;
+    }
     return compute_numeric_expression(left_type, right_type);
   }
   
   void *visit(div_expression_c *symbol) {
     symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this));
     symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this));
-    if (typeid(*left_type) == typeid(time_type_name_c) && is_integer_type(right_type)) {return (void *)&time_type_name;}
-    if (typeid(*left_type) == typeid(time_type_name_c) && is_real_type(right_type)) {return (void *)&time_type_name;}
+    if (typeid(*left_type) == typeid(time_type_name_c) && is_num_type(right_type)){
+        return (void *)&time_type_name;
+    }
     return compute_numeric_expression(left_type, right_type);
   }
 
@@ -452,39 +454,18 @@
   void *visit(power_expression_c *symbol) {
     symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this));
     symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this));
-    if (typeid(*left_type) == typeid(real_type_name_c) and typeid(*right_type) == typeid(sint_type_name_c)) {return (void *)left_type;}
-    if (typeid(*left_type) == typeid(real_type_name_c) and typeid(*right_type) == typeid(int_type_name_c)) {return (void *)left_type;}
-    if (typeid(*left_type) == typeid(real_type_name_c) and typeid(*right_type) == typeid(dint_type_name_c)) {return (void *)left_type;}
-    if (typeid(*left_type) == typeid(real_type_name_c) and typeid(*right_type) == typeid(lint_type_name_c)) {return (void *)left_type;}
-    if (typeid(*left_type) == typeid(real_type_name_c) and typeid(*right_type) == typeid(usint_type_name_c)) {return (void *)left_type;}
-    if (typeid(*left_type) == typeid(real_type_name_c) and typeid(*right_type) == typeid(uint_type_name_c)) {return (void *)left_type;}
-    if (typeid(*left_type) == typeid(real_type_name_c) and typeid(*right_type) == typeid(udint_type_name_c)) {return (void *)left_type;}
-    if (typeid(*left_type) == typeid(real_type_name_c) and typeid(*right_type) == typeid(ulint_type_name_c)) {return (void *)left_type;}
-    if (typeid(*left_type) == typeid(lreal_type_name_c) and typeid(*right_type) == typeid(sint_type_name_c)) {return (void *)left_type;}
-    if (typeid(*left_type) == typeid(lreal_type_name_c) and typeid(*right_type) == typeid(int_type_name_c)) {return (void *)left_type;}
-    if (typeid(*left_type) == typeid(lreal_type_name_c) and typeid(*right_type) == typeid(dint_type_name_c)) {return (void *)left_type;}
-    if (typeid(*left_type) == typeid(lreal_type_name_c) and typeid(*right_type) == typeid(lint_type_name_c)) {return (void *)left_type;}
-    if (typeid(*left_type) == typeid(lreal_type_name_c) and typeid(*right_type) == typeid(usint_type_name_c)) {return (void *)left_type;}
-    if (typeid(*left_type) == typeid(lreal_type_name_c) and typeid(*right_type) == typeid(uint_type_name_c)) {return (void *)left_type;}
-    if (typeid(*left_type) == typeid(lreal_type_name_c) and typeid(*right_type) == typeid(udint_type_name_c)) {return (void *)left_type;}
-    if (typeid(*left_type) == typeid(lreal_type_name_c) and typeid(*right_type) == typeid(ulint_type_name_c)) {return (void *)left_type;}
+    if (is_real_type(left_type) && is_num_type(right_type)) {
+        return (void *)left_type;
+    }
     ERROR;
     return NULL;
   }
   
   void *visit(neg_expression_c *symbol) {
     symbol_c *exp_type = base_type((symbol_c *)symbol->exp->accept(*this));
-    if (typeid(*exp_type) == typeid(sint_type_name_c)) {return (void *)exp_type;}
-    if (typeid(*exp_type) == typeid(int_type_name_c)) {return (void *)exp_type;}
-    if (typeid(*exp_type) == typeid(dint_type_name_c)) {return (void *)exp_type;}
-    if (typeid(*exp_type) == typeid(lint_type_name_c)) {return (void *)exp_type;}
-    if (typeid(*exp_type) == typeid(usint_type_name_c)) {return (void *)exp_type;}
-    if (typeid(*exp_type) == typeid(uint_type_name_c)) {return (void *)exp_type;}
-    if (typeid(*exp_type) == typeid(udint_type_name_c)) {return (void *)exp_type;}
-    if (typeid(*exp_type) == typeid(ulint_type_name_c)) {return (void *)exp_type;}
-    if (typeid(*exp_type) == typeid(real_type_name_c)) {return (void *)exp_type;}
-    if (typeid(*exp_type) == typeid(lreal_type_name_c)) {return (void *)exp_type;}
-    if (typeid(*exp_type) == typeid(time_type_name_c)) {return (void *)exp_type;}
+    if (is_num_type(exp_type) || typeid(*exp_type) == typeid(time_type_name_c)){
+            return (void *)exp_type;
+         }
     ERROR;
     return NULL;
   }