Bug on function without input parameters fixed
authorlbessard
Tue, 09 Jun 2009 10:57:01 +0200
changeset 189 7ca02034c4f6
parent 188 b4d81d21b8d3
child 190 00b83e15eb43
Bug on function without input parameters fixed
stage4/generate_c/generate_c.cc
stage4/generate_c/generate_c_vardecl.cc
--- a/stage4/generate_c/generate_c.cc	Tue Jun 09 10:14:17 2009 +0200
+++ b/stage4/generate_c/generate_c.cc	Tue Jun 09 10:57:01 2009 +0200
@@ -504,12 +504,7 @@
 				        generate_c_vardecl_c::inoutput_vt |
                 generate_c_vardecl_c::eneno_vt);
   vardecl->print(symbol->var_declarations_list);
-  if (!vardecl->is_en_declared()) {
-    s4o.print(",\n" + s4o.indent_spaces + "BOOL EN");
-  }
-  if (!vardecl->is_eno_declared()) {
-    s4o.print(",\n" + s4o.indent_spaces + "BOOL *ENO");
-  }
+  vardecl->print_eneno();
   delete vardecl;
   
   s4o.indent_left();
@@ -621,12 +616,7 @@
   				      generate_c_vardecl_c::inoutput_vt |
                 generate_c_vardecl_c::eneno_vt);
   vardecl->print(symbol->var_declarations);
-  if (!vardecl->is_en_declared()) {
-    s4o_incl.print(s4o_incl.indent_spaces + "BOOL EN;\n");
-  }
-  if (!vardecl->is_eno_declared()) {
-    s4o_incl.print(s4o_incl.indent_spaces + "BOOL ENO;\n");
-  }
+  vardecl->print_eneno();
   delete vardecl;
   s4o_incl.print("\n");
   /* (A.3) Private internal variables */
--- a/stage4/generate_c/generate_c_vardecl.cc	Tue Jun 09 10:14:17 2009 +0200
+++ b/stage4/generate_c/generate_c_vardecl.cc	Tue Jun 09 10:57:01 2009 +0200
@@ -1016,17 +1016,29 @@
       } /* switch() */
 
       symbol->accept(*this);
-
-      /* special case... */
-      if (wanted_varformat == finterface_vf)
-        if (finterface_var_count == 0)
-          s4o.print("void");
-
+      
       delete nv;
       nv = NULL;
       globalnamespace = NULL;
     }
 
+    void print_eneno(void) {
+      if (!en_declared) {
+        if (wanted_varformat == finterface_vf) {
+          if (finterface_var_count > 0)
+            s4o.print(",\n" + s4o.indent_spaces);
+          s4o.print("BOOL EN");
+        }
+        else
+          s4o.print(s4o.indent_spaces + "BOOL EN;\n");
+      }
+      if (!eno_declared) {
+        if (wanted_varformat == finterface_vf)
+          s4o.print(",\n" + s4o.indent_spaces + "BOOL *ENO");
+        else
+          s4o.print(s4o.indent_spaces + "BOOL ENO;\n");
+      }
+    }
 
   protected:
 /***************************/