edits
[cdsspec-compiler.git] / src / edu / uci / eecs / specCompiler / codeGenerator / CodeVariables.java
index bcc6e418ca80a8eab903606a567160306d0b3ab5..4d19458335299d3f15dbd6d09ab03b909c8ac985 100644 (file)
@@ -467,8 +467,13 @@ public class CodeVariables {
 
                // Define the __SPEC_CLEAN__ function for clean-up
                newCode.add(COMMENT("Cleanup routine of sequential variables"));
-               newCode.add("static void __SPEC_CLEANUP__() {");
-               addAllCodeWithIndent(newCode, construct.code.cleanupCode, "\t");
+               newCode.add("static bool __SPEC_CLEANUP__() {");
+               if (construct.code.cleanupCode.size() > 0) {
+                       addAllCodeWithIndent(newCode, construct.code.cleanupCode, "\t");        
+               } else {
+                       newCode.add("\treturn true;"); // If not specified return true
+               }
+               
                newCode.add("}");
                newCode.add("");
 
@@ -504,10 +509,10 @@ public class CodeVariables {
                newCode.add("\t" + STRUCT_NEW_DECLARE_DEFINE(ANNO_INIT, structName));
                newCode.add("\t"
                                + ASSIGN_TO_PTR(structName, "init_func",
-                                               "(void_func_t*) __SPEC_INIT__"));
+                                               "(void_func_t) __SPEC_INIT__"));
                newCode.add("\t"
                                + ASSIGN_TO_PTR(structName, "cleanup_func",
-                                               "(void_func_t*) __SPEC_CLEANUP__"));
+                                               "(cleanup_func_t) __SPEC_CLEANUP__"));
                newCode.add("\t"
                                + ASSIGN_TO_PTR(structName, "func_table", "func_ptr_table"));
                newCode.add("\t"
@@ -556,6 +561,7 @@ public class CodeVariables {
                if (templateList == null) {
                        newCode.add(DECLARE("void**", varPrefix + "func_ptr_table"));
                        newCode.add(DECLARE("hb_rule**", varPrefix + "hb_rule_table"));
+                       newCode.add(DECLARE("commutativity_rule**", varPrefix + "commutativity_rule_table"));
                        for (int i = 0; i < construct.code.declareVar.size(); i++) {
                                VariableDeclaration varDecl = construct.code.declareVar.get(i);
                                newCode.add(DECLARE(varDecl.type, varPrefix + varDecl.name));
@@ -565,6 +571,7 @@ public class CodeVariables {
                        newCode.add(DECLARE("void**", varPrefix + "func_ptr_table"));
                        newCode.add(templateDecl);
                        newCode.add(DECLARE("hb_rule**", varPrefix + "hb_rule_table"));
+                       newCode.add(DECLARE("commutativity_rule**", varPrefix + "commutativity_rule_table"));
                        for (int i = 0; i < construct.code.declareVar.size(); i++) {
                                VariableDeclaration varDecl = construct.code.declareVar.get(i);
                                newCode.add(templateDecl);
@@ -671,6 +678,10 @@ public class CodeVariables {
                        newCode.add("\t"
                                        + ASSIGN_TO_PTR("rule", "interface_num_after",
                                                        interfaceNumAfter));
+                       newCode.add("\t"
+                                       + ASSIGN_TO_PTR("rule", "rule",
+                                                       "\"" + rule.condition + "\""));
+                       
                        newCode.add("\t"
                                        + ASSIGN_TO_PTR("rule", "condition", conditionFuncName));
 
@@ -989,13 +1000,15 @@ public class CodeVariables {
                String structName = "cp_clear", anno = "annotation_cp_clear";
                newCode.add("\t\t"
                                + STRUCT_NEW_DECLARE_DEFINE(ANNO_CP_CLEAR, structName));
-               // String labelNum = Integer.toString(semantics.commitPointLabel2Num
-               // .get(construct.label));
-               // String interfaceNum = getCPInterfaceNum(semantics, construct.label);
-               // newCode.add("\t\t" + ASSIGN_TO_PTR(structName, "label_num",
-               // labelNum));
-               // newCode.add("\t\t" + ASSIGN_TO_PTR(structName, "interface_num",
-               // interfaceNum));
+                
+               String labelNum = Integer.toString(semantics.commitPointLabel2Num
+                               .get(construct.label));
+               String labelName = construct.label;
+               newCode.add("\t\t" + ASSIGN_TO_PTR(structName, "label_name",
+                               "\"" + labelName + "\""));
+               newCode.add("\t\t" + ASSIGN_TO_PTR(structName, "label_num",
+                               labelNum));
+               
                newCode.add("\t\t" + STRUCT_NEW_DECLARE_DEFINE(SPEC_ANNOTATION, anno));
                newCode.add("\t\t"
                                + ASSIGN_TO_PTR(anno, "type", SPEC_ANNO_TYPE_CP_CLEAR));