Fixing exponentiation used with symbol **
authorlaurent
Wed, 07 Sep 2011 19:28:10 +0200
changeset 349 b826f13c260e
parent 348 990ecb883731
child 375 7a11f9e9e703
Fixing exponentiation used with symbol **
stage4/generate_c/generate_c_st.cc
--- a/stage4/generate_c/generate_c_st.cc	Fri Sep 02 18:16:33 2011 +0200
+++ b/stage4/generate_c/generate_c_st.cc	Wed Sep 07 19:28:10 2011 +0200
@@ -611,10 +611,22 @@
   return NULL;
 }
 
-/* TODO: power expression... */
 void *visit(power_expression_c *symbol) {
-  ERROR; 
-  return print_binary_expression(symbol->l_exp, symbol->r_exp, " ** ");
+  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_real_type(left_type) && search_expression_type->is_num_type(right_type)) {
+	s4o.print("__expt_LREAL((BOOL)__BOOL_LITERAL(TRUE),\n");
+	s4o.indent_right();
+	s4o.print(s4o.indent_spaces + "NULL,\n");
+	s4o.print(s4o.indent_spaces + "(LREAL)(");
+	symbol->l_exp->accept(*this);
+	s4o.print("),\n");
+	s4o.print(s4o.indent_spaces + "(LREAL)(");
+	symbol->r_exp->accept(*this);
+	s4o.print("))");
+    return NULL;
+  }
+  ERROR;
 }
 
 void *visit(neg_expression_c *symbol) {