Add option to remove conjunctions.
[repair.git] / Repair / RepairCompiler / MCC / IR / Termination.java
index 046e06062ba0481f9f21aa9a4d270f8475c9dc02..32facba550d7cde1abc9663b8e0021e97d22b34d 100755 (executable)
@@ -173,6 +173,9 @@ public class Termination {
            Constraint c=(Constraint)constraints.get(i);
            DNFConstraint dnf=c.dnfconstraint;
            for(int j=0;j<dnf.size();j++) {
+               if (Compiler.removeconj.contains(new String(i+","+j)))
+                   continue;
+
                TermNode tn=new TermNode(c,dnf.get(j));
                GraphNode gn=new GraphNode("Conj"+i+"A"+j,
                                           "Conj ("+i+","+j+") "+dnf.get(j).name()
@@ -186,6 +189,8 @@ public class Termination {
            }
            // Construct quantifier "conjunction" nodes
            for(int j=0;j<c.numQuantifiers();j++) {
+               if (Compiler.removeconj.contains(new String(i+","+(j+constraints.size()))))
+                   continue;
                Quantifier q=c.getQuantifier(j);
                if (q instanceof SetQuantifier) {
                    SetQuantifier sq=(SetQuantifier)q;
@@ -195,8 +200,8 @@ public class Termination {
                    dconst=dconst.not();
                    TermNode tn=new TermNode(c,dconst.get(0));
                    tn.setquantifiernode();
-                   GraphNode gn=new GraphNode("Conj"+i+"AQ"+j,
-                                              "Conj ("+i+","+j+") "+dconst.get(0).name()
+                   GraphNode gn=new GraphNode("Conj"+i+"AQ"+(j+constraints.size()),
+                                              "Conj ("+i+","+(j+constraints.size())+") "+dconst.get(0).name()
                                               ,tn);
                    gn.setOption(conjoption);
                    conjunctions.add(gn);
@@ -213,8 +218,8 @@ public class Termination {
                    dconst=dconst.not();
                    TermNode tn=new TermNode(c,dconst.get(0));
                    tn.setquantifiernode();
-                   GraphNode gn=new GraphNode("Conj"+i+"AQ"+j,
-                                              "Conj ("+i+","+j+") "+dconst.get(0).name()
+                   GraphNode gn=new GraphNode("Conj"+i+"AQ"+(j+constraints.size()),
+                                              "Conj ("+i+","+(j+constraints.size())+") "+dconst.get(0).name()
                                               ,tn);
                    gn.setOption(conjoption);
                    conjunctions.add(gn);
@@ -464,6 +469,34 @@ public class Termination {
                }
 
                for(int j=0;j<array.length;j++) {
+                    if (array[j]==AbstractRepair.ADDTOSET) {
+
+                        System.out.println("1");
+                        if ((dp.getPredicate() instanceof ExprPredicate)&&
+                            (((ExprPredicate)dp.getPredicate()).getType()==ExprPredicate.SIZE)) {
+                            System.out.println("2");
+                            boolean neg=dp.isNegated();
+                            Opcode op=((ExprPredicate)dp.getPredicate()).getOp();
+                            int size=((ExprPredicate)dp.getPredicate()).rightSize();
+                            op=Opcode.translateOpcode(neg,op);
+                            Descriptor des=((ExprPredicate)dp.getPredicate()).getDescriptor();
+                            if (des instanceof SetDescriptor) {
+                                System.out.println("3");
+
+                                int minsize=exactsize.minSize((SetDescriptor)des);
+                                Constraint reqc=exactsize.ensuresMinSize((SetDescriptor)des);
+                                if (((size==minsize)&&(op==Opcode.EQ))||
+                                    ((size<=minsize)&&(op==Opcode.GE))||
+                                    ((size<minsize)&&(op==Opcode.GT))) {
+                                    System.out.println("4");
+                                    constraintdependence.requiresConstraint(gn,reqc);
+                                    //force good ordering
+                                    continue; //no repair action needed here...
+                                }
+                            }
+                        }
+                    }
+
                    AbstractRepair ar=new AbstractRepair(dp,array[j],d,sources);
                    TermNode tn2=new TermNode(ar);
                    //              GraphNode gn2=new GraphNode(gn.getLabel()+"A"+i+"B"+ar.type(),gn.getTextLabel()+" #"+i+" "+ar.type(),tn2);
@@ -599,7 +632,7 @@ public class Termination {
                        continue;
                    }
                }
-               if (!un.checkupdates()) /* Make sure we have a good update */
+               if (!un.checkupdates(state)) /* Make sure we have a good update */
                    continue;
 
                mun.addUpdate(un);
@@ -706,7 +739,7 @@ public class Termination {
                        goodflag=false;break;
                    }
                }
-               if (!un.checkupdates()) {
+               if (!un.checkupdates(state)) {
                    goodflag=false;
                    break;
                }
@@ -827,7 +860,7 @@ public class Termination {
                        goodflag=false;
                }
 
-               if (!un.checkupdates()) {
+               if (!un.checkupdates(state)) {
                    goodflag=false;
                    break;
                }
@@ -886,7 +919,6 @@ public class Termination {
                                continue endloop;
                            e=ce.getExpr();
                        }
-
                        if (!(e instanceof VarExpr)) {
                            if (e.isValue(si.getSet().getType())) {
                                Updates up=new Updates(e,0,si.getSet().getType());
@@ -1015,7 +1047,7 @@ public class Termination {
                        debugmsg("Finished processing quantifiers")&&
                        processconjunction(un,ruleconj,setmapping)&&
                        debugmsg("Finished processing conjunction")&&
-                       un.checkupdates()&&
+                       un.checkupdates(state)&&
                        debugmsg("Updates checked")) {
                        mun.addUpdate(un);
                        GraphNode.Edge e=new GraphNode.Edge("abstract5"+addtocount,gn2);