# HG changeset patch # User laurent # Date 1310115987 -7200 # Node ID 229eb3e29216fa50a2f92d702de47156f12d7d7b # Parent 96d2efda3d8d5b0572755695946cdc4ebefaca5b Fix bug in function calls with literal parameters diff -r 96d2efda3d8d -r 229eb3e29216 absyntax_utils/search_expression_type.cc --- a/absyntax_utils/search_expression_type.cc Thu Jul 07 10:49:08 2011 +0200 +++ b/absyntax_utils/search_expression_type.cc Fri Jul 08 11:06:27 2011 +0200 @@ -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" diff -r 96d2efda3d8d -r 229eb3e29216 absyntax_utils/search_expression_type.hh --- a/absyntax_utils/search_expression_type.hh Thu Jul 07 10:49:08 2011 +0200 +++ b/absyntax_utils/search_expression_type.hh Fri Jul 08 11:06:27 2011 +0200 @@ -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" diff -r 96d2efda3d8d -r 229eb3e29216 stage4/generate_c/generate_c_il.cc --- a/stage4/generate_c/generate_c_il.cc Thu Jul 07 10:49:08 2011 +0200 +++ b/stage4/generate_c/generate_c_il.cc Fri Jul 08 11:06:27 2011 +0200 @@ -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("__"); diff -r 96d2efda3d8d -r 229eb3e29216 stage4/generate_c/generate_c_inlinefcall.cc --- a/stage4/generate_c/generate_c_inlinefcall.cc Thu Jul 07 10:49:08 2011 +0200 +++ b/stage4/generate_c/generate_c_inlinefcall.cc Fri Jul 08 11:06:27 2011 +0200 @@ -91,11 +91,9 @@ std::list::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); diff -r 96d2efda3d8d -r 229eb3e29216 stage4/generate_c/generate_c_st.cc --- a/stage4/generate_c/generate_c_st.cc Thu Jul 07 10:49:08 2011 +0200 +++ b/stage4/generate_c/generate_c_st.cc Fri Jul 08 11:06:27 2011 +0200 @@ -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("__");