Adding test case & bug fixes to generate code for test case...
authorbdemsky <bdemsky>
Thu, 26 Feb 2004 22:51:10 +0000 (22:51 +0000)
committerbdemsky <bdemsky>
Thu, 26 Feb 2004 22:51:10 +0000 (22:51 +0000)
Repair/RepairCompiler/MCC/IR/RepairGenerator.java
Repair/RepairCompiler/MCC/IR/UpdateNode.java
Repair/RepairCompiler/MCC/ex_test.cc [new file with mode: 0755]

index c38860d..3251689 100755 (executable)
@@ -75,7 +75,7 @@ public class RepairGenerator {
        CodeWriter crhead = new StandardCodeWriter(this.outputhead);
        CodeWriter craux = new StandardCodeWriter(this.outputaux);
        crhead.outputline("};");
-       craux.outputline("};");
+       craux.outputline("}");
        generate_updates();
     }
 
@@ -316,12 +316,6 @@ public class RepairGenerator {
     
     private void generate_teardown() {
        CodeWriter cr = new StandardCodeWriter(outputaux);        
-       cr.outputline("if ("+repairtable.getSafeSymbol()+")");
-       cr.outputline("delete "+repairtable.getSafeSymbol()+";");
-       cr.outputline("if ("+oldmodel.getSafeSymbol()+")");
-       cr.outputline("delete "+oldmodel.getSafeSymbol()+";");
-       cr.outputline("delete "+newmodel.getSafeSymbol()+";");
-       cr.outputline("delete "+worklist.getSafeSymbol()+";");
        cr.endblock();
     }
 
@@ -471,6 +465,7 @@ public class RepairGenerator {
         cr2.outputline("exit(1);");
         cr2.endblock();
         // end block created for worklist
+       cr2.outputline(worklist.getSafeSymbol()+"->pop();");
         cr2.endblock();
     }
 
@@ -542,8 +537,11 @@ public class RepairGenerator {
                VarDescriptor mincost=VarDescriptor.makeNew("mincost");
                VarDescriptor mincostindex=VarDescriptor.makeNew("mincostindex");
                DNFConstraint dnfconst=constraint.dnfconstraint;
-               cr.outputline("int "+mincostindex.getSafeSymbol()+";");
+               if (dnfconst.size()<=1) {
+                   cr.outputline("int "+mincostindex.getSafeSymbol()+"=0;");
+               }
                if (dnfconst.size()>1) {
+                   cr.outputline("int "+mincostindex.getSafeSymbol()+";");
                    boolean first=true;
                    for(int j=0;j<dnfconst.size();j++) {
                        Conjunction conj=dnfconst.get(j);
@@ -621,7 +619,7 @@ public class RepairGenerator {
                cr.outputline("if ("+oldmodel.getSafeSymbol()+")");
                cr.outputline("delete "+oldmodel.getSafeSymbol()+";");
                cr.outputline(oldmodel.getSafeSymbol()+"="+newmodel.getSafeSymbol()+";");
-               cr.outputline("break;");  /* Rebuild model and all */
+               cr.outputline("goto rebuild;");  /* Rebuild model and all */
 
                 cr.endblock();
 
@@ -630,7 +628,17 @@ public class RepairGenerator {
                     cr.endblock();
                 }
                cr.outputline("if ("+goodflag.getSafeSymbol()+")");
+               cr.startblock();
+               cr.outputline("if ("+repairtable.getSafeSymbol()+")");
+               cr.outputline("delete "+repairtable.getSafeSymbol()+";");
+               cr.outputline("if ("+oldmodel.getSafeSymbol()+")");
+               cr.outputline("delete "+oldmodel.getSafeSymbol()+";");
+               cr.outputline("delete "+newmodel.getSafeSymbol()+";");
+               cr.outputline("delete "+worklist.getSafeSymbol()+";");
                cr.outputline("break;");
+               cr.endblock();
+               cr.outputline("rebuild:");
+               cr.outputline(";");
                 cr.endblock();
                 cr.outputline("");
                 cr.outputline("");
index 0f11463..ce62886 100755 (executable)
@@ -219,7 +219,7 @@ class UpdateNode {
            VarDescriptor left=VarDescriptor.makeNew("left");
            u.getLeftExpr().generate(cr,left);
            Opcode op=u.getOpcode();
-           cr.outputline("if ("+left.getSafeSymbol()+op+right.getSafeSymbol()+")");
+           cr.outputline("if (!("+left.getSafeSymbol()+op+right.getSafeSymbol()+"))");
            cr.startblock();
 
            if (op==Opcode.GT)
diff --git a/Repair/RepairCompiler/MCC/ex_test.cc b/Repair/RepairCompiler/MCC/ex_test.cc
new file mode 100755 (executable)
index 0000000..c13eae6
--- /dev/null
@@ -0,0 +1,17 @@
+#include "ex_aux.h"
+
+struct Node {
+     int data;
+     struct Node *next;
+     struct Node *prev;
+};
+
+int main(int argc, char **argv) {
+  struct Node * head =0;//(struct Node *) malloc(sizeof (struct Node));
+  //  head->next=0;
+  //head->prev=0;
+
+#include "ex.cc"
+  
+  
+}