stage4/generate_cc/generate_cc.cc
changeset 41 8998c8b24b60
parent 40 873a5b60a7ea
child 46 fc1b78ea6d84
--- a/stage4/generate_cc/generate_cc.cc	Thu Jul 12 11:24:32 2007 +0200
+++ b/stage4/generate_cc/generate_cc.cc	Fri Jul 13 19:20:26 2007 +0200
@@ -1146,19 +1146,19 @@
       current_resource_name->accept(*this);
       s4o.print("\n");
        
-      /* (A.2) POUs inclusion */
-      s4o.print("#include \"POUS.c\"\n\n");
-      
-      /* (A.3) Global variables... */
+      /* (A.2) Global variables... */
       if (current_global_vars != NULL) {
         vardecl = new generate_cc_vardecl_c(&s4o,
-                      generate_cc_vardecl_c::local_vf,
+                      generate_cc_vardecl_c::localstatic_vf,
                       generate_cc_vardecl_c::global_vt);
         vardecl->print(current_global_vars);
         delete vardecl;
       }
       s4o.print("\n");
       
+      /* (A.3) POUs inclusion */
+      s4o.print("#include \"POUS.c\"\n\n");
+      
       /* (A.4) Resource programs declaration... */
       wanted_declaretype = declare_dt;
       symbol->program_configuration_list->accept(*this);
@@ -1382,6 +1382,7 @@
   protected:
     stage4out_c &s4o;
     stage4out_c pous_s4o;
+    stage4out_c located_variables_s4o;
     generate_cc_pous_c generate_cc_pous;
 
     symbol_c *current_configuration;
@@ -1394,6 +1395,7 @@
     generate_cc_c(stage4out_c *s4o_ptr): 
             s4o(*s4o_ptr),
             pous_s4o("POUS", "c"),
+            located_variables_s4o("LOCATED_VARIABLES","h"),
             generate_cc_pous(&pous_s4o) {
       current_configuration = NULL;
     }
@@ -1404,7 +1406,7 @@
 /* B 0 - Programming Model */
 /***************************/
     void *visit(library_c *symbol) {
-      generate_location_list_c generate_location_list(&s4o);
+      generate_location_list_c generate_location_list(&located_variables_s4o);
       symbol->accept(generate_location_list);
       
       for(int i = 0; i < symbol->n; i++) {
@@ -1468,16 +1470,18 @@
       calculate_common_ticktime_c calculate_common_ticktime;
       symbol->accept(calculate_common_ticktime);
       common_ticktime = calculate_common_ticktime.get_ticktime();
-      s4o.print("common_ticktime : ");
-      s4o.print_integer((int)(common_ticktime / 1000000));
-      s4o.print("ms\n");
       
       symbol->configuration_name->accept(*this);
-    	stage4out_c config_s4o(current_name, "c");
-    	generate_cc_config_c generate_cc_config(&config_s4o);
-    	symbol->accept(generate_cc_config);
+      stage4out_c config_s4o(current_name, "c");
+      generate_cc_config_c generate_cc_config(&config_s4o);
+      symbol->accept(generate_cc_config);
+        
+      config_s4o.print("int common_ticktime__ = ");
+      config_s4o.print_integer((int)(common_ticktime / 1000000));
+      config_s4o.print("; /*ms*/\n");
+      
       symbol->resource_declarations->accept(*this);
-    	
+
       current_configuration = NULL;
       
       return NULL;