# HG changeset patch # User laurent # Date 1315416490 -7200 # Node ID b826f13c260e989869d98878342e7c774d7da218 # Parent 990ecb883731986647c08f363f87649f23284b38 Fixing exponentiation used with symbol ** diff -r 990ecb883731 -r b826f13c260e 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) {