X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=Repair%2FRepairCompiler%2FMCC%2FIR%2FTermination.java;h=5d25732106884d1a26f81fce5a483f974d3559be;hb=726db8dc825fb7f33f64f0aca6a4f63b0ba43313;hp=5b741c1e26a52a1aeae1b24c9e1e256e814cdbf4;hpb=ffbc6aa80c7e3ea6aff0cae778ecdbcdbf49a175;p=repair.git diff --git a/Repair/RepairCompiler/MCC/IR/Termination.java b/Repair/RepairCompiler/MCC/IR/Termination.java index 5b741c1..5d25732 100755 --- a/Repair/RepairCompiler/MCC/IR/Termination.java +++ b/Repair/RepairCompiler/MCC/IR/Termination.java @@ -31,6 +31,12 @@ public class Termination { ExactSize exactsize; ArrayAnalysis arrayanalysis; Sources sources; + static String conjoption="style=bold"; + static String absrepoption="shape=box,color=blue,style=bold"; + static String updateoption="shape=box,color=red,style=bold"; + static String scopeoption="color=brown"; + static String conseqoption="style=bold,color=green"; + static String compoption="shape=box,color=purple,style=bold"; public Termination(State state) { this.state=state; @@ -50,7 +56,7 @@ public class Termination { predtoabstractmap=new Hashtable(); if (!Compiler.REPAIR) return; - + for(int i=0;i1)&&(op==Opcode.LT))|| + ((size>=1)&&(op==Opcode.LE))) { + for(int i2=0;i2=0;i--) { if (e==null) e=lexpr; - else + else e=((DotExpr)e).getExpr(); while (e instanceof CastExpr) @@ -1005,11 +1084,11 @@ public class Termination { return false; e=ce.getExpr(); } - + if ((e instanceof VarExpr)&& (((VarExpr)e).getVar()==vd)) { /* Can solve for v */ - if (!si.getSet().getType().isSubtypeOf(set.getType())) + if (set==null||!si.getSet().getType().isSubtypeOf(set.getType())) return false; Binding binding=new Binding(vd,0); bindings.add(binding); @@ -1029,7 +1108,7 @@ public class Termination { return false; e=ce.getExpr(); } - + if ((e instanceof VarExpr)&& (((VarExpr)e).getVar()==vd)) { /* Can solve for v */ @@ -1050,7 +1129,7 @@ public class Termination { return false; e=ce.getExpr(); } - + if ((e instanceof VarExpr)&& (((VarExpr)e).getVar()==vd)) { /* Can solve for v */ @@ -1088,7 +1167,7 @@ public class Termination { SetInclusion si=(SetInclusion)inc; Expr e=si.elementexpr; - + while(e instanceof CastExpr) { CastExpr ce=(CastExpr)e; if (ce.getType()!=td) @@ -1113,7 +1192,7 @@ public class Termination { Expr e=ri.getLeftExpr(); - + while(e instanceof CastExpr) { CastExpr ce=(CastExpr)e; if (ce.getType()!=ri.getRelation().getDomain().getType()) @@ -1133,7 +1212,7 @@ public class Termination { e=ri.getRightExpr(); - + while(e instanceof CastExpr) { CastExpr ce=(CastExpr)e; if (ce.getType()!=ri.getRelation().getRange().getType()) @@ -1168,10 +1247,10 @@ public class Termination { } return goodupdate; } - + /** Adds updates that add an item to the appropriate set or * relation quantified over by the model definition rule.. */ - + boolean processquantifiers(GraphNode gn,UpdateNode un, Rule r,Hashtable setmapping) { Inclusion inc=r.getInclusion(); for(Iterator iterator=r.quantifiers();iterator.hasNext();) { @@ -1190,7 +1269,6 @@ public class Termination { } else { return false; } - } else if (q instanceof SetQuantifier) { SetQuantifier sq=(SetQuantifier)q; if (un.getBinding(sq.var).getType()==Binding.SEARCH) { @@ -1255,7 +1333,7 @@ public class Termination { } else if (e instanceof TupleOfExpr) { Updates up=new Updates(e,de.getNegation()); un.addUpdate(up); - } else if (e instanceof BooleanLiteralExpr) { + } else if (e instanceof BooleanLiteralExpr) { boolean truth=((BooleanLiteralExpr)e).getValue(); if (de.getNegation()) truth=!truth; @@ -1332,4 +1410,29 @@ public class Termination { } return true; } + + boolean equivalent(SetExpr se, RelationExpr re) { + if (!(se instanceof ImageSetExpr)) + return false; + ImageSetExpr ise=(ImageSetExpr)se; + while(re!=null&&ise!=null) { + if (re.getRelation()!=ise.getRelation()) + return false; + if (re.inverted()!=ise.inverted()) + return false; + if (ise.isimageset) { + ise=ise.getImageSetExpr(); + if (!(re.getExpr() instanceof RelationExpr)) + return false; + re=(RelationExpr)re.getExpr(); + } else { + if (!(re.getExpr() instanceof VarExpr)) + return false; + if (((VarExpr)re.getExpr()).getVar()==ise.getVar()) + return true; //everything matches + return false; + } + } + return false; + } }