Add support for '**' (power) operator in ST expressions
authorMario de Sousa <msousa@fe.up.pt>
Mon, 22 Aug 2011 16:08:07 +0100
changeset 358 a2c4af8f0c18
parent 357 8a6a69dd23ce
child 359 84f81f8eac2f
Add support for '**' (power) operator in ST expressions
stage4/generate_c/generate_c_st.cc
--- a/stage4/generate_c/generate_c_st.cc	Fri Aug 19 21:53:11 2011 +0100
+++ b/stage4/generate_c/generate_c_st.cc	Mon Aug 22 16:08:07 2011 +0100
@@ -586,10 +586,14 @@
   return NULL;
 }
 
-/* TODO: power expression... */
 void *visit(power_expression_c *symbol) {
-  ERROR; 
-  return print_binary_expression(symbol->l_exp, symbol->r_exp, " ** ");
+  /* Note that the called pow() function is defined in iec_std_lib.h !! */
+  s4o.print("(pow(");
+  symbol->l_exp->accept(*this);
+  s4o.print(", ");
+  symbol->r_exp->accept(*this);
+  s4o.print("))");
+  return NULL;
 }
 
 void *visit(neg_expression_c *symbol) {