2 bug fixes to getRequiredConstraints
authorbdemsky <bdemsky>
Wed, 12 Oct 2005 17:49:01 +0000 (17:49 +0000)
committerbdemsky <bdemsky>
Wed, 12 Oct 2005 17:49:01 +0000 (17:49 +0000)
added option to reject updates that change the layout of objects.

Repair/RepairCompiler/MCC/IR/DotExpr.java
Repair/RepairCompiler/MCC/IR/GraphAnalysis.java
Repair/RepairCompiler/MCC/IR/SemanticChecker.java
Repair/RepairCompiler/MCC/IR/Termination.java
Repair/RepairCompiler/MCC/IR/UpdateNode.java
Repair/RepairCompiler/MCC/IR/VarExpr.java

index 2e5021e940909a488fec446aa81790f79f63f319..54133026fdc63f38a933a044e3796cea27d1f3db 100755 (executable)
@@ -158,6 +158,7 @@ public class DotExpr extends Expr {
         if (intindex != null) {
             v.addAll(intindex.getRequiredDescriptors());
         }
+        v.add(fd);
         return v;
     }
 
index 6b690a859c4da45ee161c5a48367f63daf65bc20..3fdbe6e87a63ae9a6fb93443069b66bb979a1dd0 100755 (executable)
@@ -723,8 +723,9 @@ public class GraphAnalysis {
                    foundrepair=true;
                }
            }
-           if (!foundrepair)
+           if (!foundrepair) {
                return ERR_NOREPAIR;
+            }
        }
 
 
index f450bb79db62fa13078ff4d967ef34a09633f110..62c12be2180cbd8cf087761474c84a0b62048a78 100755 (executable)
@@ -3,6 +3,7 @@ package MCC.IR;
 import java.util.*;
 import java.math.BigInteger;
 import MCC.State;
+import MCC.Compiler;
 
 public class SemanticChecker {
 
@@ -995,6 +996,10 @@ public class SemanticChecker {
                                 public IRErrorReporter getErrorReporter() { return er; }
                                 public SymbolTable getSymbolTable() { return stGlobals; }
                             });
+                        if (Compiler.REJECTLENGTH) {
+                            analyze_length(indexbound);
+                        }
+
 
                         if (indextype == null) {
                             ok = false;
@@ -1035,6 +1040,20 @@ public class SemanticChecker {
         return ok;
     }
 
+    private void analyze_length(Expr indexbound) {
+        Set descriptors=indexbound.getRequiredDescriptors();
+        for(Iterator it=descriptors.iterator();it.hasNext();) {
+            Descriptor d=(Descriptor)it.next();
+            if (d instanceof FieldDescriptor) {
+                state.noupdate.add(d);
+            } else if (d instanceof ArrayDescriptor) {
+                state.noupdate.add(d);
+            } else if (d instanceof VarDescriptor) {
+                state.noupdate.add(d);
+            }
+        }
+    }
+
     private boolean parse_global(ParseNode pn) {
         if (!precheck(pn, "global")) {
             return false;
index 0d074f6a3146bdfeeb19e50c5852878ff4198d2d..8585655710d9b7362f79815640074d404bfb38f4 100755 (executable)
@@ -627,7 +627,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);
@@ -734,7 +734,7 @@ public class Termination {
                        goodflag=false;break;
                    }
                }
-               if (!un.checkupdates()) {
+               if (!un.checkupdates(state)) {
                    goodflag=false;
                    break;
                }
@@ -855,7 +855,7 @@ public class Termination {
                        goodflag=false;
                }
 
-               if (!un.checkupdates()) {
+               if (!un.checkupdates(state)) {
                    goodflag=false;
                    break;
                }
@@ -914,7 +914,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());
@@ -1043,7 +1042,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);
index ee6bdac134c291c4ecd870f71e8324ee7b8e8de8..89ffed905db057b1a0dd553c2269487e0a978e9b 100755 (executable)
@@ -44,14 +44,29 @@ class UpdateNode {
        }
     }
 
-    public boolean checkupdates() {
+    public boolean checkupdates(State state) {
        if (!checkconflicts()) /* Do we have conflicting concrete updates */
            return false;
+        if (!checknoupdates(state))
+            return false;
        if (computeordering()) /* Ordering exists */
            return true;
        return false;
     }
 
+    private boolean checknoupdates(State state) {
+        Set noupdate=state.noupdate;
+        for(int i=0;i<updates.size();i++) {
+           Updates u=(Updates)updates.get(i);
+            if (u.isAbstract())
+                continue; /* Abstract updates don't change fields */
+            Descriptor d=u.getDescriptor();
+            if (noupdate.contains(d))
+                return false;
+        }
+        return true;
+    }
+
     private boolean computeordering() {
        /* Build dependency graph between updates */
        HashSet graph=new HashSet();
index 3720a4cc6e1976d83a75f4d16353ccbf4a9f81ab..e94f6fb8cdf87b006a2b418e0ff3ec3a96e3cbbc 100755 (executable)
@@ -83,7 +83,10 @@ public class VarExpr extends Expr {
     }
 
     public Set getRequiredDescriptors() {
-        return new HashSet();
+        Set s=new HashSet();
+        s.add(vd);
+        return s;
+
     }
 
     public VarDescriptor getVar() {