X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=Repair%2FRepairCompiler%2FMCC%2FIR%2FTermination.java;h=32b4a1b56866113aee0e9125c231f9a4a84aedd4;hb=202f42f08243277d9c252e6560f8366780c5478b;hp=8aa0370964d51c712852ef95bbb73ea657fca7d7;hpb=cdd4513e39de359245e55af313d8bdea2167a253;p=repair.git diff --git a/Repair/RepairCompiler/MCC/IR/Termination.java b/Repair/RepairCompiler/MCC/IR/Termination.java index 8aa0370..32b4a1b 100755 --- a/Repair/RepairCompiler/MCC/IR/Termination.java +++ b/Repair/RepairCompiler/MCC/IR/Termination.java @@ -9,6 +9,8 @@ public class Termination { Hashtable conjunctionmap; HashSet abstractrepair; + HashSet abstractrepairadd; + HashSet updatenodes; HashSet consequencenodes; @@ -19,15 +21,23 @@ public class Termination { Hashtable abstractadd; Hashtable abstractremove; Hashtable conjtonodemap; + Hashtable predtoabstractmap; Set removedset; - + ComputeMaxSize maxsize; State state; + AbstractInterferes abstractinterferes; + ConcreteInterferes concreteinterferes; + ConstraintDependence constraintdependence; + ExactSize exactsize; + ArrayAnalysis arrayanalysis; + Sources sources; public Termination(State state) { this.state=state; conjunctions=new HashSet(); conjunctionmap=new Hashtable(); abstractrepair=new HashSet(); + abstractrepairadd=new HashSet(); scopenodes=new HashSet(); scopesatisfy=new Hashtable(); scopefalsify=new Hashtable(); @@ -37,10 +47,26 @@ public class Termination { abstractadd=new Hashtable(); abstractremove=new Hashtable(); conjtonodemap=new Hashtable(); + predtoabstractmap=new Hashtable(); if (!Compiler.REPAIR) return; + + + for(int i=0;i "+gn2.getTextLabel()); if (AbstractInterferes.interferes(ar,cons)|| - AbstractInterferes.interferes(ar,dp)) { + abstractinterferes.interferes(ar,dp)) { GraphNode.Edge e=new GraphNode.Edge("interferes",gn2); gn.addEdge(e); break; @@ -206,6 +277,37 @@ public class Termination { } } } + + void generatescopenodes() { + for(int i=0;i=num) { @@ -520,6 +640,7 @@ public class Termination { /** This method generates data structure updates to implement the * abstract atomic modification specified by ar. */ + int modifycount=0; void generatemodifyrelation(GraphNode gn, AbstractRepair ar) { RelationDescriptor rd=(RelationDescriptor)ar.getDescriptor(); @@ -532,7 +653,7 @@ public class Termination { else rightindex=2; - + // construct set of possible rules Vector possiblerules=new Vector(); for(int i=0;i=0;i--) { + if (e==null) + e=lexpr; + else + e=((DotExpr)e).getExpr(); + + while (e instanceof CastExpr) + e=((CastExpr)e).getExpr(); + + DotExpr de=(DotExpr)e; + FieldDescriptor fd=ap.getField(i); + if (fd instanceof ArrayDescriptor) { + // We have an ArrayDescriptor! + Expr index=de.getIndex(); + if (!index.isValue()) {/* Not assignable */ + System.out.println("ERROR:Index isn't assignable"); + return false; + } + Updates updates=new Updates(index,i,ap,lexpr,slotnumber); + un.addUpdate(updates); + } + } + return true; + } + + /** This method constructs bindings for an update using rule + * r. The boolean flag isremoval indicates that the update + * performs a removal. The function returns true if it is able to + * generate a valid set of bindings and false otherwise. */ boolean constructbindings(Vector bindings, Rule r, boolean isremoval) { boolean goodupdate=true; @@ -609,8 +916,10 @@ public class Termination { SetDescriptor set=null; if (q instanceof SetQuantifier) { vd=((SetQuantifier)q).getVar(); - } else + set=((SetQuantifier)q).getSet(); + } else { vd=((ForQuantifier)q).getVar(); + } if(inc instanceof SetInclusion) { SetInclusion si=(SetInclusion)inc; if ((si.elementexpr instanceof VarExpr)&& @@ -618,8 +927,9 @@ public class Termination { /* Can solve for v */ Binding binding=new Binding(vd,0); bindings.add(binding); - } else + } else { goodupdate=false; + } } else if (inc instanceof RelationInclusion) { RelationInclusion ri=(RelationInclusion)inc; boolean f1=true; @@ -641,11 +951,19 @@ public class Termination { } else throw new Error("Inclusion not recognized"); if (!goodupdate) if (isremoval) { - Binding binding=new Binding(vd); + /* Removals don't need bindings anymore + Binding binding=new Binding(vd); + bindings.add(binding);*/ + goodupdate=true; + } else if (q instanceof SetQuantifier) { + /* Create new element to bind to */ + // search if the set 'set' has a size + Binding binding=new Binding(vd,set,exactsize.getsize(set)==1); bindings.add(binding); goodupdate=true; + } else - break; + goodupdate=false; } else if (q instanceof RelationQuantifier) { RelationQuantifier rq=(RelationQuantifier)q; for(int k=0;k<2;k++) { @@ -680,8 +998,9 @@ public class Termination { } else throw new Error("Inclusion not recognized"); if (!goodupdate) if (isremoval) { - Binding binding=new Binding(vd); - bindings.add(binding); + /* Removals don't need bindings anymore + Binding binding=new Binding(vd); + bindings.add(binding);*/ goodupdate=true; } else break; @@ -692,98 +1011,11 @@ public class Termination { } return goodupdate; } - - static int addtocount=0; - void generateaddtosetrelation(GraphNode gn, AbstractRepair ar) { - // System.out.println("Attempting to generate add to set"); - //System.out.println(ar.getPredicate().getPredicate().name()); - //System.out.println(ar.getPredicate().isNegated()); - for(int i=0;i=0) + continue; + } else if (q instanceof RelationQuantifier) { + RelationDescriptor rd=((RelationQuantifier)q).getRelation(); + if (maxsize.getsize(rd)<=1&& + maxsize.getsize(rd)>=0) + continue; + } + return false; + } + return true; + } - ScopeNode falsify=new ScopeNode(r,false); - TermNode tnfalsify=new TermNode(falsify); - GraphNode gnfalsify=new GraphNode("FalsifyRule"+i,tnfalsify); - ConsequenceNode cnfalsify=new ConsequenceNode(); - TermNode ctnfalsify=new TermNode(cnfalsify); - GraphNode cgnfalsify=new GraphNode("ConseqFalsifyRule"+i,ctnfalsify); - consequence.put(falsify,cgnfalsify); - GraphNode.Edge efals=new GraphNode.Edge("consequencefalsify"+i,cgnfalsify); - gnfalsify.addEdge(efals); - consequencenodes.add(cgnfalsify); - scopefalsify.put(r,gnfalsify); - scopenodes.add(gnfalsify); + public boolean mutuallyexclusive(SetDescriptor sd1, SetDescriptor sd2) { + if (mutualexclusive(sd1,sd2)|| + mutualexclusive(sd2,sd1)) + return true; + else + return false; + } + + private boolean mutualexclusive(SetDescriptor sd1, SetDescriptor sd2) { + Vector rules=state.vRules; + for(int i=0;i