plcopen/structures.py
changeset 23 cce8d5662738
parent 22 a765fae3b361
child 25 8dc68e669d99
--- a/plcopen/structures.py	Wed Jun 20 15:25:08 2007 +0200
+++ b/plcopen/structures.py	Thu Jun 21 10:23:26 2007 +0200
@@ -480,10 +480,14 @@
             for Paramname, ParamTypes in fdecls.iteritems():
                 if do_il:
                     res += """
-{
+{"""
+                    if not do_type_search_only:
+                        res += """
     /* Get the value from a foo(<param_name> = <param_value>) style call */
     symbol_c *%(input_name)s_param_value = &this->default_variable_name;
-    
+"""%{"input_name":Paramname}
+                    res += """
+    symbol_c *%(input_name)s_type_symbol = param_data_type;
     last_type_symbol = param_data_type;
 """%{"input_name":Paramname}
                 else:
@@ -706,13 +710,13 @@
 """    %(fname, fname.lower())
         indent =  "    "
 
-        il_code_gen += recurse_and_indent(fdecls, indent).replace('\n','\n    ')
+        il_code_gen += recurse_and_indent(fdecls, indent, do_il=True).replace('\n','\n    ')
         
         il_code_gen += """
     }/*function_%s*/
     break;
 """    %(fname.lower())
-    st_code_gen +=  """
+    il_code_gen +=  """
     case function_none :
     ERROR;
 }
@@ -726,7 +730,14 @@
  * IEC 61131-3 standard function lib
  * generated code, do not edit by hand
  */
-switch(current_function_type){
+
+void *compute_standard_function_st(function_invocation_c *symbol) {
+
+  function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name);
+  function_call_param_iterator_c function_call_param_iterator(symbol);
+  search_expression_type_c* search_expression_type = this;
+
+  switch(current_function_type){
 """
     
     for fname, fdecls in [ (fname,std_fdecls[fname]) for fname in official_order ]:
@@ -749,8 +760,42 @@
     search_type_code += """
     case function_none :
     ERROR;
+  }
+  return NULL;
 }
-return NULL;
+
+void *compute_standard_function_il(il_function_call_c *symbol, symbol_c *param_data_type) {
+  
+  function_type_t current_function_type = get_function_type((identifier_c *)symbol->function_name);
+  function_call_param_iterator_c function_call_param_iterator(symbol);  
+  search_expression_type_c* search_expression_type = this;
+
+  switch(current_function_type){
+"""
+
+    for fname, fdecls in [ (fname,std_fdecls[fname]) for fname in official_order ]:
+        search_type_code += """
+/****
+ *%s
+ */
+    case function_%s :
+    {
+        symbol_c *last_type_symbol = NULL;
+"""    %(fname, fname.lower())
+        indent =  "    "
+
+        search_type_code += recurse_and_indent(fdecls, indent, True, True).replace('\n','\n    ')
+        
+        search_type_code += """
+    }/*function_%s*/
+    break;
+"""    %(fname.lower())
+    search_type_code += """
+    case function_none :
+    ERROR;
+  }
+  return NULL;
+}
 """