found compilation errors from david's recent commits . have interim fixes to make...
authoryeom <yeom>
Fri, 16 Sep 2011 21:16:58 +0000 (21:16 +0000)
committeryeom <yeom>
Fri, 16 Sep 2011 21:16:58 +0000 (21:16 +0000)
Robust/src/Analysis/SSJava/ImplicitTuple.java
Robust/src/Analysis/SSJava/SSJavaInferenceEngine.java
Robust/src/Analysis/SSJava/VarID.java

index e56674b7e6c5cb127d9845af5b6ac0da241f9a44..60a3cb3b4726e149256b1a4f9bdb1a3ba573138d 100644 (file)
@@ -1,22 +1,25 @@
 package Analysis.SSJava;
 
-import IR.Tree.ExpressionNode;
+import IR.Tree.TreeNode;
 
 //contains a varID and what branch that var has implicit flow on
-public class ImplicitTuple{
-    private VarID var;
-    private ExpressionNode branchID;
+public class ImplicitTuple {
+  private VarID var;
+  private TreeNode branchID;  // interim fixes
 
-    public ImplicitTuple(VarID var, ExpressionNode branchID){
-       this.var = var;
-       this.branchID = branchID;
-    }
+  // interim fixes
+  public ImplicitTuple(VarID var, TreeNode branchID) {
+    this.var = var;
+    this.branchID = branchID;
+  }
 
-    public VarID getVar(){
-       return var;
-    }
+  public VarID getVar() {
+    return var;
+  }
+
+  public boolean isFromBranch(TreeNode ln) {
+    // interim fixes
+    return true;
+  }
 
-    public boolean isFromBranch(ExpressionNode branchID){
-       return this.branchID == branchID;
-    }
 }
\ No newline at end of file
index 1c86d35b807ad4f2b584866ea44c840ea95cddff..39e3de14e216a499b08ed628f6edcd5d31d52492 100644 (file)
@@ -1,5 +1,8 @@
 package Analysis.SSJava;
 
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
@@ -8,15 +11,7 @@ import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.Vector;
-import java.io.FileWriter;
-import java.io.PrintWriter;
-import java.io.IOException;
 
-import Analysis.SSJava.FlowDownCheck.ComparisonResult;
-import Analysis.SSJava.FlowDownCheck.CompositeLattice;
-import IR.AnnotationDescriptor;
 import IR.ClassDescriptor;
 import IR.Descriptor;
 import IR.FieldDescriptor;
@@ -25,33 +20,21 @@ import IR.NameDescriptor;
 import IR.Operation;
 import IR.State;
 import IR.SymbolTable;
-import IR.TypeDescriptor;
 import IR.VarDescriptor;
-import IR.Tree.ArrayAccessNode;
 import IR.Tree.AssignmentNode;
 import IR.Tree.BlockExpressionNode;
 import IR.Tree.BlockNode;
 import IR.Tree.BlockStatementNode;
-import IR.Tree.CastNode;
-import IR.Tree.CreateObjectNode;
 import IR.Tree.DeclarationNode;
 import IR.Tree.ExpressionNode;
-import IR.Tree.FieldAccessNode;
 import IR.Tree.IfStatementNode;
 import IR.Tree.Kind;
 import IR.Tree.LiteralNode;
 import IR.Tree.LoopNode;
-import IR.Tree.MethodInvokeNode;
 import IR.Tree.NameNode;
 import IR.Tree.OpNode;
 import IR.Tree.ReturnNode;
 import IR.Tree.SubBlockNode;
-import IR.Tree.SwitchBlockNode;
-import IR.Tree.SwitchStatementNode;
-import IR.Tree.SynchronizedNode;
-import IR.Tree.TertiaryNode;
-import IR.Tree.TreeNode;
-import Util.Pair;
 
 public class SSJavaInferenceEngine {
 
@@ -73,7 +56,11 @@ public class SSJavaInferenceEngine {
   // mapping from 'locID' to 'class descriptor'
   Hashtable<String, ClassDescriptor> fieldLocName2cd;
 
-    private Set<ImplicitTuple> implicitFlowSet;  /*should maybe be hashtable<ExpressionNode,Set<VarID>>*/
+  private Set<ImplicitTuple> implicitFlowSet; /*
+                                               * should maybe be
+                                               * hashtable<ExpressionNode
+                                               * ,Set<VarID>>
+                                               */
   private RelationSet rSet;
 
   boolean deterministic = true;
@@ -192,14 +179,14 @@ public class SSJavaInferenceEngine {
     FileWriter latticeFile;
     PrintWriter latticeOut;
     setupToAnalyze();
-    
+
     while (!toAnalyzeIsEmpty()) {
       ClassDescriptor cd = toAnalyzeNext();
-      try{
-      latticeFile = new FileWriter(cd.getClassName()+".lat");
-      } catch(IOException e){
-         System.out.println("File Fail");
-         return;
+      try {
+        latticeFile = new FileWriter(cd.getClassName() + ".lat");
+      } catch (IOException e) {
+        System.out.println("File Fail");
+        return;
       }
       latticeOut = new PrintWriter(latticeFile);
       if (ssjava.needToBeAnnoated(cd)) {
@@ -207,10 +194,10 @@ public class SSJavaInferenceEngine {
         while (!toAnalyzeMethodIsEmpty()) {
           MethodDescriptor md = toAnalyzeMethodNext();
           if (ssjava.needTobeAnnotated(md)) {
-           inferRelationsFromBlockNode(md, md.getParameterTable(), state.getMethodBody(md));
-           latticeOut.println(md.getClassMethodName() + "\n");
-           latticeOut.println(rSet.toString());
-           rSet = new RelationSet();
+            inferRelationsFromBlockNode(md, md.getParameterTable(), state.getMethodBody(md));
+            latticeOut.println(md.getClassMethodName() + "\n");
+            latticeOut.println(rSet.toString());
+            rSet = new RelationSet();
           }
         }
       }
@@ -219,8 +206,7 @@ public class SSJavaInferenceEngine {
     }
   }
 
-  private void inferRelationsFromBlockNode(MethodDescriptor md, SymbolTable nametable,
-      BlockNode bn) {
+  private void inferRelationsFromBlockNode(MethodDescriptor md, SymbolTable nametable, BlockNode bn) {
 
     bn.getVarTable().setParent(nametable);
     for (int i = 0; i < bn.size(); i++) {
@@ -230,8 +216,8 @@ public class SSJavaInferenceEngine {
 
   }
 
-  private void inferRelationsFromBlockStatementNode(MethodDescriptor md,
-      SymbolTable nametable, BlockStatementNode bsn) {
+  private void inferRelationsFromBlockStatementNode(MethodDescriptor md, SymbolTable nametable,
+      BlockStatementNode bsn) {
 
     switch (bsn.kind()) {
     case Kind.BlockExpressionNode:
@@ -241,7 +227,7 @@ public class SSJavaInferenceEngine {
     case Kind.DeclarationNode:
       inferRelationsFromDeclarationNode(md, nametable, (DeclarationNode) bsn);
       break;
-      
+
     case Kind.IfStatementNode:
       inferRelationsFromIfStatementNode(md, nametable, (IfStatementNode) bsn);
       break;
@@ -257,62 +243,58 @@ public class SSJavaInferenceEngine {
     case Kind.SubBlockNode:
       inferRelationsFromSubBlockNode(md, nametable, (SubBlockNode) bsn);
       break;
-      /*
-    case Kind.ContinueBreakNode:
-      compLoc = new CompositeLocation();
-      break;
-
-    case Kind.SwitchStatementNode:
-      inferRelationsFromSwitchStatementNode(md, nametable, (SwitchStatementNode) bsn, constraint);
-      break;
-*/
+    /*
+     * case Kind.ContinueBreakNode: compLoc = new CompositeLocation(); break;
+     * 
+     * case Kind.SwitchStatementNode: inferRelationsFromSwitchStatementNode(md,
+     * nametable, (SwitchStatementNode) bsn, constraint); break;
+     */
     default:
-       System.out.println(bsn.kind() + " not handled...");
+      System.out.println(bsn.kind() + " not handled...");
       break;
     }
   }
 
-    /*private CompositeLocation inferRelationsFromSwitchStatementNode(MethodDescriptor md,
-      SymbolTable nametable, SwitchStatementNode ssn, CompositeLocation constraint) {
-
-    ClassDescriptor cd = md.getClassDesc();
-    CompositeLocation condLoc =
-        inferRelationsFromExpressionNode(md, nametable, ssn.getCondition(), new CompositeLocation(),
-            constraint, false);
-    BlockNode sbn = ssn.getSwitchBody();
-
-    constraint = generateNewConstraint(constraint, condLoc);
-
-    for (int i = 0; i < sbn.size(); i++) {
-      inferRelationsFromSwitchBlockNode(md, nametable, (SwitchBlockNode) sbn.get(i), constraint);
-    }
-    return new CompositeLocation();
-  }
-    
-  private void inferRelationsFromSwitchBlockNode(MethodDescriptor md,
-      SymbolTable nametable, SwitchBlockNode sbn) {
-
-    CompositeLocation blockLoc =
-        inferRelationsFromBlockNode(md, nametable, sbn.getSwitchBlockStatement(), constraint);
-
-    return blockLoc;
-
-  }
-    */
+  /*
+   * private CompositeLocation
+   * inferRelationsFromSwitchStatementNode(MethodDescriptor md, SymbolTable
+   * nametable, SwitchStatementNode ssn, CompositeLocation constraint) {
+   * 
+   * ClassDescriptor cd = md.getClassDesc(); CompositeLocation condLoc =
+   * inferRelationsFromExpressionNode(md, nametable, ssn.getCondition(), new
+   * CompositeLocation(), constraint, false); BlockNode sbn =
+   * ssn.getSwitchBody();
+   * 
+   * constraint = generateNewConstraint(constraint, condLoc);
+   * 
+   * for (int i = 0; i < sbn.size(); i++) {
+   * inferRelationsFromSwitchBlockNode(md, nametable, (SwitchBlockNode)
+   * sbn.get(i), constraint); } return new CompositeLocation(); }
+   * 
+   * private void inferRelationsFromSwitchBlockNode(MethodDescriptor md,
+   * SymbolTable nametable, SwitchBlockNode sbn) {
+   * 
+   * CompositeLocation blockLoc = inferRelationsFromBlockNode(md, nametable,
+   * sbn.getSwitchBlockStatement(), constraint);
+   * 
+   * return blockLoc;
+   * 
+   * }
+   */
   private void inferRelationsFromReturnNode(MethodDescriptor md, SymbolTable nametable,
       ReturnNode rn) {
 
     ExpressionNode returnExp = rn.getReturnExpression();
 
-    VarID returnID = new VarID();
+    // interim fixes
+    VarID returnID = new VarID(md);
     returnID.setReturn();
     if (returnExp != null) {
-       inferRelationsFromExpressionNode(md, nametable, returnExp, returnID, null, false);
+      inferRelationsFromExpressionNode(md, nametable, returnExp, returnID, null, false);
     }
   }
 
-  private void inferRelationsFromLoopNode(MethodDescriptor md, SymbolTable nametable,
-      LoopNode ln) {
+  private void inferRelationsFromLoopNode(MethodDescriptor md, SymbolTable nametable, LoopNode ln) {
 
     ClassDescriptor cd = md.getClassDesc();
     if (ln.getType() == LoopNode.WHILELOOP || ln.getType() == LoopNode.DOWHILELOOP) {
@@ -321,11 +303,11 @@ public class SSJavaInferenceEngine {
 
       inferRelationsFromBlockNode(md, nametable, ln.getBody());
 
-      for(ImplicitTuple tuple: implicitFlowSet){
-        if(tuple.isFromBranch(ln)){
+      for (ImplicitTuple tuple : implicitFlowSet) {
+        if (tuple.isFromBranch(ln)) {
           implicitFlowSet.remove(tuple);
         }
-      }  
+      }
 
     } else {
       // check 'for loop' case
@@ -338,8 +320,8 @@ public class SSJavaInferenceEngine {
       inferRelationsFromBlockNode(md, bn.getVarTable(), ln.getUpdate());
       inferRelationsFromBlockNode(md, bn.getVarTable(), ln.getBody());
 
-      for(ImplicitTuple tuple: implicitFlowSet){
-        if(tuple.isFromBranch(ln)){
+      for (ImplicitTuple tuple : implicitFlowSet) {
+        if (tuple.isFromBranch(ln)) {
           implicitFlowSet.remove(tuple);
         }
       }
@@ -348,16 +330,15 @@ public class SSJavaInferenceEngine {
 
   }
 
-  private void inferRelationsFromSubBlockNode(MethodDescriptor md,
-      SymbolTable nametable, SubBlockNode sbn) {
-     inferRelationsFromBlockNode(md, nametable, sbn.getBlockNode());
+  private void inferRelationsFromSubBlockNode(MethodDescriptor md, SymbolTable nametable,
+      SubBlockNode sbn) {
+    inferRelationsFromBlockNode(md, nametable, sbn.getBlockNode());
   }
 
-  
-  private void inferRelationsFromIfStatementNode(MethodDescriptor md,
-      SymbolTable nametable, IfStatementNode isn) {
+  private void inferRelationsFromIfStatementNode(MethodDescriptor md, SymbolTable nametable,
+      IfStatementNode isn) {
 
-      inferRelationsFromExpressionNode(md, nametable, isn.getCondition(), null, isn, false);
+    inferRelationsFromExpressionNode(md, nametable, isn.getCondition(), null, isn, false);
 
     inferRelationsFromBlockNode(md, nametable, isn.getTrueBlock());
 
@@ -365,30 +346,31 @@ public class SSJavaInferenceEngine {
       inferRelationsFromBlockNode(md, nametable, isn.getFalseBlock());
     }
 
-    for(ImplicitTuple tuple: implicitFlowSet){
-      if(tuple.isFromBranch(isn)){
+    for (ImplicitTuple tuple : implicitFlowSet) {
+      if (tuple.isFromBranch(isn)) {
         implicitFlowSet.remove(tuple);
       }
     }
   }
 
-  private void inferRelationsFromDeclarationNode(MethodDescriptor md,
-      SymbolTable nametable, DeclarationNode dn) {
+  private void inferRelationsFromDeclarationNode(MethodDescriptor md, SymbolTable nametable,
+      DeclarationNode dn) {
   }
 
-    /*private void inferRelationsFromSubBlockNode(MethodDescriptor md, SymbolTable nametable,
-      SubBlockNode sbn) {
-    inferRelationsFromBlockNode(md, nametable.getParent(), sbn.getBlockNode());
-    }*/
-
-  private void inferRelationsFromBlockExpressionNode(MethodDescriptor md,
-      SymbolTable nametable, BlockExpressionNode ben) {
-      inferRelationsFromExpressionNode(md, nametable, ben.getExpression(), null, null, false);
+  /*
+   * private void inferRelationsFromSubBlockNode(MethodDescriptor md,
+   * SymbolTable nametable, SubBlockNode sbn) { inferRelationsFromBlockNode(md,
+   * nametable.getParent(), sbn.getBlockNode()); }
+   */
+
+  private void inferRelationsFromBlockExpressionNode(MethodDescriptor md, SymbolTable nametable,
+      BlockExpressionNode ben) {
+    inferRelationsFromExpressionNode(md, nametable, ben.getExpression(), null, null, false);
     // addTypeLocation(ben.getExpression().getType(), compLoc);
   }
 
-  private VarID inferRelationsFromExpressionNode(MethodDescriptor md,
-     SymbolTable nametable, ExpressionNode en, VarID flowTo, BlockStatementNode implicitTag, boolean isLHS) {
+  private VarID inferRelationsFromExpressionNode(MethodDescriptor md, SymbolTable nametable,
+      ExpressionNode en, VarID flowTo, BlockStatementNode implicitTag, boolean isLHS) {
 
     VarID var = null;
     switch (en.kind()) {
@@ -398,45 +380,39 @@ public class SSJavaInferenceEngine {
           inferRelationsFromAssignmentNode(md, nametable, (AssignmentNode) en, flowTo, implicitTag);
       break;
 
-      //   case Kind.FieldAccessNode:
-      // var =
-      //    inferRelationsFromFieldAccessNode(md, nametable, (FieldAccessNode) en, flowTo);
-      // break;
+    // case Kind.FieldAccessNode:
+    // var =
+    // inferRelationsFromFieldAccessNode(md, nametable, (FieldAccessNode) en,
+    // flowTo);
+    // break;
 
     case Kind.NameNode:
-       var = inferRelationsFromNameNode(md, nametable, (NameNode) en, flowTo, implicitTag);
+      var = inferRelationsFromNameNode(md, nametable, (NameNode) en, flowTo, implicitTag);
       break;
 
-      case Kind.OpNode:
-       var = inferRelationsFromOpNode(md, nametable, (OpNode) en, flowTo, implicitTag);
-      break;
-      /*
-    case Kind.CreateObjectNode:
-      var = inferRelationsFromCreateObjectNode(md, nametable, (CreateObjectNode) en);
+    case Kind.OpNode:
+      var = inferRelationsFromOpNode(md, nametable, (OpNode) en, flowTo, implicitTag);
       break;
-
-    case Kind.ArrayAccessNode:
-      var =
-          inferRelationsFromArrayAccessNode(md, nametable, (ArrayAccessNode) en, flowTo, isLHS);
-      break;
-      */
+    /*
+     * case Kind.CreateObjectNode: var = inferRelationsFromCreateObjectNode(md,
+     * nametable, (CreateObjectNode) en); break;
+     * 
+     * case Kind.ArrayAccessNode: var = inferRelationsFromArrayAccessNode(md,
+     * nametable, (ArrayAccessNode) en, flowTo, isLHS); break;
+     */
     case Kind.LiteralNode:
-       var = inferRelationsFromLiteralNode(md, nametable, (LiteralNode) en);
-      break;
-      /*
-     case Kind.MethodInvokeNode:
-      var =
-          inferRelationsFromMethodInvokeNode(md, nametable, (MethodInvokeNode) en, flowTo);
-      break;
-
-    case Kind.TertiaryNode:
-      var = inferRelationsFromTertiaryNode(md, nametable, (TertiaryNode) en);
+      var = inferRelationsFromLiteralNode(md, nametable, (LiteralNode) en);
       break;
-
-    case Kind.CastNode:
-      var = inferRelationsFromCastNode(md, nametable, (CastNode) en);
-      break;
-      */
+    /*
+     * case Kind.MethodInvokeNode: var = inferRelationsFromMethodInvokeNode(md,
+     * nametable, (MethodInvokeNode) en, flowTo); break;
+     * 
+     * case Kind.TertiaryNode: var = inferRelationsFromTertiaryNode(md,
+     * nametable, (TertiaryNode) en); break;
+     * 
+     * case Kind.CastNode: var = inferRelationsFromCastNode(md, nametable,
+     * (CastNode) en); break;
+     */
     // case Kind.InstanceOfNode:
     // checkInstanceOfNode(md, nametable, (InstanceOfNode) en, td);
     // return null;
@@ -455,368 +431,317 @@ public class SSJavaInferenceEngine {
     // return null;
 
     default:
-       System.out.println("expressionnode not handled...");
+      System.out.println("expressionnode not handled...");
       return null;
 
     }
     // addTypeLocation(en.getType(), compLoc);
     return var;
 
-  }
-    /*
- private CompositeLocation inferRelationsFromCastNode(MethodDescriptor md, SymbolTable nametable,
-      CastNode cn, CompositeLocation constraint) {
-
-    ExpressionNode en = cn.getExpression();
-    return inferRelationsFromExpressionNode(md, nametable, en, new CompositeLocation(), constraint,
-        false);
-
-  }
-
-  private CompositeLocation inferRelationsFromTertiaryNode(MethodDescriptor md,
-      SymbolTable nametable, TertiaryNode tn, CompositeLocation constraint) {
-    ClassDescriptor cd = md.getClassDesc();
-
-    CompositeLocation condLoc =
-        inferRelationsFromExpressionNode(md, nametable, tn.getCond(), new CompositeLocation(),
-            constraint, false);
-    // addLocationType(tn.getCond().getType(), condLoc);
-    CompositeLocation trueLoc =
-        inferRelationsFromExpressionNode(md, nametable, tn.getTrueExpr(), new CompositeLocation(),
-            constraint, false);
-    // addLocationType(tn.getTrueExpr().getType(), trueLoc);
-    CompositeLocation falseLoc =
-        inferRelationsFromExpressionNode(md, nametable, tn.getFalseExpr(), new CompositeLocation(),
-            constraint, false);
-    // addLocationType(tn.getFalseExpr().getType(), falseLoc);
-
-    // locations from true/false branches can be TOP when there are only literal
-    // values
-    // in this case, we don't need to check flow down rule!
-
-    // 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 true expression at "
-              + cd.getSourceFileName() + ":" + tn.getCond().getNumLine());
-    }
-
-    // then, return glb of trueLoc & falseLoc
-    Set<CompositeLocation> glbInputSet = new HashSet<CompositeLocation>();
-    glbInputSet.add(trueLoc);
-    glbInputSet.add(falseLoc);
-
-    return CompositeLattice.calculateGLB(glbInputSet, generateErrorMessage(cd, tn));
-  }
-
-  private CompositeLocation inferRelationsFromMethodInvokeNode(MethodDescriptor md,
-      SymbolTable nametable, MethodInvokeNode min, CompositeLocation loc,
-      CompositeLocation constraint) {
-
-    CompositeLocation baseLocation = null;
-    if (min.getExpression() != null) {
-      baseLocation =
-          inferRelationsFromExpressionNode(md, nametable, min.getExpression(),
-              new CompositeLocation(), constraint, false);
-    } else {
-
-      if (min.getMethod().isStatic()) {
-        String globalLocId = ssjava.getMethodLattice(md).getGlobalLoc();
-        if (globalLocId == null) {
-          throw new Error("Method lattice does not define global variable location at "
-              + generateErrorMessage(md.getClassDesc(), min));
-        }
-        baseLocation = new CompositeLocation(new Location(md, globalLocId));
-      } else {
-        String thisLocId = ssjava.getMethodLattice(md).getThisLoc();
-        baseLocation = new CompositeLocation(new Location(md, thisLocId));
-      }
-    }
-
-    checkCalleeConstraints(md, nametable, min, baseLocation, constraint);
-
-    checkCallerArgumentLocationConstraints(md, nametable, min, baseLocation, constraint);
-
-    if (!min.getMethod().getReturnType().isVoid()) {
-      // If method has a return value, compute the highest possible return
-      // location in the caller's perspective
-      CompositeLocation ceilingLoc =
-          computeCeilingLocationForCaller(md, nametable, min, baseLocation, constraint);
-      return ceilingLoc;
-    }
-
-    return new CompositeLocation();
-
-  }
-
-  private void checkCallerArgumentLocationConstraints(MethodDescriptor md, SymbolTable nametable,
-      MethodInvokeNode min, CompositeLocation callerBaseLoc, CompositeLocation constraint) {
-    // if parameter location consists of THIS and FIELD location,
-    // caller should pass an argument that is comparable to the declared
-    // parameter location
-    // and is not lower than the declared parameter location in the field
-    // lattice.
-
-    MethodDescriptor calleemd = min.getMethod();
-
-    List<CompositeLocation> callerArgList = new ArrayList<CompositeLocation>();
-    List<CompositeLocation> calleeParamList = new ArrayList<CompositeLocation>();
-
-    MethodLattice<String> calleeLattice = ssjava.getMethodLattice(calleemd);
-    Location calleeThisLoc = new Location(calleemd, calleeLattice.getThisLoc());
-
-    for (int i = 0; i < min.numArgs(); i++) {
-      ExpressionNode en = min.getArg(i);
-      CompositeLocation callerArgLoc =
-          inferRelationsFromExpressionNode(md, nametable, en, new CompositeLocation(), constraint,
-              false);
-      callerArgList.add(callerArgLoc);
-    }
-
-    // setup callee params set
-    for (int i = 0; i < calleemd.numParameters(); i++) {
-      VarDescriptor calleevd = (VarDescriptor) calleemd.getParameter(i);
-      CompositeLocation calleeLoc = d2loc.get(calleevd);
-      calleeParamList.add(calleeLoc);
-    }
-
-    String errorMsg = generateErrorMessage(md.getClassDesc(), min);
-
-    System.out.println("checkCallerArgumentLocationConstraints=" + min.printNode(0));
-    System.out.println("base location=" + callerBaseLoc);
-
-    for (int i = 0; i < calleeParamList.size(); i++) {
-      CompositeLocation calleeParamLoc = calleeParamList.get(i);
-      if (calleeParamLoc.get(0).equals(calleeThisLoc) && calleeParamLoc.getSize() > 1) {
-
-        // callee parameter location has field information
-        CompositeLocation callerArgLoc = callerArgList.get(i);
-
-        CompositeLocation paramLocation =
-            translateCalleeParamLocToCaller(md, calleeParamLoc, callerBaseLoc, errorMsg);
-
-        Set<CompositeLocation> inputGLBSet = new HashSet<CompositeLocation>();
-        if (constraint != null) {
-          inputGLBSet.add(callerArgLoc);
-          inputGLBSet.add(constraint);
-          callerArgLoc =
-              CompositeLattice.calculateGLB(inputGLBSet,
-                  generateErrorMessage(md.getClassDesc(), min));
-        }
-
-        if (!CompositeLattice.isGreaterThan(callerArgLoc, paramLocation, errorMsg)) {
-          throw new Error("Caller argument '" + min.getArg(i).printNode(0) + " : " + callerArgLoc
-              + "' should be higher than corresponding callee's parameter : " + paramLocation
-              + " at " + errorMsg);
-        }
-
-      }
-    }
-
-  }
-
-  private CompositeLocation translateCalleeParamLocToCaller(MethodDescriptor md,
-      CompositeLocation calleeParamLoc, CompositeLocation callerBaseLocation, String errorMsg) {
-
-    CompositeLocation translate = new CompositeLocation();
-
-    for (int i = 0; i < callerBaseLocation.getSize(); i++) {
-      translate.addLocation(callerBaseLocation.get(i));
-    }
-
-    for (int i = 1; i < calleeParamLoc.getSize(); i++) {
-      translate.addLocation(calleeParamLoc.get(i));
-    }
-
-    System.out.println("TRANSLATED=" + translate + " from calleeParamLoc=" + calleeParamLoc);
-
-    return translate;
-  }
-
-  private CompositeLocation computeCeilingLocationForCaller(MethodDescriptor md,
-      SymbolTable nametable, MethodInvokeNode min, CompositeLocation baseLocation,
-      CompositeLocation constraint) {
-    List<CompositeLocation> argList = new ArrayList<CompositeLocation>();
-
-    // by default, method has a THIS parameter
-    argList.add(baseLocation);
-
-    for (int i = 0; i < min.numArgs(); i++) {
-      ExpressionNode en = min.getArg(i);
-      CompositeLocation callerArg =
-          inferRelationsFromExpressionNode(md, nametable, en, new CompositeLocation(), constraint,
-              false);
-      argList.add(callerArg);
-    }
-
-    System.out.println("\n## computeReturnLocation=" + min.getMethod() + " argList=" + argList);
-    CompositeLocation compLoc = md2ReturnLocGen.get(min.getMethod()).computeReturnLocation(argList);
-    DeltaLocation delta = new DeltaLocation(compLoc, 1);
-    System.out.println("##computeReturnLocation=" + delta);
-
-    return delta;
-
-  }
-
-  private void checkCalleeConstraints(MethodDescriptor md, SymbolTable nametable,
-      MethodInvokeNode min, CompositeLocation callerBaseLoc, CompositeLocation constraint) {
-    
-    System.out.println("checkCalleeConstraints="+min.printNode(0));
-
-    MethodDescriptor calleemd = min.getMethod();
-
-    MethodLattice<String> calleeLattice = ssjava.getMethodLattice(calleemd);
-    CompositeLocation calleeThisLoc =
-        new CompositeLocation(new Location(calleemd, calleeLattice.getThisLoc()));
-
-    List<CompositeLocation> callerArgList = new ArrayList<CompositeLocation>();
-    List<CompositeLocation> calleeParamList = new ArrayList<CompositeLocation>();
-
-    if (min.numArgs() > 0) {
-      // caller needs to guarantee that it passes arguments in regarding to
-      // callee's hierarchy
-
-      // setup caller args set
-      // first, add caller's base(this) location
-      callerArgList.add(callerBaseLoc);
-      // second, add caller's arguments
-      for (int i = 0; i < min.numArgs(); i++) {
-        ExpressionNode en = min.getArg(i);
-        CompositeLocation callerArgLoc =
-            inferRelationsFromExpressionNode(md, nametable, en, new CompositeLocation(), constraint,
-                false);
-        callerArgList.add(callerArgLoc);
-      }
-
-      // setup callee params set
-      // first, add callee's this location
-      calleeParamList.add(calleeThisLoc);
-      // second, add callee's parameters
-      for (int i = 0; i < calleemd.numParameters(); i++) {
-        VarDescriptor calleevd = (VarDescriptor) calleemd.getParameter(i);
-        CompositeLocation calleeLoc = d2loc.get(calleevd);
-        System.out.println("calleevd="+calleevd+" loc="+calleeLoc);
-        calleeParamList.add(calleeLoc);
-      }
-
-      // here, check if ordering relations among caller's args respect
-      // ordering relations in-between callee's args
-      CHECK: for (int i = 0; i < calleeParamList.size(); i++) {
-        CompositeLocation calleeLoc1 = calleeParamList.get(i);
-        CompositeLocation callerLoc1 = callerArgList.get(i);
-
-        for (int j = 0; j < calleeParamList.size(); j++) {
-          if (i != j) {
-            CompositeLocation calleeLoc2 = calleeParamList.get(j);
-            CompositeLocation callerLoc2 = callerArgList.get(j);
-
-            if (callerLoc1.get(callerLoc1.getSize() - 1).isTop()
-                || callerLoc2.get(callerLoc2.getSize() - 1).isTop()) {
-              continue CHECK;
-            }
-            
-            System.out.println("calleeLoc1="+calleeLoc1);
-            System.out.println("calleeLoc2="+calleeLoc2+"calleeParamList="+calleeParamList);
-
-            int callerResult =
-                CompositeLattice.compare(callerLoc1, callerLoc2, true,
-                    generateErrorMessage(md.getClassDesc(), min));
-            int calleeResult =
-                CompositeLattice.compare(calleeLoc1, calleeLoc2, true,
-                    generateErrorMessage(md.getClassDesc(), min));
-
-            if (calleeResult == ComparisonResult.GREATER
-                && callerResult != ComparisonResult.GREATER) {
-              // If calleeLoc1 is higher than calleeLoc2
-              // then, caller should have same ordering relation in-bet
-              // callerLoc1 & callerLoc2
-
-              String paramName1, paramName2;
-
-              if (i == 0) {
-                paramName1 = "'THIS'";
-              } else {
-                paramName1 = "'parameter " + calleemd.getParamName(i - 1) + "'";
-              }
-
-              if (j == 0) {
-                paramName2 = "'THIS'";
-              } else {
-                paramName2 = "'parameter " + calleemd.getParamName(j - 1) + "'";
-              }
-
-              throw new Error(
-                  "Caller doesn't respect an ordering relation among method arguments: callee expects that "
-                      + paramName1 + " should be higher than " + paramName2 + " in " + calleemd
-                      + " at " + md.getClassDesc().getSourceFileName() + ":" + min.getNumLine());
-            }
-          }
-
-        }
-      }
-
-    }
-
-  }
-
-  private CompositeLocation inferRelationsFromArrayAccessNode(MethodDescriptor md,
-      SymbolTable nametable, ArrayAccessNode aan, CompositeLocation constraint, boolean isLHS) {
-
-    ClassDescriptor cd = md.getClassDesc();
-
-    CompositeLocation arrayLoc =
-        inferRelationsFromExpressionNode(md, nametable, aan.getExpression(),
-            new CompositeLocation(), constraint, isLHS);
-    // addTypeLocation(aan.getExpression().getType(), arrayLoc);
-    CompositeLocation indexLoc =
-        inferRelationsFromExpressionNode(md, nametable, aan.getIndex(), new CompositeLocation(),
-            constraint, isLHS);
-    // addTypeLocation(aan.getIndex().getType(), indexLoc);
-
-    if (isLHS) {
-      if (!CompositeLattice.isGreaterThan(indexLoc, arrayLoc, generateErrorMessage(cd, aan))) {
-        throw new Error("Array index value is not higher than array location at "
-            + generateErrorMessage(cd, aan));
-      }
-      return arrayLoc;
-    } else {
-      Set<CompositeLocation> inputGLB = new HashSet<CompositeLocation>();
-      inputGLB.add(arrayLoc);
-      inputGLB.add(indexLoc);
-      return CompositeLattice.calculateGLB(inputGLB, generateErrorMessage(cd, aan));
-    }
-
   }
 
-  private CompositeLocation inferRelationsFromCreateObjectNode(MethodDescriptor md,
-      SymbolTable nametable, CreateObjectNode con) {
-
-    ClassDescriptor cd = md.getClassDesc();
-
-    CompositeLocation compLoc = new CompositeLocation();
-    compLoc.addLocation(Location.createTopLocation(md));
-    return compLoc;
-
-  }
-    */
-  private VarID inferRelationsFromOpNode(MethodDescriptor md, SymbolTable nametable,
-                                                    OpNode on, VarID flowTo, BlockStatementNode implicitTag) {
+  /*
+   * private CompositeLocation inferRelationsFromCastNode(MethodDescriptor md,
+   * SymbolTable nametable, CastNode cn, CompositeLocation constraint) {
+   * 
+   * ExpressionNode en = cn.getExpression(); return
+   * inferRelationsFromExpressionNode(md, nametable, en, new
+   * CompositeLocation(), constraint, false);
+   * 
+   * }
+   * 
+   * private CompositeLocation inferRelationsFromTertiaryNode(MethodDescriptor
+   * md, SymbolTable nametable, TertiaryNode tn, CompositeLocation constraint) {
+   * ClassDescriptor cd = md.getClassDesc();
+   * 
+   * CompositeLocation condLoc = inferRelationsFromExpressionNode(md, nametable,
+   * tn.getCond(), new CompositeLocation(), constraint, false); //
+   * addLocationType(tn.getCond().getType(), condLoc); CompositeLocation trueLoc
+   * = inferRelationsFromExpressionNode(md, nametable, tn.getTrueExpr(), new
+   * CompositeLocation(), constraint, false); //
+   * addLocationType(tn.getTrueExpr().getType(), trueLoc); CompositeLocation
+   * falseLoc = inferRelationsFromExpressionNode(md, nametable,
+   * tn.getFalseExpr(), new CompositeLocation(), constraint, false); //
+   * addLocationType(tn.getFalseExpr().getType(), falseLoc);
+   * 
+   * // locations from true/false branches can be TOP when there are only
+   * literal // values // in this case, we don't need to check flow down rule!
+   * 
+   * // 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 true expression at "
+   * + cd.getSourceFileName() + ":" + tn.getCond().getNumLine()); }
+   * 
+   * // then, return glb of trueLoc & falseLoc Set<CompositeLocation>
+   * glbInputSet = new HashSet<CompositeLocation>(); glbInputSet.add(trueLoc);
+   * glbInputSet.add(falseLoc);
+   * 
+   * return CompositeLattice.calculateGLB(glbInputSet, generateErrorMessage(cd,
+   * tn)); }
+   * 
+   * private CompositeLocation
+   * inferRelationsFromMethodInvokeNode(MethodDescriptor md, SymbolTable
+   * nametable, MethodInvokeNode min, CompositeLocation loc, CompositeLocation
+   * constraint) {
+   * 
+   * CompositeLocation baseLocation = null; if (min.getExpression() != null) {
+   * baseLocation = inferRelationsFromExpressionNode(md, nametable,
+   * min.getExpression(), new CompositeLocation(), constraint, false); } else {
+   * 
+   * if (min.getMethod().isStatic()) { String globalLocId =
+   * ssjava.getMethodLattice(md).getGlobalLoc(); if (globalLocId == null) {
+   * throw new
+   * Error("Method lattice does not define global variable location at " +
+   * generateErrorMessage(md.getClassDesc(), min)); } baseLocation = new
+   * CompositeLocation(new Location(md, globalLocId)); } else { String thisLocId
+   * = ssjava.getMethodLattice(md).getThisLoc(); baseLocation = new
+   * CompositeLocation(new Location(md, thisLocId)); } }
+   * 
+   * checkCalleeConstraints(md, nametable, min, baseLocation, constraint);
+   * 
+   * checkCallerArgumentLocationConstraints(md, nametable, min, baseLocation,
+   * constraint);
+   * 
+   * if (!min.getMethod().getReturnType().isVoid()) { // If method has a return
+   * value, compute the highest possible return // location in the caller's
+   * perspective CompositeLocation ceilingLoc =
+   * computeCeilingLocationForCaller(md, nametable, min, baseLocation,
+   * constraint); return ceilingLoc; }
+   * 
+   * return new CompositeLocation();
+   * 
+   * }
+   * 
+   * private void checkCallerArgumentLocationConstraints(MethodDescriptor md,
+   * SymbolTable nametable, MethodInvokeNode min, CompositeLocation
+   * callerBaseLoc, CompositeLocation constraint) { // if parameter location
+   * consists of THIS and FIELD location, // caller should pass an argument that
+   * is comparable to the declared // parameter location // and is not lower
+   * than the declared parameter location in the field // lattice.
+   * 
+   * MethodDescriptor calleemd = min.getMethod();
+   * 
+   * List<CompositeLocation> callerArgList = new ArrayList<CompositeLocation>();
+   * List<CompositeLocation> calleeParamList = new
+   * ArrayList<CompositeLocation>();
+   * 
+   * MethodLattice<String> calleeLattice = ssjava.getMethodLattice(calleemd);
+   * Location calleeThisLoc = new Location(calleemd,
+   * calleeLattice.getThisLoc());
+   * 
+   * for (int i = 0; i < min.numArgs(); i++) { ExpressionNode en =
+   * min.getArg(i); CompositeLocation callerArgLoc =
+   * inferRelationsFromExpressionNode(md, nametable, en, new
+   * CompositeLocation(), constraint, false); callerArgList.add(callerArgLoc); }
+   * 
+   * // setup callee params set for (int i = 0; i < calleemd.numParameters();
+   * i++) { VarDescriptor calleevd = (VarDescriptor) calleemd.getParameter(i);
+   * CompositeLocation calleeLoc = d2loc.get(calleevd);
+   * calleeParamList.add(calleeLoc); }
+   * 
+   * String errorMsg = generateErrorMessage(md.getClassDesc(), min);
+   * 
+   * System.out.println("checkCallerArgumentLocationConstraints=" +
+   * min.printNode(0)); System.out.println("base location=" + callerBaseLoc);
+   * 
+   * for (int i = 0; i < calleeParamList.size(); i++) { CompositeLocation
+   * calleeParamLoc = calleeParamList.get(i); if
+   * (calleeParamLoc.get(0).equals(calleeThisLoc) && calleeParamLoc.getSize() >
+   * 1) {
+   * 
+   * // callee parameter location has field information CompositeLocation
+   * callerArgLoc = callerArgList.get(i);
+   * 
+   * CompositeLocation paramLocation = translateCalleeParamLocToCaller(md,
+   * calleeParamLoc, callerBaseLoc, errorMsg);
+   * 
+   * Set<CompositeLocation> inputGLBSet = new HashSet<CompositeLocation>(); if
+   * (constraint != null) { inputGLBSet.add(callerArgLoc);
+   * inputGLBSet.add(constraint); callerArgLoc =
+   * CompositeLattice.calculateGLB(inputGLBSet,
+   * generateErrorMessage(md.getClassDesc(), min)); }
+   * 
+   * if (!CompositeLattice.isGreaterThan(callerArgLoc, paramLocation, errorMsg))
+   * { throw new Error("Caller argument '" + min.getArg(i).printNode(0) + " : "
+   * + callerArgLoc +
+   * "' should be higher than corresponding callee's parameter : " +
+   * paramLocation + " at " + errorMsg); }
+   * 
+   * } }
+   * 
+   * }
+   * 
+   * private CompositeLocation translateCalleeParamLocToCaller(MethodDescriptor
+   * md, CompositeLocation calleeParamLoc, CompositeLocation callerBaseLocation,
+   * String errorMsg) {
+   * 
+   * CompositeLocation translate = new CompositeLocation();
+   * 
+   * for (int i = 0; i < callerBaseLocation.getSize(); i++) {
+   * translate.addLocation(callerBaseLocation.get(i)); }
+   * 
+   * for (int i = 1; i < calleeParamLoc.getSize(); i++) {
+   * translate.addLocation(calleeParamLoc.get(i)); }
+   * 
+   * System.out.println("TRANSLATED=" + translate + " from calleeParamLoc=" +
+   * calleeParamLoc);
+   * 
+   * return translate; }
+   * 
+   * private CompositeLocation computeCeilingLocationForCaller(MethodDescriptor
+   * md, SymbolTable nametable, MethodInvokeNode min, CompositeLocation
+   * baseLocation, CompositeLocation constraint) { List<CompositeLocation>
+   * argList = new ArrayList<CompositeLocation>();
+   * 
+   * // by default, method has a THIS parameter argList.add(baseLocation);
+   * 
+   * for (int i = 0; i < min.numArgs(); i++) { ExpressionNode en =
+   * min.getArg(i); CompositeLocation callerArg =
+   * inferRelationsFromExpressionNode(md, nametable, en, new
+   * CompositeLocation(), constraint, false); argList.add(callerArg); }
+   * 
+   * System.out.println("\n## computeReturnLocation=" + min.getMethod() +
+   * " argList=" + argList); CompositeLocation compLoc =
+   * md2ReturnLocGen.get(min.getMethod()).computeReturnLocation(argList);
+   * DeltaLocation delta = new DeltaLocation(compLoc, 1);
+   * System.out.println("##computeReturnLocation=" + delta);
+   * 
+   * return delta;
+   * 
+   * }
+   * 
+   * private void checkCalleeConstraints(MethodDescriptor md, SymbolTable
+   * nametable, MethodInvokeNode min, CompositeLocation callerBaseLoc,
+   * CompositeLocation constraint) {
+   * 
+   * System.out.println("checkCalleeConstraints="+min.printNode(0));
+   * 
+   * MethodDescriptor calleemd = min.getMethod();
+   * 
+   * MethodLattice<String> calleeLattice = ssjava.getMethodLattice(calleemd);
+   * CompositeLocation calleeThisLoc = new CompositeLocation(new
+   * Location(calleemd, calleeLattice.getThisLoc()));
+   * 
+   * List<CompositeLocation> callerArgList = new ArrayList<CompositeLocation>();
+   * List<CompositeLocation> calleeParamList = new
+   * ArrayList<CompositeLocation>();
+   * 
+   * if (min.numArgs() > 0) { // caller needs to guarantee that it passes
+   * arguments in regarding to // callee's hierarchy
+   * 
+   * // setup caller args set // first, add caller's base(this) location
+   * callerArgList.add(callerBaseLoc); // second, add caller's arguments for
+   * (int i = 0; i < min.numArgs(); i++) { ExpressionNode en = min.getArg(i);
+   * CompositeLocation callerArgLoc = inferRelationsFromExpressionNode(md,
+   * nametable, en, new CompositeLocation(), constraint, false);
+   * callerArgList.add(callerArgLoc); }
+   * 
+   * // setup callee params set // first, add callee's this location
+   * calleeParamList.add(calleeThisLoc); // second, add callee's parameters for
+   * (int i = 0; i < calleemd.numParameters(); i++) { VarDescriptor calleevd =
+   * (VarDescriptor) calleemd.getParameter(i); CompositeLocation calleeLoc =
+   * d2loc.get(calleevd);
+   * System.out.println("calleevd="+calleevd+" loc="+calleeLoc);
+   * calleeParamList.add(calleeLoc); }
+   * 
+   * // here, check if ordering relations among caller's args respect //
+   * ordering relations in-between callee's args CHECK: for (int i = 0; i <
+   * calleeParamList.size(); i++) { CompositeLocation calleeLoc1 =
+   * calleeParamList.get(i); CompositeLocation callerLoc1 =
+   * callerArgList.get(i);
+   * 
+   * for (int j = 0; j < calleeParamList.size(); j++) { if (i != j) {
+   * CompositeLocation calleeLoc2 = calleeParamList.get(j); CompositeLocation
+   * callerLoc2 = callerArgList.get(j);
+   * 
+   * if (callerLoc1.get(callerLoc1.getSize() - 1).isTop() ||
+   * callerLoc2.get(callerLoc2.getSize() - 1).isTop()) { continue CHECK; }
+   * 
+   * System.out.println("calleeLoc1="+calleeLoc1);
+   * System.out.println("calleeLoc2="
+   * +calleeLoc2+"calleeParamList="+calleeParamList);
+   * 
+   * int callerResult = CompositeLattice.compare(callerLoc1, callerLoc2, true,
+   * generateErrorMessage(md.getClassDesc(), min)); int calleeResult =
+   * CompositeLattice.compare(calleeLoc1, calleeLoc2, true,
+   * generateErrorMessage(md.getClassDesc(), min));
+   * 
+   * if (calleeResult == ComparisonResult.GREATER && callerResult !=
+   * ComparisonResult.GREATER) { // If calleeLoc1 is higher than calleeLoc2 //
+   * then, caller should have same ordering relation in-bet // callerLoc1 &
+   * callerLoc2
+   * 
+   * String paramName1, paramName2;
+   * 
+   * if (i == 0) { paramName1 = "'THIS'"; } else { paramName1 = "'parameter " +
+   * calleemd.getParamName(i - 1) + "'"; }
+   * 
+   * if (j == 0) { paramName2 = "'THIS'"; } else { paramName2 = "'parameter " +
+   * calleemd.getParamName(j - 1) + "'"; }
+   * 
+   * throw new Error(
+   * "Caller doesn't respect an ordering relation among method arguments: callee expects that "
+   * + paramName1 + " should be higher than " + paramName2 + " in " + calleemd +
+   * " at " + md.getClassDesc().getSourceFileName() + ":" + min.getNumLine()); }
+   * }
+   * 
+   * } }
+   * 
+   * }
+   * 
+   * }
+   * 
+   * private CompositeLocation
+   * inferRelationsFromArrayAccessNode(MethodDescriptor md, SymbolTable
+   * nametable, ArrayAccessNode aan, CompositeLocation constraint, boolean
+   * isLHS) {
+   * 
+   * ClassDescriptor cd = md.getClassDesc();
+   * 
+   * CompositeLocation arrayLoc = inferRelationsFromExpressionNode(md,
+   * nametable, aan.getExpression(), new CompositeLocation(), constraint,
+   * isLHS); // addTypeLocation(aan.getExpression().getType(), arrayLoc);
+   * CompositeLocation indexLoc = inferRelationsFromExpressionNode(md,
+   * nametable, aan.getIndex(), new CompositeLocation(), constraint, isLHS); //
+   * addTypeLocation(aan.getIndex().getType(), indexLoc);
+   * 
+   * if (isLHS) { if (!CompositeLattice.isGreaterThan(indexLoc, arrayLoc,
+   * generateErrorMessage(cd, aan))) { throw new
+   * Error("Array index value is not higher than array location at " +
+   * generateErrorMessage(cd, aan)); } return arrayLoc; } else {
+   * Set<CompositeLocation> inputGLB = new HashSet<CompositeLocation>();
+   * inputGLB.add(arrayLoc); inputGLB.add(indexLoc); return
+   * CompositeLattice.calculateGLB(inputGLB, generateErrorMessage(cd, aan)); }
+   * 
+   * }
+   * 
+   * private CompositeLocation
+   * inferRelationsFromCreateObjectNode(MethodDescriptor md, SymbolTable
+   * nametable, CreateObjectNode con) {
+   * 
+   * ClassDescriptor cd = md.getClassDesc();
+   * 
+   * CompositeLocation compLoc = new CompositeLocation();
+   * compLoc.addLocation(Location.createTopLocation(md)); return compLoc;
+   * 
+   * }
+   */
+  private VarID inferRelationsFromOpNode(MethodDescriptor md, SymbolTable nametable, OpNode on,
+      VarID flowTo, BlockStatementNode implicitTag) {
 
     ClassDescriptor cd = md.getClassDesc();
-    VarID var = inferRelationsFromExpressionNode(md, nametable, on.getLeft(), flowTo, implicitTag, false);
+    VarID var =
+        inferRelationsFromExpressionNode(md, nametable, on.getLeft(), flowTo, implicitTag, false);
 
     CompositeLocation rightLoc = new CompositeLocation();
     if (on.getRight() != null) {
-       inferRelationsFromExpressionNode(md, nametable, on.getRight(), flowTo, implicitTag, false);
+      inferRelationsFromExpressionNode(md, nametable, on.getRight(), flowTo, implicitTag, false);
     }
 
     Operation op = on.getOp();
@@ -859,31 +784,32 @@ public class SSJavaInferenceEngine {
 
   }
 
-  private VarID inferRelationsFromLiteralNode(MethodDescriptor md,
-  SymbolTable nametable, LiteralNode ln) {
-      //literal data flow does not matter
+  private VarID inferRelationsFromLiteralNode(MethodDescriptor md, SymbolTable nametable,
+      LiteralNode ln) {
+    // literal data flow does not matter
     return null;
 
   }
 
-  private VarID inferRelationsFromNameNode(MethodDescriptor md, SymbolTable nametable,
-                                          NameNode nn, VarID flowTo, BlockStatementNode implicitTag) {
+  private VarID inferRelationsFromNameNode(MethodDescriptor md, SymbolTable nametable, NameNode nn,
+      VarID flowTo, BlockStatementNode implicitTag) {
     VarID var = null;
     NameDescriptor nd = nn.getName();
     if (nd.getBase() != null) {
       var =
-          inferRelationsFromExpressionNode(md, nametable, nn.getExpression(), flowTo, implicitTag, false);
+          inferRelationsFromExpressionNode(md, nametable, nn.getExpression(), flowTo, implicitTag,
+              false);
     } else {
       String varname = nd.toString();
       if (varname.equals("this")) {
-       var = new VarID(nd);
-       if(flowTo != null){
-           rSet.addRelation(new BinaryRelation(var,flowTo));
-       }
-       if(implicitTag != null){
-           implicitFlowSet.add(new ImplicitTuple(var,implicitTag));
-       }
-       var.setThis();
+        var = new VarID(nd);
+        if (flowTo != null) {
+          rSet.addRelation(new BinaryRelation(var, flowTo));
+        }
+        if (implicitTag != null) {
+          implicitFlowSet.add(new ImplicitTuple(var, implicitTag));
+        }
+        var.setThis();
         return var;
       }
 
@@ -891,140 +817,135 @@ public class SSJavaInferenceEngine {
 
       if (d instanceof VarDescriptor) {
         var = new VarID(nd);
-       if(flowTo != null){
-         rSet.addRelation(new BinaryRelation(var,flowTo));
-       }                  
-       if(implicitTag != null){
-           implicitFlowSet.add(new ImplicitTuple(var,implicitTag));
-       }
+        if (flowTo != null) {
+          rSet.addRelation(new BinaryRelation(var, flowTo));
+        }
+        if (implicitTag != null) {
+          implicitFlowSet.add(new ImplicitTuple(var, implicitTag));
+        }
       } else if (d instanceof FieldDescriptor) {
         FieldDescriptor fd = (FieldDescriptor) d;
         if (fd.isStatic()) {
           if (fd.isFinal()) {
             var = new VarID(nd);
-           if(flowTo != null){
-             rSet.addRelation(new BinaryRelation(var,flowTo));
-           }
-           if(implicitTag != null){
-               implicitFlowSet.add(new ImplicitTuple(var,implicitTag));
-           }
-           var.setTop();
+            if (flowTo != null) {
+              rSet.addRelation(new BinaryRelation(var, flowTo));
+            }
+            if (implicitTag != null) {
+              implicitFlowSet.add(new ImplicitTuple(var, implicitTag));
+            }
+            var.setTop();
             return var;
           } else {
             var = new VarID(nd);
-           if(flowTo != null){
-             rSet.addRelation(new BinaryRelation(var,flowTo));
-           }
-           if(implicitTag != null){
-               implicitFlowSet.add(new ImplicitTuple(var,implicitTag));
-           }
-           var.setGlobal();
+            if (flowTo != null) {
+              rSet.addRelation(new BinaryRelation(var, flowTo));
+            }
+            if (implicitTag != null) {
+              implicitFlowSet.add(new ImplicitTuple(var, implicitTag));
+            }
+            var.setGlobal();
           }
         } else {
-            var = new VarID(nd);
-           if(flowTo != null){
-             rSet.addRelation(new BinaryRelation(var,flowTo));
-           }
-           if(implicitTag != null){
-               implicitFlowSet.add(new ImplicitTuple(var,implicitTag));
-           }
-           var.setThis();
+          var = new VarID(nd);
+          if (flowTo != null) {
+            rSet.addRelation(new BinaryRelation(var, flowTo));
+          }
+          if (implicitTag != null) {
+            implicitFlowSet.add(new ImplicitTuple(var, implicitTag));
+          }
+          var.setThis();
         }
       } else if (d == null) {
         var = new VarID(nd);
-       if(flowTo != null){
-         rSet.addRelation(new BinaryRelation(var,flowTo));
-       }
-       if(implicitTag != null){
-           implicitFlowSet.add(new ImplicitTuple(var,implicitTag));
-       }
-       var.setGlobal();
+        if (flowTo != null) {
+          rSet.addRelation(new BinaryRelation(var, flowTo));
+        }
+        if (implicitTag != null) {
+          implicitFlowSet.add(new ImplicitTuple(var, implicitTag));
+        }
+        var.setGlobal();
         return var;
       }
     }
     return var;
   }
-  /*
-  private CompositeLocation inferRelationsFromFieldAccessNode(MethodDescriptor md,
-      SymbolTable nametable, FieldAccessNode fan, CompositeLocation loc,
-      CompositeLocation constraint) {
-
-    ExpressionNode left = fan.getExpression();
-    TypeDescriptor ltd = left.getType();
-
-    FieldDescriptor fd = fan.getField();
-
-    String varName = null;
-    if (left.kind() == Kind.NameNode) {
-      NameDescriptor nd = ((NameNode) left).getName();
-      varName = nd.toString();
-    }
-
-    if (ltd.isClassNameRef() || (varName != null && varName.equals("this"))) {
-      // using a class name directly or access using this
-      if (fd.isStatic() && fd.isFinal()) {
-        loc.addLocation(Location.createTopLocation(md));
-        return loc;
-      }
-    }
-
-    loc = inferRelationsFromExpressionNode(md, nametable, left, loc, constraint, false);
-    System.out.println("### inferRelationsFromFieldAccessNode=" + fan.printNode(0));
-    System.out.println("### left=" + left.printNode(0));
-    if (!left.getType().isPrimitive()) {
-      Location fieldLoc = getFieldLocation(fd);
-      loc.addLocation(fieldLoc);
-    }
-
-    return loc;
-  }
 
-  private Location getFieldLocation(FieldDescriptor fd) {
-
-    System.out.println("### getFieldLocation=" + fd);
-    System.out.println("### fd.getType().getExtension()=" + fd.getType().getExtension());
-
-    Location fieldLoc = (Location) fd.getType().getExtension();
-
-    // handle the case that method annotation checking skips checking field
-    // declaration
-    if (fieldLoc == null) {
-      fieldLoc = checkFieldDeclaration(fd.getClassDescriptor(), fd);
-    }
-
-    return fieldLoc;
-
-  }*/
-
-  private VarID inferRelationsFromAssignmentNode(MethodDescriptor md,
-        SymbolTable nametable, AssignmentNode an, VarID flowTo, BlockStatementNode implicitTag) {
+  /*
+   * private CompositeLocation
+   * inferRelationsFromFieldAccessNode(MethodDescriptor md, SymbolTable
+   * nametable, FieldAccessNode fan, CompositeLocation loc, CompositeLocation
+   * constraint) {
+   * 
+   * ExpressionNode left = fan.getExpression(); TypeDescriptor ltd =
+   * left.getType();
+   * 
+   * FieldDescriptor fd = fan.getField();
+   * 
+   * String varName = null; if (left.kind() == Kind.NameNode) { NameDescriptor
+   * nd = ((NameNode) left).getName(); varName = nd.toString(); }
+   * 
+   * if (ltd.isClassNameRef() || (varName != null && varName.equals("this"))) {
+   * // using a class name directly or access using this if (fd.isStatic() &&
+   * fd.isFinal()) { loc.addLocation(Location.createTopLocation(md)); return
+   * loc; } }
+   * 
+   * loc = inferRelationsFromExpressionNode(md, nametable, left, loc,
+   * constraint, false);
+   * System.out.println("### inferRelationsFromFieldAccessNode=" +
+   * fan.printNode(0)); System.out.println("### left=" + left.printNode(0)); if
+   * (!left.getType().isPrimitive()) { Location fieldLoc = getFieldLocation(fd);
+   * loc.addLocation(fieldLoc); }
+   * 
+   * return loc; }
+   * 
+   * private Location getFieldLocation(FieldDescriptor fd) {
+   * 
+   * System.out.println("### getFieldLocation=" + fd);
+   * System.out.println("### fd.getType().getExtension()=" +
+   * fd.getType().getExtension());
+   * 
+   * Location fieldLoc = (Location) fd.getType().getExtension();
+   * 
+   * // handle the case that method annotation checking skips checking field //
+   * declaration if (fieldLoc == null) { fieldLoc =
+   * checkFieldDeclaration(fd.getClassDescriptor(), fd); }
+   * 
+   * return fieldLoc;
+   * 
+   * }
+   */
+
+  private VarID inferRelationsFromAssignmentNode(MethodDescriptor md, SymbolTable nametable,
+      AssignmentNode an, VarID flowTo, BlockStatementNode implicitTag) {
     ClassDescriptor cd = md.getClassDesc();
     boolean postinc = true;
-    
+
     if (an.getOperation().getBaseOp() == null
         || (an.getOperation().getBaseOp().getOp() != Operation.POSTINC && an.getOperation()
             .getBaseOp().getOp() != Operation.POSTDEC))
       postinc = false;
-    //get ID for leftside
-    VarID destID = inferRelationsFromExpressionNode(md, nametable, an.getDest(), flowTo, implicitTag, true);
+    // get ID for leftside
+    VarID destID =
+        inferRelationsFromExpressionNode(md, nametable, an.getDest(), flowTo, implicitTag, true);
 
     if (!postinc) {
-      //recursively add relations from RHS to LHS
-       inferRelationsFromExpressionNode(md, nametable, an.getSrc(), destID, null, false);
-     
+      // recursively add relations from RHS to LHS
+      inferRelationsFromExpressionNode(md, nametable, an.getSrc(), destID, null, false);
+
     } else {
-       //add relation to self
-       destID = inferRelationsFromExpressionNode(md, nametable, an.getDest(), destID, null, false);
+      // add relation to self
+      destID = inferRelationsFromExpressionNode(md, nametable, an.getDest(), destID, null, false);
     }
-    
-    //checks if flow to anythin and adds relation
-    if(flowTo != null){
-       rSet.addRelation(new BinaryRelation(destID, flowTo));
+
+    // checks if flow to anythin and adds relation
+    if (flowTo != null) {
+      rSet.addRelation(new BinaryRelation(destID, flowTo));
     }
 
-    //add relations for implicit flow
-    for(ImplicitTuple it: implicitFlowSet){
-       rSet.addRelation(new BinaryRelation(it.getVar(),destID));
+    // add relations for implicit flow
+    for (ImplicitTuple it : implicitFlowSet) {
+      rSet.addRelation(new BinaryRelation(it.getVar(), destID));
     }
 
     return destID;
index 46af1f2d1e0309ea34de62433abd876c28a77382..4e8c0adde2252a40ed5c20893141d6cef7fab9a6 100644 (file)
@@ -3,44 +3,48 @@ package Analysis.SSJava;
 import java.util.ArrayList;
 import IR.Descriptor;
 
-public class VarID{
-    
-    //contains field and var descriptors
-    //given the case a.b.f it contains descriptors for a,b, and f
-    private ArrayList<Descriptor> var;
-    //properties of ID
-    private boolean isThis;
-    private boolean isGlobal;
-    private boolean isTop;
-
-    public VarID(Descriptor var){
-       this.var = new ArrayList<Descriptor>();
-       this.var.add(var);
-       isThis = false;
-       isGlobal = false;
-       isTop = false;
-    }
-    
-    public void addAccess(Descriptor var){
-       this.var.add(var);
-    }
-
-    public void setThis(){
-       isThis = true;
-    }
-    
-    public void setGlobal(){
-       isGlobal = true;
-    }
-
-    public void setTop(){
-       isTop = true;
-    }
-
-    public String toString(){
-       String toReturn = "";
-       for(Descriptor d: var)
-           toReturn += d.toString() + " ";
-       return toReturn;
-    }
+public class VarID {
+
+  // contains field and var descriptors
+  // given the case a.b.f it contains descriptors for a,b, and f
+  private ArrayList<Descriptor> var;
+  // properties of ID
+  private boolean isThis;
+  private boolean isGlobal;
+  private boolean isTop;
+
+  public VarID(Descriptor var) {
+    this.var = new ArrayList<Descriptor>();
+    this.var.add(var);
+    isThis = false;
+    isGlobal = false;
+    isTop = false;
+  }
+
+  public void addAccess(Descriptor var) {
+    this.var.add(var);
+  }
+
+  public void setThis() {
+    isThis = true;
+  }
+
+  public void setGlobal() {
+    isGlobal = true;
+  }
+
+  public void setTop() {
+    isTop = true;
+  }
+
+  public String toString() {
+    String toReturn = "";
+    for (Descriptor d : var)
+      toReturn += d.toString() + " ";
+    return toReturn;
+  }
+
+  public void setReturn() {
+    //interim fixes
+  }
 }
\ No newline at end of file