edits
[cdsspec-compiler.git] / src / edu / uci / eecs / codeGenerator / CodeGeneratorUtils.java
index 694695cf48ca9db30cae73666101a9ccb75ef066..04f3be95f4fba9983f04473a7e84f082159a7dc3 100644 (file)
@@ -248,6 +248,7 @@ public class CodeGeneratorUtils {
 
                Code code = new Code();
                String line = null;
+               Code fieldsInit = null;
 
                // Add auto-generated comments
                code.addLine("/**");
@@ -461,29 +462,27 @@ public class CodeGeneratorUtils {
                code.addLine("");
 
                // Define @Print
-               if (!globalConstruct.printState.isEmpty()) {
-                       code.addLine(ShortComment("Define @" + SpecNaming.PrintState));
-                       code.addLine("void _" + SpecNaming.PrintState.toLowerCase() + "("
-                                       + SpecNaming.Method + " " + SpecNaming.Method1 + ") {");
-
-                       // Initialize state struct fields
-                       Code fieldsInit = GenerateStateFieldsInitialization(
-                                       SpecNaming.Method1, SpecNaming.StateInst, globalConstruct);
-                       fieldsInit.align(1);
-                       code.addLines(fieldsInit);
-                       code.addLine("");
-                       if (!globalConstruct.autoGenPrint)
-                               code.addLine(TabbedLine(ShortComment("Execute user-defined state printing code")));
-                       else
-                               // Auto-generated the copy function
-                               code.addLine(TabbedLine(ShortComment("Execute auto-generated state printing code")));
-
-                       // Align the code with one tab
-                       globalConstruct.printState.align(1);
-                       code.addLines(globalConstruct.printState);
-                       code.addLine("}");
-                       code.addLine("");
-               }
+               code.addLine(ShortComment("Define @" + SpecNaming.PrintState));
+               code.addLine("void _" + SpecNaming.PrintState.toLowerCase() + "("
+                               + SpecNaming.Method + " " + SpecNaming.Method1 + ") {");
+
+               // Initialize state struct fields
+               fieldsInit = GenerateStateFieldsInitialization(SpecNaming.Method1,
+                               SpecNaming.StateInst, globalConstruct);
+               fieldsInit.align(1);
+               code.addLines(fieldsInit);
+               code.addLine("");
+               if (!globalConstruct.autoGenPrint)
+                       code.addLine(TabbedLine(ShortComment("Execute user-defined state printing code")));
+               else
+                       // Auto-generated the copy function
+                       code.addLine(TabbedLine(ShortComment("Execute auto-generated state printing code")));
+
+               // Align the code with one tab
+               globalConstruct.printState.align(1);
+               code.addLines(globalConstruct.printState);
+               code.addLine("}");
+               code.addLine("");
 
                // Define @Commutativity
                code.addLine(ShortComment("Define commutativity checking functions"));
@@ -517,7 +516,7 @@ public class CodeGeneratorUtils {
                for (File file : interfaceListMap.keySet()) {
                        ArrayList<InterfaceConstruct> list = interfaceListMap.get(file);
                        for (InterfaceConstruct construct : list) {
-                               Code fieldsInit = null;
+                               fieldsInit = null;
 
                                // Define interface functions
                                String name = construct.getName();