# HG changeset patch # User laurent # Date 1253527575 -7200 # Node ID e1d4e9a93186c39f47277e2d2967944edc0d9802 # Parent 34c9f624c2feafcb8a4141388605bb0d3975538f Bug when trying to use standard functions on literals only fixed diff -r 34c9f624c2fe -r e1d4e9a93186 generate_IEC_std.py --- a/generate_IEC_std.py Wed Sep 16 12:00:58 2009 +0200 +++ b/generate_IEC_std.py Mon Sep 21 12:06:15 2009 +0200 @@ -231,7 +231,14 @@ result_type_rule = fdecl["return_type_rule"] res += { - "copy_input" : "symbol_c * return_type_symbol = last_type_symbol;\n", + "copy_input" : """symbol_c * return_type_symbol; +if (search_expression_type->is_literal_integer_type(last_type_symbol)) + return_type_symbol = &search_constant_type_c::%s_type_name; +else + return_type_symbol = last_type_symbol; +"""%({True: "lword", False: """lint_type_name; +else if (search_expression_type->is_literal_real_type(last_type_symbol)) + return_type_symbol = &search_constant_type_c::lreal"""}[reduce(lambda x, y: x or y, [paramtype == "ANY_BIT" for paramname,paramtype,unused in fdecl["inputs"]], False)]), "defined" : "symbol_c * return_type_symbol = &search_constant_type_c::%s_type_name;\n"%fdecl["outputs"][0][1].lower(), }.get(result_type_rule, "symbol_c * return_type_symbol = %s;\n"%result_type_rule)