X-Git-Url: http://plrg.eecs.uci.edu/git/?p=repair.git;a=blobdiff_plain;f=Repair%2FRepairCompiler%2FMCC%2FIR%2FRepairGenerator.java;h=1114e1af8876f682a4271289113db61aad282eb8;hp=ba75daeaa973125c4642b5eb5e1ef01c5b2b2cc6;hb=2834d0a0299416114317d21a700c0ff7d5341996;hpb=1865e2c81c6c387dcc48114a33921e26fc0211b1 diff --git a/Repair/RepairCompiler/MCC/IR/RepairGenerator.java b/Repair/RepairCompiler/MCC/IR/RepairGenerator.java index ba75dae..1114e1a 100755 --- a/Repair/RepairCompiler/MCC/IR/RepairGenerator.java +++ b/Repair/RepairCompiler/MCC/IR/RepairGenerator.java @@ -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,20 +726,24 @@ 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"); - DNFConstraint dnfconst=constraint.dnfconstraint; + Vector dnfconst=new Vector(); + dnfconst.addAll((Set)termination.conjunctionmap.get(constraint)); + if (dnfconst.size()<=1) { cr.outputline("int "+mincostindex.getSafeSymbol()+"=0;"); } @@ -742,8 +751,8 @@ public class RepairGenerator { cr.outputline("int "+mincostindex.getSafeSymbol()+";"); boolean first=true; for(int j=0;jget("+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) { @@ -1209,7 +1221,7 @@ public class RepairGenerator { Rule r=(Rule)state.vRules.get(i); if (r.getInclusion().getTargetDescriptors().contains(rd)) { for(int j=0;jgetrelation2("+rd.getNum()+","+currentrule.getNum()+","+leftvar+","+rightvar+");"); + VarDescriptor ismdfyptr=VarDescriptor.makeNew("ismodifyptr"); + cr.outputline("int "+ismdfyptr.getSafeSymbol()+"="+repairtable.getSafeSymbol()+"->ismodify("+rd.getNum()+","+currentrule.getNum()+","+leftvar+","+rightvar+");"); + + + String parttype=""; for(int i=0;igetrelation("+rd.getNum()+","+currentrule.getNum()+","+leftvar+","+rightvar+");"); - cr.outputline("if ("+mdfyptr.getSafeSymbol()+")"); + cr.outputline("if ("+ismdfyptr.getSafeSymbol()+")"); { cr.startblock(); + cr.outputline("int "+mdfyptr.getSafeSymbol()+"="+repairtable.getSafeSymbol()+"->getrelation2("+rd.getNum()+","+currentrule.getNum()+","+leftvar+","+rightvar+");"); cr.outputline("void (*"+funptr.getSafeSymbol()+") ("+name+"_state *,"+name+"*,RepairHash *"+parttype+",int,int,int)="+"(void (*) ("+name+"_state *,"+name+"*,RepairHash *"+parttype+",int,int,int)) "+tmpptr.getSafeSymbol()+";"); cr.outputline(methodcall+","+leftvar+", "+rightvar+", "+mdfyptr.getSafeSymbol() +");"); cr.endblock(); @@ -1403,6 +1420,7 @@ public class RepairGenerator { cr.outputline(methodcall+");"); cr.endblock(); } + cr.outputline("delete "+newmodel.getSafeSymbol()+";"); cr.outputline("goto rebuild;"); } cr.endblock(); @@ -1429,6 +1447,7 @@ public class RepairGenerator { } methodcall+=");"; cr.outputline(methodcall); + cr.outputline("delete "+newmodel.getSafeSymbol()+";"); cr.outputline("goto rebuild;"); } } @@ -1436,17 +1455,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(); @@ -1525,6 +1563,7 @@ public class RepairGenerator { } methodcall+=");"; cr.outputline(methodcall); + cr.outputline("delete "+newmodel.getSafeSymbol()+";"); cr.outputline("goto rebuild;"); } cr.endblock(); @@ -1552,6 +1591,7 @@ public class RepairGenerator { } methodcall+=");"; cr.outputline(methodcall); + cr.outputline("delete "+newmodel.getSafeSymbol()+";"); cr.outputline("goto rebuild;"); } } @@ -1559,7 +1599,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);