X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=Repair%2FRepairCompiler%2FMCC%2FIR%2FTermination.java;h=55f49522eb3b8d4d0ab834ffe628749282435816;hb=aba31a4e9a0ea1e1cf30a6f4eb66baca2ae52c5d;hp=7f9adc08e8ace7d684e15effdc8be5f7e2c6cfd3;hpb=818e376c5aeeeb458febe75f3d6273a94f3bcf7d;p=repair.git diff --git a/Repair/RepairCompiler/MCC/IR/Termination.java b/Repair/RepairCompiler/MCC/IR/Termination.java index 7f9adc0..55f4952 100755 --- a/Repair/RepairCompiler/MCC/IR/Termination.java +++ b/Repair/RepairCompiler/MCC/IR/Termination.java @@ -1,16 +1,28 @@ package MCC.IR; import java.util.*; +import java.io.*; import MCC.State; +import MCC.Compiler; public class Termination { HashSet conjunctions; Hashtable conjunctionmap; HashSet abstractrepair; + HashSet abstractrepairadd; + + HashSet updatenodes; + HashSet consequencenodes; HashSet scopenodes; Hashtable scopesatisfy; Hashtable scopefalsify; + Hashtable consequence; + Hashtable abstractadd; + Hashtable abstractremove; + Hashtable conjtonodemap; + Hashtable predtoabstractmap; + Set removedset; State state; @@ -19,15 +31,75 @@ public class Termination { conjunctions=new HashSet(); conjunctionmap=new Hashtable(); abstractrepair=new HashSet(); + abstractrepairadd=new HashSet(); scopenodes=new HashSet(); scopesatisfy=new Hashtable(); scopefalsify=new Hashtable(); + consequence=new Hashtable(); + updatenodes=new HashSet(); + consequencenodes=new HashSet(); + abstractadd=new Hashtable(); + abstractremove=new Hashtable(); + conjtonodemap=new Hashtable(); + predtoabstractmap=new Hashtable(); + if (!Compiler.REPAIR) + return; generateconjunctionnodes(); + generatescopenodes(); generaterepairnodes(); - generateabstractedges(); generatedatastructureupdatenodes(); - generatescopenodes(); + generatecompensationnodes(); + + generateabstractedges(); + generatescopeedges(); + generateupdateedges(); + + HashSet superset=new HashSet(); + superset.addAll(conjunctions); + HashSet closureset=new HashSet(); + // closureset.addAll(updatenodes); + //superset.addAll(abstractrepair); + //superset.addAll(updatenodes); + //superset.addAll(scopenodes); + //superset.addAll(consequencenodes); + GraphNode.computeclosure(superset,closureset); + try { + GraphNode.DOTVisitor.visit(new FileOutputStream("graph.dot"),superset); + } catch (Exception e) { + e.printStackTrace(); + System.exit(-1); + } + for(Iterator it=updatenodes.iterator();it.hasNext();) { + GraphNode gn=(GraphNode)it.next(); + TermNode tn=(TermNode)gn.getOwner(); + MultUpdateNode mun=tn.getUpdate(); + System.out.println(gn.getTextLabel()); + System.out.println(mun.toString()); + } + GraphAnalysis ga=new GraphAnalysis(this); + removedset=ga.doAnalysis(); + if (removedset==null) { + System.out.println("Can't generate terminating repair algorithm!"); + System.exit(-1); + } + System.out.println("Removing:"); + for(Iterator it=removedset.iterator();it.hasNext();) { + GraphNode gn=(GraphNode)it.next(); + System.out.println(gn.getTextLabel()); + } + + superset=new HashSet(); + superset.addAll(conjunctions); + superset.removeAll(removedset); + GraphNode.computeclosure(superset,removedset); + try { + GraphNode.DOTVisitor.visit(new FileOutputStream("graphfinal.dot"),superset); + } catch (Exception e) { + e.printStackTrace(); + System.exit(-1); + } + } void generateconjunctionnodes() { @@ -37,9 +109,70 @@ public class Termination { DNFConstraint dnf=c.dnfconstraint; for(int j=0;j=num) { + count[i+1]++; + count[i]=0; + } else break; + } + } + + static boolean remains(int count[], Vector rules, boolean isremove) { + for(int i=0;i=num) { + return false; + } + } + return true; + } + + /** 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(); + ExprPredicate exprPredicate=(ExprPredicate)ar.getPredicate().getPredicate(); + boolean inverted=exprPredicate.inverted(); + int leftindex=0; + int rightindex=1; + if (inverted) + leftindex=2; + else + rightindex=2; + + + Vector possiblerules=new Vector(); + for(int i=0;i