changes: now Inference engine works fine with the EyeTracking benchmark.
[IRC.git] / Robust / src / Analysis / SSJava / FlowDownCheck.java
index 4dd4eaf2b7e3a55d5d69df956c892b31d73dd244..5bce89cc1d66caa7c03194173f6a3bdcd1e1d178 100644 (file)
@@ -914,24 +914,25 @@ public class FlowDownCheck {
     // System.out.println("# false=" + tn.getFalseExpr().printNode(0) + " Loc="
     // + falseLoc);
 
-    // check if condLoc is higher than trueLoc & falseLoc
-    if (!trueLoc.get(0).isTop()
-        && !CompositeLattice.isGreaterThan(condLoc, trueLoc, generateErrorMessage(cd, tn))) {
-      throw new Error(
-          "The location of the condition expression is lower than the true expression at "
-              + cd.getSourceFileName() + ":" + tn.getCond().getNumLine());
-    }
-
-    if (!falseLoc.get(0).isTop()
-        && !CompositeLattice.isGreaterThan(condLoc, falseLoc,
-            generateErrorMessage(cd, tn.getCond()))) {
-      throw new Error(
-          "The location of the condition expression is lower than the false expression at "
-              + cd.getSourceFileName() + ":" + tn.getCond().getNumLine());
-    }
+    // we don't need to check that condLoc is higher than trueLoc & falseLoc
+    // if (!trueLoc.get(0).isTop()
+    // && !CompositeLattice.isGreaterThan(condLoc, trueLoc, generateErrorMessage(cd, tn))) {
+    // throw new Error(
+    // "The location of the condition expression is lower than the true expression at "
+    // + cd.getSourceFileName() + ":" + tn.getCond().getNumLine());
+    // }
+    //
+    // if (!falseLoc.get(0).isTop()
+    // && !CompositeLattice.isGreaterThan(condLoc, falseLoc,
+    // generateErrorMessage(cd, tn.getCond()))) {
+    // throw new Error(
+    // "The location of the condition expression is lower than the false expression at "
+    // + cd.getSourceFileName() + ":" + tn.getCond().getNumLine());
+    // }
 
     // then, return glb of trueLoc & falseLoc
     Set<CompositeLocation> glbInputSet = new HashSet<CompositeLocation>();
+    glbInputSet.add(condLoc);
     glbInputSet.add(trueLoc);
     glbInputSet.add(falseLoc);
 
@@ -1054,7 +1055,7 @@ public class FlowDownCheck {
                 + " paramCompareResult=" + paramCompareResult);
 
             if (!(paramLocation.get(0).equals(calleePCLOC.get(0)) && calleePCLOC.getSize() > 1)
-                && paramCompareResult != ComparisonResult.GREATER) {
+                && paramCompareResult == ComparisonResult.LESS) {
               throw new Error(
                   "The argument(idx="
                       + idx
@@ -1154,7 +1155,12 @@ public class FlowDownCheck {
     // System.out.println("base location=" + callerBaseLoc + " constraint=" +
     // constraint);
 
-    for (int i = 0; i < calleeParamList.size(); i++) {
+    System.out.println("calleeParamList=" + calleeParamList);
+    int offset = 0;
+    if (!md.isStatic()) {
+      offset = 1;
+    }
+    for (int i = offset; i < calleeParamList.size(); i++) {
       CompositeLocation calleeParamLoc = calleeParamList.get(i);
       if (calleeParamLoc.get(0).equals(calleeThisLoc) && calleeParamLoc.getSize() > 1) {
 
@@ -1181,6 +1187,8 @@ public class FlowDownCheck {
           continue;
         }
 
+        System.out.println("---idx=" + i + "  callerArgLoc=" + callerArgLoc + "   paramLocation="
+            + paramLocation);
         // if (!CompositeLattice.isGreaterThan(callerArgLoc, paramLocation, errorMsg)) {
         if (CompositeLattice.compare(callerArgLoc, paramLocation, true, errorMsg) == ComparisonResult.LESS) {
           throw new Error("Caller argument '" + min.getArg(i).printNode(0) + " : " + callerArgLoc
@@ -1425,12 +1433,9 @@ public class FlowDownCheck {
       // addTypeLocation(on.getRight().getType(), rightLoc);
     }
 
-    System.out.println("\n# OP NODE=" + on.printNode(0));
-    // System.out.println("# left loc=" + leftLoc + " from " +
-    // on.getLeft().getClass());
+    // System.out.println("# left loc=" + leftLoc + " from " + on.getLeft().getClass());
     // if (on.getRight() != null) {
-    // System.out.println("# right loc=" + rightLoc + " from " +
-    // on.getRight().getClass());
+    // System.out.println("# right loc=" + rightLoc + " from " + on.getRight().getClass());
     // }
 
     Operation op = on.getOp();
@@ -1741,7 +1746,7 @@ public class FlowDownCheck {
           ssjava.addSameHeightWriteFlatNode(fn);
         }
 
-      }
+      } 
 
     } else {
       destLocation =
@@ -1987,6 +1992,9 @@ public class FlowDownCheck {
 
         addLocationType(fd.getType(), loc);
 
+        if (ssjava.isSharedLocation(loc)) {
+          ssjava.addSharedDesc(loc, fd);
+        }
       }
     }
 
@@ -2127,7 +2135,11 @@ public class FlowDownCheck {
         } else if (lattice.isGreaterThan(loc1.getLocIdentifier(), loc2.getLocIdentifier())) {
           return ComparisonResult.GREATER;
         } else {
-          return ComparisonResult.LESS;
+          if (lattice.isComparable(loc1.getLocIdentifier(), loc2.getLocIdentifier())) {
+            return ComparisonResult.LESS;
+          } else {
+            return ComparisonResult.INCOMPARABLE;
+          }
         }
 
       }
@@ -2167,6 +2179,7 @@ public class FlowDownCheck {
       // composite location
 
       int maxTupleSize = 0;
+      int minTupleSize = 0;
       CompositeLocation maxCompLoc = null;
 
       Location prevPriorityLoc = null;
@@ -2176,6 +2189,9 @@ public class FlowDownCheck {
           maxTupleSize = compLoc.getSize();
           maxCompLoc = compLoc;
         }
+        if (minTupleSize == 0 || compLoc.getSize() < minTupleSize) {
+          minTupleSize = compLoc.getSize();
+        }
         Location priorityLoc = compLoc.get(0);
         String priorityLocId = priorityLoc.getLocIdentifier();
         priorityLocIdentifierSet.add(priorityLocId);
@@ -2213,7 +2229,8 @@ public class FlowDownCheck {
 
         // in this case, do not take care about delta
         // CompositeLocation inputComp = inputSet.iterator().next();
-        for (int i = 1; i < maxTupleSize; i++) {
+        // for (int i = 1; i < maxTupleSize; i++) {
+        for (int i = 1; i < minTupleSize; i++) {
           glbCompLoc.addLocation(Location.createTopLocation(maxCompLoc.get(i).getDescriptor()));
         }
       } else {