More bug fixes...and debug flags
authorbdemsky <bdemsky>
Wed, 12 May 2004 19:03:33 +0000 (19:03 +0000)
committerbdemsky <bdemsky>
Wed, 12 May 2004 19:03:33 +0000 (19:03 +0000)
Repair/RepairCompiler/MCC/Compiler.java
Repair/RepairCompiler/MCC/IR/DotExpr.java
Repair/RepairCompiler/MCC/IR/OpExpr.java
Repair/RepairCompiler/MCC/IR/RepairGenerator.java

index 9ecf6a653a6e40209b1e04f5cc0ed30b898fbe6a..f10b39d879db782dd6ccc9861d5f337c8e96c714 100755 (executable)
@@ -21,6 +21,8 @@ public class Compiler {
     public static boolean REPAIR=true;
     public static boolean AGGRESSIVESEARCH=false;
     public static boolean PRUNEQUANTIFIERS=false;
+    public static boolean GENERATEDEBUGHOOKS=true;
+    public static boolean GENERATEDEBUGPRINT=true;
 
     public static void main(String[] args) {
         State state = null;
index adc872120c5e865d2d8bcf36c71c512863bb19df..505459f6846caae342d7caf5d34de0a8549beca5 100755 (executable)
@@ -13,6 +13,13 @@ public class DotExpr extends Expr {
     static boolean DOTYPECHECKS=false;
     static boolean DONULL=false;
 
+    
+    public DotExpr(Expr left, String field, Expr index) {
+        this.left = left;
+        this.field = field;
+        this.index = index;
+    }
+
     public boolean isSafe() {
        if (!left.isSafe())
            return false;
@@ -28,15 +35,15 @@ public class DotExpr extends Expr {
        if (d==fd)
            s.add(this);
        left.findmatch(d,s);
-       if (index!=null)
-           index.findmatch(d,s);
+       if (intindex!=null)
+           intindex.findmatch(d,s);
     }
 
     public Set freeVars() {
        Set lset=left.freeVars();
        Set iset=null;
-       if (index!=null)
-           iset=index.freeVars();
+       if (intindex!=null)
+           iset=intindex.freeVars();
        if (lset==null)
            return iset;
        if (iset!=null)
@@ -99,18 +106,12 @@ public class DotExpr extends Expr {
        return true;
     }
 
-    
-    public DotExpr(Expr left, String field, Expr index) {
-        this.left = left;
-        this.field = field;
-        this.index = index;
-    }
 
     public Set getRequiredDescriptors() {
         Set v = left.getRequiredDescriptors();
         
-        if (index != null) {
-            v.addAll(index.getRequiredDescriptors());
+        if (intindex != null) {
+            v.addAll(intindex.getRequiredDescriptors());
         }
         return v;
     }
@@ -141,7 +142,6 @@ public class DotExpr extends Expr {
         writer.outputline("");
       
         StructureTypeDescriptor struct = (StructureTypeDescriptor) left.getType();
-        Expr intindex = index;
         Expr offsetbits;
 
         // #ATTN#: getOffsetExpr needs to be called with the fielddescriptor object that is in the vector list
@@ -311,7 +311,7 @@ public class DotExpr extends Expr {
        
        {
            /* finished typechecking...so we can fill the fields in */
-           StructureTypeDescriptor struct = (StructureTypeDescriptor) left.getType();        
+           StructureTypeDescriptor struct = (StructureTypeDescriptor) left.getType();
            FieldDescriptor fd = struct.getField(field);
            LabelDescriptor ld = struct.getLabel(field);
            if (ld != null) { /* label */
index 957a35be2fc36d91229f885d19e2d7c2c8c1011a..3fe5297050b4c68c6efc1bd1d1c9ff21f3734fae 100755 (executable)
@@ -184,9 +184,6 @@ public class OpExpr extends Expr {
        return opcode;
     }
 
-
-
-
     public boolean equals(Map remap, Expr e) {
        if (e==null||!(e instanceof OpExpr))
            return false;
index ba75daeaa973125c4642b5eb5e1ef01c5b2b2cc6..11c3ea2b956087935b33247b346207097ca58f21 100755 (executable)
@@ -86,7 +86,7 @@ public class RepairGenerator {
        generate_call();
        generate_start();
         generate_rules();
-       if (!Compiler.REPAIR) {
+       if (!Compiler.REPAIR||Compiler.GENERATEDEBUGPRINT) {
            generate_print();
        }
         generate_checks();
@@ -95,6 +95,11 @@ public class RepairGenerator {
        CodeWriter craux = new StandardCodeWriter(this.outputaux);
        crhead.outputline("};");
        craux.outputline("}");
+
+       if (Compiler.GENERATEDEBUGHOOKS) {
+           crhead.outputline("void debughook();");
+           craux.outputline("void debughook() {}");
+       }
        generatetypechecks(false);
        generate_computesizes();
        generatetypechecks(true);
@@ -721,16 +726,18 @@ public class RepairGenerator {
 
                 cr.outputline("else if (!" + constraintboolean.getSafeSymbol() + ")");
                 cr.startblock();
-                if (!Compiler.REPAIR)
+                if (!Compiler.REPAIR||Compiler.GENERATEDEBUGHOOKS)
                    cr.outputline("printf(\"fail " + escape(constraint.toString()) + ". \\n\");");
-               else {
+               
+               if (Compiler.REPAIR) {
                /* Do repairs */
                /* Build new repair table */
                cr.outputline("if ("+repairtable.getSafeSymbol()+")");
                cr.outputline("delete "+repairtable.getSafeSymbol()+";");
                 cr.outputline(repairtable.getSafeSymbol()+"=new RepairHash();");
-
                
+               if (Compiler.GENERATEDEBUGHOOKS)
+                   cr.outputline("debughook();");
                /* Compute cost of each repair */
                VarDescriptor mincost=VarDescriptor.makeNew("mincost");
                VarDescriptor mincostindex=VarDescriptor.makeNew("mincostindex");
@@ -889,15 +896,15 @@ public class RepairGenerator {
        VarDescriptor rightside=VarDescriptor.makeNew("rightside");
        VarDescriptor newvalue=VarDescriptor.makeNew("newvalue");
        if (!inverted) {
-           expr.getLeftExpr().generate(cr,leftside);
+           ((RelationExpr)expr.getLeftExpr()).getExpr().generate(cr,leftside);
            expr.getRightExpr().generate(cr,newvalue);
            cr.outputline(rd.getRange().getType().getGenerateType().getSafeSymbol()+" "+rightside.getSafeSymbol()+";");
            cr.outputline(rd.getSafeSymbol()+"_hash->get("+leftside.getSafeSymbol()+","+rightside.getSafeSymbol()+");");
        } else {
-           expr.getLeftExpr().generate(cr,rightside);
+           ((RelationExpr)expr.getLeftExpr()).getExpr().generate(cr,rightside);
            expr.getRightExpr().generate(cr,newvalue);
            cr.outputline(rd.getDomain().getType().getGenerateType().getSafeSymbol()+" "+leftside.getSafeSymbol()+";");
-           cr.outputline(rd.getSafeSymbol()+"_hashinv->get("+leftside.getSafeSymbol()+","+leftside.getSafeSymbol()+");");
+           cr.outputline(rd.getSafeSymbol()+"_hashinv->get("+rightside.getSafeSymbol()+","+leftside.getSafeSymbol()+");");
        }
        if (negated)
            if (opcode==Opcode.GT) {
@@ -1386,7 +1393,7 @@ public class RepairGenerator {
                    }
                    
                    
-               
+                   
                    cr.outputline("void *"+tmpptr.getSafeSymbol()+"=");
                    cr.outputline("(void *) "+repairtable.getSafeSymbol()+"->getrelation("+rd.getNum()+","+currentrule.getNum()+","+leftvar+","+rightvar+");");
                    cr.outputline("if ("+mdfyptr.getSafeSymbol()+")");
@@ -1436,17 +1443,36 @@ public class RepairGenerator {
        }
 
         String addeditem = (VarDescriptor.makeNew("addeditem")).getSafeSymbol();
-       cr.outputline("int " + addeditem + ";");
+       cr.outputline("int " + addeditem + "=0;");
+
+       String ifstring="if (!maybe&&";
+       boolean dogenerate=false;
+       if (rd.getDomain().getType() instanceof StructureTypeDescriptor)  {
+           dogenerate=true;
+           ifstring+=leftvar;
+       }
+
+       if (rd.getRange().getType() instanceof StructureTypeDescriptor)  {
+           if (dogenerate)
+               ifstring+="&&"+rightvar;
+           else
+               ifstring+=rightvar;
+           dogenerate=true;
+       }
+
+       ifstring+=")";
+
        if (rd.testUsage(RelationDescriptor.IMAGE)) {
+           cr.outputline(ifstring);
            cr.outputline(addeditem + " = " + rd.getSafeSymbol() + "_hash->add((int)" + leftvar + ", (int)" + rightvar+ ");");
        }
        
        if (rd.testUsage(RelationDescriptor.INVIMAGE)) {
+           cr.outputline(ifstring);
            cr.outputline(addeditem + " = " + rd.getSafeSymbol() + "_hashinv->add((int)" + rightvar + ", (int)" + leftvar + ");");
        }
        
 
-
         Vector dispatchrules = getrulelist(rd);
         
        Set toremove=new HashSet();
@@ -1559,7 +1585,11 @@ public class RepairGenerator {
        }
 
         String addeditem = (VarDescriptor.makeNew("addeditem")).getSafeSymbol();
-       cr.outputline("int " + addeditem + " = 1;");
+       cr.outputline("int " + addeditem + " = 0;");
+       if (sd.getType() instanceof StructureTypeDescriptor)  {
+           cr.outputline("if (!maybe&&"+setvar+")");
+       } else
+           cr.outputline("if (!maybe)");
        cr.outputline(addeditem + " = " + sd.getSafeSymbol() + "_hash->add((int)" + setvar +  ", (int)" + setvar + ");");
        cr.startblock();
         Vector dispatchrules = getrulelist(sd);