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 2e5021e..5413302 100755 (executable)
@@ -158,6 +158,7 @@ public class DotExpr extends Expr {
         if (intindex != null) {
             v.addAll(intindex.getRequiredDescriptors());
         }
+        v.add(fd);
         return v;
     }
 
index 6b690a8..3fdbe6e 100755 (executable)
@@ -723,8 +723,9 @@ public class GraphAnalysis {
                    foundrepair=true;
                }
            }
-           if (!foundrepair)
+           if (!foundrepair) {
                return ERR_NOREPAIR;
+            }
        }
 
 
index f450bb7..62c12be 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 0d074f6..8585655 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 ee6bdac..89ffed9 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 3720a4c..e94f6fb 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() {