commiting merge with Laurent's repository
authorMario de Sousa <msousa@fe.up.pt>
Mon, 11 Jul 2011 09:47:27 +0100
changeset 341 ba80c3ceb6fb
parent 340 27a56785e9cd (current diff)
parent 336 229eb3e29216 (diff)
child 342 8fb0fbfcc71b
child 350 2c3c4dc34979
commiting merge with Laurent's repository
--- a/absyntax_utils/search_expression_type.cc	Sat Jul 09 14:48:31 2011 +0100
+++ b/absyntax_utils/search_expression_type.cc	Mon Jul 11 09:47:27 2011 +0100
@@ -191,6 +191,16 @@
   return NULL;
 }
 
+symbol_c *search_expression_type_c::default_literal_type(symbol_c* symbol) {
+  if (is_literal_integer_type(symbol)) {
+    return (symbol_c *)&search_constant_type_c::lint_type_name;
+  }
+  else if (is_literal_real_type(symbol)) {
+    return (symbol_c *)&search_constant_type_c::lreal_type_name;
+  }
+  return symbol;
+}
+
 
 integer_c search_expression_type_c::integer("1"); // what default value should we use here ???
 #include "search_type_code.c"
--- a/absyntax_utils/search_expression_type.hh	Sat Jul 09 14:48:31 2011 +0100
+++ b/absyntax_utils/search_expression_type.hh	Mon Jul 11 09:47:27 2011 +0100
@@ -64,6 +64,7 @@
 
     bool is_same_type(symbol_c *first_type, symbol_c *second_type);
     symbol_c* common_type(symbol_c *first_type, symbol_c *second_type);
+    symbol_c* default_literal_type(symbol_c *symbol);
 
     /*
     #include "search_type_code.c"
--- a/stage4/generate_c/generate_c_il.cc	Sat Jul 09 14:48:31 2011 +0100
+++ b/stage4/generate_c/generate_c_il.cc	Mon Jul 11 09:47:27 2011 +0100
@@ -893,9 +893,12 @@
     
   if (function_type_prefix != NULL) {
     s4o.print("(");
-    function_type_prefix->accept(*this);
+    search_expression_type->default_literal_type(function_type_prefix)->accept(*this);
     s4o.print(")");
   }
+  if (function_type_suffix != NULL) {
+  	function_type_suffix = search_expression_type->default_literal_type(function_type_prefix);
+  }
   if (has_output_params) {
   	fcall_number++;
   	s4o.print("__");
@@ -1258,9 +1261,12 @@
   
   if (function_type_prefix != NULL) {
     s4o.print("(");
-    function_type_prefix->accept(*this);
+    search_expression_type->default_literal_type(function_type_prefix)->accept(*this);
     s4o.print(")");
   }
+  if (function_type_suffix != NULL) {
+  	function_type_suffix = search_expression_type->default_literal_type(function_type_prefix);
+  }
   if (has_output_params) {
 	fcall_number++;
 	s4o.print("__");
--- a/stage4/generate_c/generate_c_inlinefcall.cc	Sat Jul 09 14:48:31 2011 +0100
+++ b/stage4/generate_c/generate_c_inlinefcall.cc	Mon Jul 11 09:47:27 2011 +0100
@@ -91,11 +91,9 @@
             std::list<FUNCTION_PARAM*>::iterator pt;
 
       fcall_number++;
-      if (search_expression_type->is_literal_integer_type(function_type_prefix)) {
-    	function_type_prefix = (symbol_c *)&search_constant_type_c::lint_type_name;
-      }
-      else if (search_expression_type->is_literal_real_type(function_type_prefix)) {
-    	function_type_prefix = (symbol_c *)&search_constant_type_c::lreal_type_name;
+      function_type_prefix = search_expression_type->default_literal_type(function_type_prefix);
+      if (function_type_suffix) {
+        function_type_suffix = search_expression_type->default_literal_type(function_type_suffix);
       }
 
       s4o.print(s4o.indent_spaces);
@@ -105,23 +103,16 @@
       fbname->accept(*this);
       s4o.print("_");
       function_name->accept(*this);
-      if (function_type_suffix)
-        function_type_suffix->accept(*this);
+      if (function_type_suffix) {
+    	function_type_suffix->accept(*this);
+      }
       s4o.print_integer(fcall_number);
       s4o.print("(");
       s4o.indent_right();
 
       PARAM_LIST_ITERATOR() {
         if (PARAM_DIRECTION == function_param_iterator_c::direction_in) {
-          if (search_expression_type->is_literal_integer_type(PARAM_TYPE)) {
-        	((symbol_c *)&search_constant_type_c::lint_type_name)->accept(*this);
-          }
-          else if (search_expression_type->is_literal_real_type(PARAM_TYPE)) {
-        	((symbol_c *)&search_constant_type_c::lreal_type_name)->accept(*this);
-          }
-          else {
-        	PARAM_TYPE->accept(*this);
-          }
+          search_expression_type->default_literal_type(PARAM_TYPE)->accept(*this);
           s4o.print(" ");
           PARAM_NAME->accept(*this);
           s4o.print(",\n" + s4o.indent_spaces);
--- a/stage4/generate_c/generate_c_st.cc	Sat Jul 09 14:48:31 2011 +0100
+++ b/stage4/generate_c/generate_c_st.cc	Mon Jul 11 09:47:27 2011 +0100
@@ -698,9 +698,12 @@
 
   if (function_type_prefix != NULL) {
     s4o.print("(");
-    function_type_prefix->accept(*this);
+    search_expression_type->default_literal_type(function_type_prefix)->accept(*this);
     s4o.print(")");
   }
+  if (function_type_suffix != NULL) {
+	function_type_suffix = search_expression_type->default_literal_type(function_type_prefix);
+  }
   if (has_output_params) {
 	fcall_number++;
 	s4o.print("__");