changes.
[IRC.git] / Robust / src / Analysis / SSJava / FlowDownCheck.java
index 5dbf31e13b2b5eac195ef64d75da330e7011f091..4dd4eaf2b7e3a55d5d69df956c892b31d73dd244 100644 (file)
@@ -707,7 +707,7 @@ public class FlowDownCheck {
   private CompositeLocation checkLocationFromIfStatementNode(MethodDescriptor md,
       SymbolTable nametable, IfStatementNode isn, CompositeLocation constraint) {
 
-    System.out.println("checkLocationFromIfStatementNode=" + isn);
+    System.out.println("\n\ncheckLocationFromIfStatementNode=" + isn.printNode(0));
     CompositeLocation condLoc =
         checkLocationFromExpressionNode(md, nametable, isn.getCondition(), new CompositeLocation(),
             constraint, false);
@@ -1032,7 +1032,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 +1054,16 @@ public class FlowDownCheck {
                 + " paramCompareResult=" + paramCompareResult);
 
             if (!(paramLocation.get(0).equals(calleePCLOC.get(0)) && calleePCLOC.getSize() > 1)
-                && paramCompareResult != ComparisonResult.LESS) {
+                && paramCompareResult != ComparisonResult.GREATER) {
               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());
             }
 
@@ -1365,18 +1365,19 @@ public class FlowDownCheck {
 
   private CompositeLocation checkLocationFromArrayAccessNode(MethodDescriptor md,
       SymbolTable nametable, ArrayAccessNode aan, CompositeLocation constraint, boolean isLHS) {
-    // System.out.println("aan=" + aan.printNode(0) + "  line#=" + aan.getNumLine());
+    System.out.println("aan=" + aan.printNode(0) + "  line#=" + aan.getNumLine());
     ClassDescriptor cd = md.getClassDesc();
-
+    System.out.println("aan.getExpression()=" + aan.getExpression().getClass());
     CompositeLocation arrayLoc =
         checkLocationFromExpressionNode(md, nametable, aan.getExpression(),
             new CompositeLocation(), constraint, isLHS);
-
+    System.out.println("HERE?");
     // addTypeLocation(aan.getExpression().getType(), arrayLoc);
     CompositeLocation indexLoc =
         checkLocationFromExpressionNode(md, nametable, aan.getIndex(), new CompositeLocation(),
             constraint, isLHS);
     // addTypeLocation(aan.getIndex().getType(), indexLoc);
+    System.out.println("HERE2?");
 
     if (isLHS) {
       if (!CompositeLattice.isGreaterThan(indexLoc, arrayLoc, generateErrorMessage(cd, aan))) {
@@ -1388,7 +1389,11 @@ public class FlowDownCheck {
       Set<CompositeLocation> inputGLB = new HashSet<CompositeLocation>();
       inputGLB.add(arrayLoc);
       inputGLB.add(indexLoc);
-      return CompositeLattice.calculateGLB(inputGLB, generateErrorMessage(cd, aan));
+      System.out.println("arrayLoc=" + arrayLoc + "   indexLoc=" + indexLoc);
+      CompositeLocation comp =
+          CompositeLattice.calculateGLB(inputGLB, generateErrorMessage(cd, aan));
+      System.out.println("---aan=" + aan.printNode(0) + "  compLoc=" + comp);
+      return comp;
     }
 
   }
@@ -1420,7 +1425,7 @@ public class FlowDownCheck {
       // addTypeLocation(on.getRight().getType(), rightLoc);
     }
 
-    // System.out.println("\n# OP NODE=" + on.printNode(0));
+    System.out.println("\n# OP NODE=" + on.printNode(0));
     // System.out.println("# left loc=" + leftLoc + " from " +
     // on.getLeft().getClass());
     // if (on.getRight() != null) {
@@ -1487,6 +1492,7 @@ public class FlowDownCheck {
   private CompositeLocation checkLocationFromNameNode(MethodDescriptor md, SymbolTable nametable,
       NameNode nn, CompositeLocation loc, CompositeLocation constraint) {
 
+    // System.out.println("checkLocationFromNameNode nn=" + nn.printNode(0));
     NameDescriptor nd = nn.getName();
     if (nd.getBase() != null) {
       loc =
@@ -1518,6 +1524,7 @@ public class FlowDownCheck {
       } else if (d instanceof FieldDescriptor) {
         // the type of field descriptor has a location!
         FieldDescriptor fd = (FieldDescriptor) d;
+        // System.out.println("fd=" + fd);
         if (fd.isStatic()) {
           if (fd.isFinal()) {
             // if it is 'static final', the location has TOP since no one can
@@ -1525,6 +1532,7 @@ public class FlowDownCheck {
             loc.addLocation(Location.createTopLocation(md));
             return loc;
           } else {
+
             // if 'static', the location has pre-assigned global loc
             MethodLattice<String> localLattice = ssjava.getMethodLattice(md);
             String globalLocId = localLattice.getGlobalLoc();
@@ -1532,7 +1540,7 @@ public class FlowDownCheck {
               throw new Error("Global location element is not defined in the method " + md);
             }
             Location globalLoc = new Location(md, globalLocId);
-
+            System.out.println("static=" + globalLoc);
             loc.addLocation(globalLoc);
           }
         } else {
@@ -1658,6 +1666,8 @@ public class FlowDownCheck {
   private CompositeLocation checkLocationFromAssignmentNode(MethodDescriptor md,
       SymbolTable nametable, AssignmentNode an, CompositeLocation loc, CompositeLocation constraint) {
 
+    System.out.println("\n\ncheckLocationFromAssignmentNode=" + an.printNode(0));
+
     ClassDescriptor cd = md.getClassDesc();
 
     Set<CompositeLocation> inputGLBSet = new HashSet<CompositeLocation>();
@@ -1709,8 +1719,7 @@ public class FlowDownCheck {
         // generateErrorMessage(cd, an));
       }
 
-      // System.out.println("src=" + srcLocation + "  dest=" + destLocation + "  const=" +
-      // constraint);
+      System.out.println("src=" + srcLocation + "  dest=" + destLocation + "  const=" + constraint);
 
       if (!CompositeLattice.isGreaterThan(srcLocation, destLocation, generateErrorMessage(cd, an))) {
 
@@ -2254,6 +2263,7 @@ public class FlowDownCheck {
           }
 
           if (innerGLBInput.size() > 0) {
+            // System.out.println("######innerGLBInput=" + innerGLBInput);
             CompositeLocation innerGLB = CompositeLattice.calculateGLB(innerGLBInput, errMsg);
             for (int idx = 0; idx < innerGLB.getSize(); idx++) {
               glbCompLoc.addLocation(innerGLB.get(idx));
@@ -2276,7 +2286,7 @@ public class FlowDownCheck {
         }
       }
 
-      System.out.println("GLB=" + glbCompLoc + "\n");
+      System.out.println("GLB=" + glbCompLoc);
       return glbCompLoc;
 
     }