stage4/generate_cc/generate_cc.cc
changeset 30 83201ec94ef4
parent 29 3ba8ef691003
child 32 289256ec66f1
--- a/stage4/generate_cc/generate_cc.cc	Wed May 16 18:15:24 2007 +0200
+++ b/stage4/generate_cc/generate_cc.cc	Fri May 18 14:11:09 2007 +0200
@@ -193,6 +193,7 @@
 #include "generate_cc_typedecl.cc"
 #include "generate_cc_vardecl.cc"
 #include "generate_cc_configbody.cc"
+#include "generate_location_list.cc"
 
 /***********************************************************************/
 /***********************************************************************/
@@ -456,32 +457,6 @@
 
 
   public:
-/***************************/
-/* B 0 - Programming Model */
-/***************************/
-void *visit(library_c *symbol) {
-  TRACE("library_c");
-
-  /* Insert the header... */
-  s4o.print("/*******************************************/\n");
-  s4o.print("/*     FILE GENERATED BY iec2cc            */\n");
-  s4o.print("/* Editing this file is not recommended... */\n");
-  s4o.print("/*******************************************/\n");
-  s4o.print("\n\n\n\n\n");
-  s4o.print("#include \"plciec.h\"\n");
-  s4o.print("\n\n\n\n\n");
-
-  /* now do the actual code... */
-  print_list(symbol);
-  s4o.print("\n\n");
-
-  /* Finish off with the main() */
-  s4o.print("#include \"plciec.cc\"\n");
-  s4o.print("\n\n");
-
-  // function_symtable.print();
-  return NULL;
-}
 
 /*************************/
 /* B.1 - Common elements */
@@ -946,6 +921,13 @@
 void *visit(configuration_declaration_c *symbol) {
   generate_cc_vardecl_c *vardecl;
   
+  /* Insert the header... */
+  s4o.print("/*******************************************/\n");
+  s4o.print("/*     FILE GENERATED BY iec2cc            */\n");
+  s4o.print("/* Editing this file is not recommended... */\n");
+  s4o.print("/*******************************************/\n\n");
+  s4o.print("#include \"plciec.h\"\n\n");
+  
   /* (A) configuration declaration... */
   /* (A.1) configuration name in comment */
   s4o.print("// CONFIGURATION ");
@@ -1151,6 +1133,13 @@
         current_resource_name = new identifier_c("RESOURCE");
       generate_cc_vardecl_c *vardecl;
       
+      /* Insert the header... */
+      s4o.print("/*******************************************/\n");
+      s4o.print("/*     FILE GENERATED BY iec2cc            */\n");
+      s4o.print("/* Editing this file is not recommended... */\n");
+      s4o.print("/*******************************************/\n\n");
+      s4o.print("#include \"plciec.h\"\n\n");
+      
       /* (A) resource declaration... */
       /* (A.1) resource name in comment */
       s4o.print("// RESOURCE ");
@@ -1248,7 +1237,7 @@
           s4o.print(s4o.indent_spaces);
           s4o.print("if (");
           symbol->task_name->accept(*this);
-          s4o.print(") {\n");
+          s4o.print(" == 0) {\n");
           s4o.indent_right(); 
         }
         
@@ -1407,6 +1396,19 @@
             
     ~generate_cc_c(void) {}
 
+/***************************/
+/* B 0 - Programming Model */
+/***************************/
+    void *visit(library_c *symbol) {
+      generate_location_list_c generate_location_list(&s4o);
+      symbol->accept(generate_location_list);
+      
+      for(int i = 1; i < symbol->n; i++) {
+        symbol->elements[i]->accept(*this);
+      }
+      return NULL;
+    }
+
 /*************************/
 /* B.1 - Common elements */
 /*************************/