From: bdemsky Date: Mon, 5 Jan 2004 19:02:34 +0000 (+0000) Subject: Still adding code to construct termination graph, abstract repair actions, concrete... X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=cd8c06f13c3d628b15f745790e3eeac2891c5736;p=repair.git Still adding code to construct termination graph, abstract repair actions, concrete repair actions, edge, etc... --- diff --git a/Repair/RepairCompiler/MCC/IR/AbstractInterferes.java b/Repair/RepairCompiler/MCC/IR/AbstractInterferes.java index 5122d07..569485c 100755 --- a/Repair/RepairCompiler/MCC/IR/AbstractInterferes.java +++ b/Repair/RepairCompiler/MCC/IR/AbstractInterferes.java @@ -92,9 +92,93 @@ class AbstractInterferes { (neg2&&(op2==Opcode.LT)&&(size1a>=size2))) return false; } + } + return true; + } + static public boolean interferes(Descriptor des, boolean satisfy, DNFPredicate dp) { + if ((des!=dp.getPredicate().getDescriptor()) && + ((des instanceof SetDescriptor)|| + !dp.getPredicate().usesDescriptor((RelationDescriptor)des))) + return false; + /* This if handles all the c comparisons in the paper */ + if (des==dp.getPredicate().getDescriptor()&& + (satisfy)&& + (dp.getPredicate() instanceof ExprPredicate)&& + (((ExprPredicate)dp.getPredicate()).getType()==ExprPredicate.SIZE)) { + boolean neg2=dp.isNegated(); + Opcode op2=((ExprPredicate)dp.getPredicate()).getOp(); + int size2=((ExprPredicate)dp.getPredicate()).leftsize(); + { + if ((!neg2&&(op2==Opcode.GE))|| + (!neg2&&(op2==Opcode.GT))|| + (neg2&&(op2==Opcode.LE))|| + (neg2&&(op2==Opcode.LT))) + return false; + } + } + /* This if handles all the c comparisons in the paper */ + if (des==dp.getPredicate().getDescriptor()&& + (!satisfy)&& + (dp.getPredicate() instanceof ExprPredicate)&& + (((ExprPredicate)dp.getPredicate()).getType()==ExprPredicate.SIZE)) { + boolean neg2=dp.isNegated(); + Opcode op2=((ExprPredicate)dp.getPredicate()).getOp(); + int size2=((ExprPredicate)dp.getPredicate()).leftsize(); + { + if ((neg2&&(op2==Opcode.GE))|| + (neg2&&(op2==Opcode.GT))|| + (!neg2&&(op2==Opcode.LE))|| + (!neg2&&(op2==Opcode.LT))) + return false; + } } return true; } + + static public boolean interferes(Descriptor des, boolean satisfy, Rule r, boolean satisfyrule) { + for(int i=0;i Superblock, while, d.b ==> Block + fd = ld.getField(); + assert fd != null; + assert intindex == null; + intindex = ld.getIndex(); + } else { + fieldtype = fd.getType(); + intindex=index; + } + this.fd=fd; } public Set getRequiredDescriptors() { @@ -32,7 +51,6 @@ public class DotExpr extends Expr { if (index != null) { v.addAll(index.getRequiredDescriptors()); } - return v; } @@ -40,6 +58,14 @@ public class DotExpr extends Expr { return left; } + public FieldDescriptor getField() { + return fd; + } + + public Expr getIndex() { + return intindex; + } + public void generate(CodeWriter writer, VarDescriptor dest) { VarDescriptor leftd = VarDescriptor.makeNew("left"); @@ -54,23 +80,9 @@ public class DotExpr extends Expr { writer.outputline(""); StructureTypeDescriptor struct = (StructureTypeDescriptor) left.getType(); - FieldDescriptor fd = struct.getField(field); - LabelDescriptor ld = struct.getLabel(field); - TypeDescriptor fieldtype; Expr intindex = index; Expr offsetbits; - if (ld != null) { /* label */ - assert fd == null; - fieldtype = ld.getType(); // d.s ==> Superblock, while, d.b ==> Block - fd = ld.getField(); - assert fd != null; - assert intindex == null; - intindex = ld.getIndex(); - } else { - fieldtype = fd.getType(); - } - // #ATTN#: getOffsetExpr needs to be called with the fielddescriptor obect that is in teh vector list // this means that if the field is an arraydescriptor you have to call getOffsetExpr with the array // descriptor not the underlying field descriptor diff --git a/Repair/RepairCompiler/MCC/IR/ForQuantifier.java b/Repair/RepairCompiler/MCC/IR/ForQuantifier.java index e4150d2..5739d63 100755 --- a/Repair/RepairCompiler/MCC/IR/ForQuantifier.java +++ b/Repair/RepairCompiler/MCC/IR/ForQuantifier.java @@ -14,13 +14,21 @@ public class ForQuantifier extends Quantifier { this.var = vd; } + public VarDescriptor getVar() { + return var; + } + + public void setBounds(Expr lower, Expr upper) { this.lower = lower; this.upper = upper; } public Set getRequiredDescriptors() { - return new HashSet(); + HashSet set=new HashSet(); + set.addAll(lower.getRequiredDescriptors()); + set.addAll(upper.getRequiredDescriptors()); + return set; } public String toString() { diff --git a/Repair/RepairCompiler/MCC/IR/MultUpdateNode.java b/Repair/RepairCompiler/MCC/IR/MultUpdateNode.java new file mode 100755 index 0000000..fdddbeb --- /dev/null +++ b/Repair/RepairCompiler/MCC/IR/MultUpdateNode.java @@ -0,0 +1,23 @@ +package MCC.IR; +import java.util.*; + +class MultUpdateNode { + Vector updates; + AbstractRepair abstractrepair; + public MultUpdateNode(AbstractRepair ar) { + updates=new Vector(); + abstractrepair=ar; + } + void addUpdate(UpdateNode un) { + updates.add(un); + } + int numUpdates() { + return updates.size(); + } + AbstractRepair getRepair() { + return abstractrepair; + } + UpdateNode getUpdate(int i) { + return (UpdateNode)updates.get(i); + } +} diff --git a/Repair/RepairCompiler/MCC/IR/OpExpr.java b/Repair/RepairCompiler/MCC/IR/OpExpr.java index 47a6fae..b3af827 100755 --- a/Repair/RepairCompiler/MCC/IR/OpExpr.java +++ b/Repair/RepairCompiler/MCC/IR/OpExpr.java @@ -16,6 +16,10 @@ public class OpExpr extends Expr { assert (right == null && opcode == Opcode.NOT) || (right != null); } + public Opcode getOpcode() { + return opcode; + } + public DNFRule constructDNF() { if (opcode==Opcode.AND) { DNFRule leftd=left.constructDNF(); @@ -28,7 +32,7 @@ public class OpExpr extends Expr { } else if (opcode==Opcode.NOT) { DNFRule leftd=left.constructDNF(); return leftd.not(); - } else throw new Error(); + } else return new DNFRule(this); } public boolean usesDescriptor(RelationDescriptor rd) { diff --git a/Repair/RepairCompiler/MCC/IR/Quantifier.java b/Repair/RepairCompiler/MCC/IR/Quantifier.java index 3f302b8..2f5c170 100755 --- a/Repair/RepairCompiler/MCC/IR/Quantifier.java +++ b/Repair/RepairCompiler/MCC/IR/Quantifier.java @@ -3,7 +3,6 @@ package MCC.IR; import java.util.*; public abstract class Quantifier { - public abstract Set getRequiredDescriptors(); public abstract void generate_open(CodeWriter writer); diff --git a/Repair/RepairCompiler/MCC/IR/Rule.java b/Repair/RepairCompiler/MCC/IR/Rule.java index 69e8d0d..12650d9 100755 --- a/Repair/RepairCompiler/MCC/IR/Rule.java +++ b/Repair/RepairCompiler/MCC/IR/Rule.java @@ -12,7 +12,8 @@ public class Rule { Expr guard = null; Inclusion inclusion = null; SymbolTable st = new SymbolTable(); - + DNFRule dnfguard=null,dnfnegguard=null; + String label; int num; @@ -22,6 +23,14 @@ public class Rule { label = new String("rule" + count++); } + public int numQuantifiers() { + return quantifiers.size(); + } + + public Quantifier getQuantifier(int i) { + return (Quantifier) quantifiers.get(i); + } + public int getNum() { return num; } @@ -48,12 +57,23 @@ public class Rule { public void setGuardExpr(Expr guard) { this.guard = guard; + dnfguard=guard.constructDNF(); + OpExpr opexpr=new OpExpr(Opcode.NOT,guard,null); + dnfnegguard=opexpr.constructDNF(); } public Expr getGuardExpr() { return guard; } + public DNFRule getDNFGuardExpr() { + return dnfguard; + } + + public DNFRule getDNFNegGuardExpr() { + return dnfnegguard; + } + public void setInclusion(Inclusion inclusion) { this.inclusion = inclusion; } diff --git a/Repair/RepairCompiler/MCC/IR/RuleConjunction.java b/Repair/RepairCompiler/MCC/IR/RuleConjunction.java index c1aa03b..b2723bc 100755 --- a/Repair/RepairCompiler/MCC/IR/RuleConjunction.java +++ b/Repair/RepairCompiler/MCC/IR/RuleConjunction.java @@ -34,7 +34,7 @@ public class RuleConjunction { public RuleConjunction copy() { Vector vector=new Vector(); - for (int i=0;i<=size();i++) { + for (int i=0;i=(((Rule)rules.get(i)).numQuantifiers()+(((Rule)rules.get(i)).getDNFNegGuardExpr().size()))) { + count[i+1]++; + count[i]=0; + } else break; + } + } + + static boolean remains(int count[], Vector rules) { + for(int i=0;i=(((Rule)rules.get(i)).numQuantifiers()+(((Rule)rules.get(i)).getDNFNegGuardExpr().size()))) { + return false; + } + } + return true; + } + + void generateremovefromrelation(GraphNode gn,AbstractRepair ar) {} + void generateaddtorelation(GraphNode gn,AbstractRepair ar) {} + void generatemodifyrelation(GraphNode gn, AbstractRepair ar) {} + + static int addtocount=0; + void generateaddtoset(GraphNode gn, AbstractRepair ar) { for(int i=0;i