changes: generated annotated code but it still causes type errors + re-formatting...
[IRC.git] / Robust / src / Analysis / SSJava / FlowDownCheck.java
index eb7cf77b036c29395429d323076414e79e481b63..3d2459662bfe54f1be6895cd14a97d5fd91035b2 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);
 
@@ -1032,7 +1033,7 @@ public class FlowDownCheck {
 
           if (!argLocation.get(0).isTop()
               && CompositeLattice.compare(argLocation, constraint, true,
-                  generateErrorMessage(cd, min)) == ComparisonResult.LESS) {
+                  generateErrorMessage(cd, min)) == ComparisonResult.GREATER) {
 
             CompositeLocation paramLocation = calleeParamList.get(idx);
 
@@ -1054,16 +1055,16 @@ public class FlowDownCheck {
                 + " paramCompareResult=" + paramCompareResult);
 
             if (!(paramLocation.get(0).equals(calleePCLOC.get(0)) && calleePCLOC.getSize() > 1)
-                && paramCompareResult != ComparisonResult.LESS) {
+                && paramCompareResult == ComparisonResult.LESS) {
               throw new Error(
-                  "The program counter location "
-                      + constraint
-                      + " is lower than the argument(idx="
+                  "The argument(idx="
                       + idx
                       + ") location "
                       + argLocation
+                      + "is higher than the caller program counter location "
+                      + constraint
                       + ". Need to specify that the initial PC location of the callee, which is currently set to "
-                      + calleePCLOC + ", is lower than " + paramLocation + " in the method "
+                      + calleePCLOC + ", is not higher than " + paramLocation + " in the method "
                       + calleeMethodDesc.getSymbol() + ":" + min.getNumLine());
             }
 
@@ -1367,11 +1368,11 @@ public class FlowDownCheck {
       SymbolTable nametable, ArrayAccessNode aan, CompositeLocation constraint, boolean isLHS) {
     System.out.println("aan=" + aan.printNode(0) + "  line#=" + aan.getNumLine());
     ClassDescriptor cd = md.getClassDesc();
-    System.out.println("aan.getExpression()=" +aan.getExpression().getClass());
+    System.out.println("aan.getExpression()=" + aan.getExpression().getClass());
     CompositeLocation arrayLoc =
         checkLocationFromExpressionNode(md, nametable, aan.getExpression(),
             new CompositeLocation(), constraint, isLHS);
-System.out.println("HERE?");
+    System.out.println("HERE?");
     // addTypeLocation(aan.getExpression().getType(), arrayLoc);
     CompositeLocation indexLoc =
         checkLocationFromExpressionNode(md, nametable, aan.getIndex(), new CompositeLocation(),
@@ -1425,12 +1426,9 @@ System.out.println("HERE?");
       // 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();
@@ -2127,7 +2125,11 @@ System.out.println("HERE?");
         } 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 +2169,7 @@ System.out.println("HERE?");
       // composite location
 
       int maxTupleSize = 0;
+      int minTupleSize = 0;
       CompositeLocation maxCompLoc = null;
 
       Location prevPriorityLoc = null;
@@ -2176,6 +2179,9 @@ System.out.println("HERE?");
           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 +2219,8 @@ System.out.println("HERE?");
 
         // 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 {