Bug when trying to use standard functions on literals only fixed
authorlaurent
Mon, 21 Sep 2009 12:06:15 +0200
changeset 410 e1d4e9a93186
parent 409 34c9f624c2fe
child 411 9ab97d517ae8
Bug when trying to use standard functions on literals only fixed
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)