Fixed some analysis problems...
[repair.git] / Repair / RepairCompiler / MCC / IR / ModelRuleDependence.java
index dfdcfb83682ad1610d216a4ec4f394d42e9a092e..028c4b99ecf74715599ea290b58c1c8212df0260 100755 (executable)
@@ -104,8 +104,17 @@ class ModelRuleDependence {
     private void generateEdge(Rule r1,Rule r2) {
        Descriptor d=(Descriptor) r1.getInclusion().getTargetDescriptors().iterator().next();
        int dep=checkBody(d,r2.getDNFGuardExpr());
-       if (dep==NODEPENDENCY)
-           dep=checkQuantifiers(d,r2);
+       if (dep==NODEPENDENCY) {
+           SetDescriptor bsd=null;
+           if (d instanceof SetDescriptor) {
+               SetInclusion si=(SetInclusion)r1.getInclusion();
+               if (si.getExpr() instanceof VarExpr) {
+                   VarDescriptor vd=((VarExpr)si.getExpr()).getVar();
+                   bsd=vd.getSet();
+               }
+           }
+           dep=checkQuantifiers(bsd,d,r2);
+       }
        if (dep==NODEPENDENCY)
            return;
        GraphNode gn1=(GraphNode) ruletonode.get(r1);
@@ -120,10 +129,12 @@ class ModelRuleDependence {
        boolean dependency=false;
        for(int i=0;i<drule.size();i++) {
            RuleConjunction rconj=drule.get(i);
-           for(int j=0;j<rconj.size();j++){ 
+           for(int j=0;j<rconj.size();j++) 
                DNFExpr dexpr=rconj.get(j);
                Expr e=dexpr.getExpr();
-               if (e.usesDescriptor(d)) {
+               Set descset=e.getRequiredDescriptors();
+               descset=SetDescriptor.expand(descset);
+               if (descset.contains(d)) {
                    boolean negated=dexpr.getNegation();
                    if (negated)
                        return NEGDEPENDENCY;
@@ -138,10 +149,17 @@ class ModelRuleDependence {
            return NODEPENDENCY;
     }
 
-    private int checkQuantifiers(Descriptor d, Quantifiers qs) {
+    private int checkQuantifiers(SetDescriptor bsd, Descriptor d, Quantifiers qs) {
        for (int i=0;i<qs.numQuantifiers();i++) {
            Quantifier q=qs.getQuantifier(i);
-           if (q.getRequiredDescriptors().contains(d))
+           if (q instanceof SetQuantifier&&
+               d instanceof SetDescriptor) {
+               SetQuantifier sq=(SetQuantifier)q;
+               SetDescriptor sd=(SetDescriptor)d;
+               if (sq.getSet().isSubset(sd)&&
+                   ((bsd==null)||!bsd.isSubset(sq.getSet())))
+                   return NORMDEPENDENCY;
+           } else if (q.getRequiredDescriptors().contains(d))
                return NORMDEPENDENCY;
        }
        return NODEPENDENCY;