changes: 1) fixes problems in the original EyeTracking benchmark 2) fix a bug in...
[IRC.git] / Robust / src / Analysis / SSJava / LocationInference.java
index 2e7e9004a2d0e6cf30f44e13a04851ae9cc0d0f4..5502eb8808d6f36baba01c80a23d71373384cd2c 100644 (file)
@@ -370,6 +370,26 @@ public class LocationInference {
     System.out.println("\nSSJAVA: Add addtional ordering constriants:");
     MethodDescriptor methodEventLoopDesc = ssjava.getMethodContainingSSJavaLoop();
     addAddtionalOrderingConstraints(methodEventLoopDesc);
+    // calculateReturnHolderLocation();
+  }
+
+  private void calculateReturnHolderLocation() {
+    LinkedList<MethodDescriptor> methodDescList =
+        (LinkedList<MethodDescriptor>) toanalyze_methodDescList.clone();
+
+    while (!methodDescList.isEmpty()) {
+      MethodDescriptor md = methodDescList.removeLast();
+
+      FlowGraph fg = getFlowGraph(md);
+      Set<FlowNode> nodeSet = fg.getNodeSet();
+      for (Iterator iterator = nodeSet.iterator(); iterator.hasNext();) {
+        FlowNode flowNode = (FlowNode) iterator.next();
+        if (flowNode.isFromHolder()) {
+          calculateCompositeLocationFromFlowGraph(md, flowNode);
+        }
+      }
+
+    }
   }
 
   private void updateCompositeLocationAssignments() {
@@ -481,109 +501,14 @@ public class LocationInference {
       translateMapLocationToInferCompositeLocationToCalleeGraph(callerGlobalFlowGraph, min);
       MethodDescriptor mdCallee = min.getMethod();
       calleeSet.add(mdCallee);
-      //
-      // FlowGraph calleeFlowGraph = getFlowGraph(mdCallee);
-      //
-      // NTuple<Descriptor> methodInvokeBaseDescTuple = mapMethodInvokeNodeToBaseTuple.get(min);
-      // NTuple<Location> methodInvokeBaseLocTuple = null;
-      // if (methodInvokeBaseDescTuple != null) {
-      // methodInvokeBaseLocTuple = translateToLocTuple(mdCaller, methodInvokeBaseDescTuple);
-      // }
-
-      // ////////////////
-      // ////////////////
-
-      // If the location of an argument has a composite location
-      // need to assign a proper composite location to the corresponding callee parameter
-      // System.out.println("---translate arg composite location to callee param. min="
-      // + min.printNode(0));
-      // Map<Integer, NTuple<Descriptor>> mapIdxToArgTuple =
-      // mapMethodInvokeNodeToArgIdxMap.get(min);
-      // Set<Integer> idxSet = mapIdxToArgTuple.keySet();
-      // for (Iterator iterator2 = idxSet.iterator(); iterator2.hasNext();) {
-      // Integer idx = (Integer) iterator2.next();
-      //
-      // if (idx == 0 && !min.getMethod().isStatic()) {
-      // continue;
-      // }
-      //
-      // NTuple<Descriptor> argTuple = mapIdxToArgTuple.get(idx);
-      // if (argTuple.size() > 0) {
-      // // check if an arg tuple has been already assigned to a composite location
-      // NTuple<Location> argLocTuple = translateToLocTuple(mdCaller, argTuple);
-      // Location argLocalLoc = argLocTuple.get(0);
-      //
-      // // if (!isPrimitiveType(argTuple)) {
-      // if (callerMapLocToCompLoc.containsKey(argLocalLoc)) {
-      //
-      // CompositeLocation argLocalCompositeLocation = callerMapLocToCompLoc.get(argLocalLoc);
-      // CompositeLocation argCompLoc = argLocalCompositeLocation.clone();
-      // for (int i = 1; i < argLocTuple.size(); i++) {
-      // argCompLoc.addLocation(argLocTuple.get(i));
-      // }
-      //
-      // FlowNode calleeParamFlowNode = calleeFlowGraph.getParamFlowNode(idx);
-      //
-      // System.out
-      // .println("----- argLocTuple=" + argLocTuple + "  argLocalLoc=+" + argLocalLoc);
-      // System.out.println("-------need to translate argCompLoc=" + argCompLoc
-      // + " with baseTuple=" + methodInvokeBaseLocTuple + "   calleeParamLocTuple="
-      // + calleeParamFlowNode);
-      //
-      // // CompositeLocation paramCompLoc = translateArgCompLocToParamCompLoc(min, argCompLoc);
-      // // calleeParamFlowNode.setCompositeLocation(paramCompLoc);
-      //
-      // // if (baseLocTuple != null && callerCompLoc.getTuple().startsWith(baseLocTuple)) {
-      // //
-      // // FlowNode calleeParamFlowNode = calleeFlowGraph.getParamFlowNode(idx);
-      // // NTuple<Descriptor> calleeParamDescTuple = calleeParamFlowNode.getDescTuple();
-      // // NTuple<Location> calleeParamLocTuple
-      // // =###translateCompositeLocationAssignmentToFlowGraph mdCaller=public static void
-      // // huffcodetab.huffman_decoder(int htIdx, int x, BitReserve br)
-      //
-      // // translateToLocTuple(mdCallee, calleeParamDescTuple);
-      // //
-      // // System.out.println("---need to translate callerCompLoc=" + callerCompLoc
-      // // + " with baseTuple=" + baseLocTuple + "   calleeParamLocTuple="
-      // // + calleeParamLocTuple);
-      // //
-      // // CompositeLocation newCalleeCompLoc =
-      // // translateCompositeLocationToCallee(callerCompLoc, baseLocTuple, mdCallee);
-      // //
-      // // calleeGlobalGraph.addMapLocationToInferCompositeLocation(calleeParamLocTuple.get(0),
-      // // newCalleeCompLoc);
-      // //
-      // // System.out.println("---callee loc=" + calleeParamLocTuple.get(0)
-      // // + "  newCalleeCompLoc=" + newCalleeCompLoc);
-      // //
-      // // // System.out.println("###need to assign composite location to=" +
-      // // // calleeParamDescTuple
-      // // // + " with baseTuple=" + baseLocTuple);
-      // // }
-      //
-      // }
-      // }
-      // }
 
     }
-    // ////////////////
-    // ////////////////
 
     for (Iterator iterator = calleeSet.iterator(); iterator.hasNext();) {
       MethodDescriptor callee = (MethodDescriptor) iterator.next();
       translateCompositeLocationAssignmentToFlowGraph(callee);
     }
 
-    // for (Iterator iterator = minSet.iterator(); iterator.hasNext();) {
-    // MethodInvokeNode min = (MethodInvokeNode) iterator.next();
-    // // add an additional ordering constraint
-    // // if the first element of a parameter composite location matches 'this' reference,
-    // // the corresponding argument in the caller is required to be higher than the translated
-    // // parameter location in the caller lattice
-    // // TODO
-    // // addOrderingConstraintFromCompLocParamToArg(mdCaller, min);
-    // }
-
   }
 
   private CompositeLocation translateArgCompLocToParamCompLoc(MethodInvokeNode min,
@@ -655,7 +580,6 @@ public class LocationInference {
       //
       // update return flow nodes in the caller
       CompositeLocation returnLoc = getMethodSummary(mdCallee).getRETURNLoc();
-
       System.out.println("### min=" + min.printNode(0) + "  returnLoc=" + returnLoc);
       if (returnLoc != null && returnLoc.get(0).getLocDescriptor().equals(mdCallee.getThis())
           && returnLoc.getSize() > 1) {
@@ -668,6 +592,20 @@ public class LocationInference {
         }
         System.out.println("###NEW RETURN TUPLE FOR CALLER=" + newReturnTuple);
         callerFlowGraph.getFlowReturnNode(min).setNewTuple(newReturnTuple);
+      } else {
+        // if the return loc set was empty and later pcloc was connected to the return loc
+        // need to make sure that return loc reflects to this changes.
+        FlowReturnNode flowReturnNode = callerFlowGraph.getFlowReturnNode(min);
+        if (flowReturnNode != null && flowReturnNode.getReturnTupleSet().isEmpty()) {
+
+          if (needToUpdateReturnLocHolder(min.getMethod(), flowReturnNode)) {
+            NTuple<Descriptor> baseTuple = mapMethodInvokeNodeToBaseTuple.get(min);
+            NTuple<Descriptor> newReturnTuple = baseTuple.clone();
+            flowReturnNode.addTuple(newReturnTuple);
+          }
+
+        }
+
       }
 
     }
@@ -679,6 +617,23 @@ public class LocationInference {
 
   }
 
+  private boolean needToUpdateReturnLocHolder(MethodDescriptor mdCallee,
+      FlowReturnNode flowReturnNode) {
+    FlowGraph fg = getFlowGraph(mdCallee);
+    MethodSummary summary = getMethodSummary(mdCallee);
+    CompositeLocation returnCompLoc = summary.getRETURNLoc();
+    NTuple<Descriptor> returnDescTuple = translateToDescTuple(returnCompLoc.getTuple());
+    Set<FlowNode> incomingNodeToReturnNode =
+        fg.getIncomingFlowNodeSet(fg.getFlowNode(returnDescTuple));
+    for (Iterator iterator = incomingNodeToReturnNode.iterator(); iterator.hasNext();) {
+      FlowNode inNode = (FlowNode) iterator.next();
+      if (inNode.getDescTuple().get(0).equals(mdCallee.getThis())) {
+        return true;
+      }
+    }
+    return false;
+  }
+
   private void addMapMethodDescToMethodInvokeNodeSet(MethodInvokeNode min) {
     MethodDescriptor md = min.getMethod();
     if (!mapMethodDescToMethodInvokeNodeSet.containsKey(md)) {
@@ -773,6 +728,8 @@ public class LocationInference {
     System.out.println("generateCompositeLocation=" + nodeDescTuple + " with inferCompLoc="
         + inferCompLoc);
 
+    MethodDescriptor md = (MethodDescriptor) inferCompLoc.get(0).getDescriptor();
+
     CompositeLocation newCompLoc = new CompositeLocation();
     for (int i = 0; i < inferCompLoc.getSize(); i++) {
       newCompLoc.addLocation(inferCompLoc.get(i));
@@ -781,7 +738,7 @@ public class LocationInference {
     Descriptor lastDescOfPrefix = nodeDescTuple.get(0);
     Descriptor enclosingDescriptor;
     if (lastDescOfPrefix instanceof InterDescriptor) {
-      enclosingDescriptor = null;
+      enclosingDescriptor = getFlowGraph(md).getEnclosingDescriptor(lastDescOfPrefix);
     } else {
       enclosingDescriptor = ((VarDescriptor) lastDescOfPrefix).getType().getClassDesc();
     }
@@ -864,18 +821,31 @@ public class LocationInference {
           } else {
             int paramIdx = getParamIdx(callerCompLoc, mapIdxToArgTuple);
             if (paramIdx == -1) {
-              // System.out.println("*****key=" + key + "  callerCompLoc=" + callerCompLoc);
+              // here, the first element of the current composite location comes from the current
+              // callee
+              // so transfer the same composite location to the callee
               if (!calleeGlobalGraph.contrainsInferCompositeLocationMapKey(key)) {
-                // calleeGlobalGraph.addMapLocationToInferCompositeLocation(key, callerCompLoc);
-                System.out.println("3---key=" + key + "  callerCompLoc=" + callerCompLoc
-                    + "  newCalleeCompLoc=" + callerCompLoc);
-                System.out.println("-----caller=" + mdCaller + "    callee=" + mdCallee);
-                if (!callerCompLoc.get(0).getDescriptor().equals(mdCallee)) {
-                  System.exit(0);
+                if (callerCompLoc.get(0).getDescriptor().equals(mdCallee)) {
+                  System.out.println("3---key=" + key + "  callerCompLoc=" + callerCompLoc
+                      + "  newCalleeCompLoc=" + callerCompLoc);
+                  System.out.println("-----caller=" + mdCaller + "    callee=" + mdCallee);
+                  calleeGlobalGraph.addMapLocationToInferCompositeLocation(key, callerCompLoc);
+                } else {
+                  System.out.println("3---SKIP key=" + key + " callerCompLoc=" + callerCompLoc);
                 }
               }
               continue;
             }
+
+            // It is the case where two parameters have relative orderings between them by having
+            // composite locations
+            // if we found the param idx, it means that the first part of the caller composite
+            // location corresponds to the one of arguments.
+            // for example, if the caller argument is <<caller.this>,<Decoder.br>>
+            // and the current caller composite location mapping
+            // <<caller.this>,<Decoder.br>,<Br.value>>
+            // and the parameter which matches with the caller argument is 'Br brParam'
+            // then, the translated callee composite location will be <<callee.brParam>,<Br.value>>
             NTuple<Descriptor> argTuple = mapIdxToArgTuple.get(paramIdx);
 
             FlowNode paramFlowNode = calleeFlowGraph.getParamFlowNode(paramIdx);
@@ -1426,31 +1396,11 @@ public class LocationInference {
       for (Iterator iterator2 = keySet.iterator(); iterator2.hasNext();) {
         Integer argIdx = (Integer) iterator2.next();
         NTuple<Descriptor> argTuple = map.get(argIdx);
-        // System.out.println("argTuple=" + argTuple);
-        // if (argIdx == 0 && !min.getMethod().isStatic()) {
-        // ClassDescriptor currentMethodThisType = getClassTypeDescriptor(argTuple.get(0));
-        //
-        // for (int i = 0; i < curPrefix.size(); i++) {
-        // ClassDescriptor prefixType =
-        // getClassTypeDescriptor(curPrefix.get(i).getLocDescriptor());
-        // if (prefixType != null && prefixType.equals(currentMethodThisType)) {
-        // System.out.println("PREFIX TYPE MATCHES WITH=" + currentMethodThisType);
-        // for (Iterator iterator3 = subGlobalReachableSet.iterator(); iterator3.hasNext();) {
-        // GlobalFlowNode subGlobalReachalbeNode = (GlobalFlowNode) iterator3.next();
-        // if (subGlobalReachalbeNode.getLocTuple().get(0).getLocDescriptor()
-        // .equals(md.getThis())) {
-        // System.out.println("PREFIX FOUND=" + subGlobalReachalbeNode);
-        // System.out.println("here4?!");
-        //
-        // return true;
-        // }
-        // }
-        // }
-        // }
-        //
-        // }
+
         if (!(!md.isStatic() && argIdx == 0)) {
-          if (argTuple.get(argTuple.size() - 1).equals(lastLocationOfPrefix.getLocDescriptor())) {
+          // if the argTuple is empty, we don't need to do with anything(LITERAL CASE).
+          if (argTuple.size() > 0
+              && argTuple.get(argTuple.size() - 1).equals(lastLocationOfPrefix.getLocDescriptor())) {
             NTuple<Location> locTuple =
                 translateToLocTuple(md, flowGraph.getParamFlowNode(argIdx).getDescTuple());
             lastLocationOfPrefix = locTuple.get(0);
@@ -1604,34 +1554,132 @@ public class LocationInference {
 
     return prefixList;
 
-    // List<NTuple<Location>> prefixList = new ArrayList<NTuple<Location>>();
-    //
-    // for (Iterator iterator = incomingNodeSet.iterator(); iterator.hasNext();) {
-    // GlobalFlowNode inNode = (GlobalFlowNode) iterator.next();
-    // NTuple<Location> inNodeTuple = inNode.getLocTuple();
-    //
-    // for (int i = 1; i < inNodeTuple.size(); i++) {
-    // NTuple<Location> prefix = inNodeTuple.subList(0, i);
-    // if (!prefixList.contains(prefix)) {
-    // prefixList.add(prefix);
-    // }
-    // }
-    // }
+  }
+
+  private CompositeLocation calculateCompositeLocationFromFlowGraph(MethodDescriptor md,
+      FlowNode node) {
+
+    System.out.println("#############################################################");
+    System.out.println("calculateCompositeLocationFromFlowGraph=" + node);
+
+    FlowGraph flowGraph = getFlowGraph(md);
+    // NTuple<Location> paramLocTuple = translateToLocTuple(md, paramNode.getDescTuple());
+    // GlobalFlowNode paramGlobalNode = subGlobalFlowGraph.getFlowNode(paramLocTuple);
+
+    List<NTuple<Location>> prefixList = calculatePrefixListFlowGraph(flowGraph, node);
+
+    // Set<GlobalFlowNode> reachableNodeSet =
+    // subGlobalFlowGraph.getReachableNodeSetByPrefix(paramGlobalNode.getLocTuple().get(0));
     //
-    // Collections.sort(prefixList, new Comparator<NTuple<Location>>() {
-    // public int compare(NTuple<Location> arg0, NTuple<Location> arg1) {
-    // int s0 = arg0.size();
-    // int s1 = arg1.size();
-    // if (s0 > s1) {
-    // return -1;
-    // } else if (s0 == s1) {
-    // return 0;
-    // } else {
-    // return 1;
-    // }
-    // }
-    // });
-    // return prefixList;
+    Set<FlowNode> reachableNodeSet =
+        flowGraph.getReachableSetFrom(node.getDescTuple().subList(0, 1));
+
+    // Set<GlobalFlowNode> reachNodeSet = globalFlowGraph.getReachableNodeSetFrom(node);
+
+    // System.out.println("node=" + node + "    prefixList=" + prefixList);
+
+    for (int i = 0; i < prefixList.size(); i++) {
+      NTuple<Location> curPrefix = prefixList.get(i);
+      Set<NTuple<Location>> reachableCommonPrefixSet = new HashSet<NTuple<Location>>();
+
+      for (Iterator iterator2 = reachableNodeSet.iterator(); iterator2.hasNext();) {
+        FlowNode reachNode = (FlowNode) iterator2.next();
+        NTuple<Location> reachLocTuple = translateToLocTuple(md, reachNode.getCurrentDescTuple());
+        if (reachLocTuple.startsWith(curPrefix)) {
+          reachableCommonPrefixSet.add(reachLocTuple);
+        }
+      }
+      // System.out.println("reachableCommonPrefixSet=" + reachableCommonPrefixSet);
+
+      if (!reachableCommonPrefixSet.isEmpty()) {
+
+        MethodDescriptor curPrefixFirstElementMethodDesc =
+            (MethodDescriptor) curPrefix.get(0).getDescriptor();
+
+        // MethodDescriptor nodePrefixLocFirstElementMethodDesc =
+        // (MethodDescriptor) prefixLoc.getDescriptor();
+
+        // System.out.println("curPrefixFirstElementMethodDesc=" +
+        // curPrefixFirstElementMethodDesc);
+        // System.out.println("nodePrefixLocFirstElementMethodDesc="
+        // + nodePrefixLocFirstElementMethodDesc);
+
+        // TODO
+        // if (!node.getLocTuple().startsWith(curPrefix.get(0))) {
+
+        Location curPrefixLocalLoc = curPrefix.get(0);
+
+        Location targetLocalLoc = new Location(md, node.getDescTuple().get(0));
+        // Location targetLocalLoc = paramGlobalNode.getLocTuple().get(0);
+
+        CompositeLocation newCompLoc = generateCompositeLocation(curPrefix);
+        System.out.println("NEED2ASSIGN COMP LOC TO " + node + " with prefix=" + curPrefix);
+        System.out.println("-targetLocalLoc=" + targetLocalLoc + "   - newCompLoc=" + newCompLoc);
+
+        // // makes sure that a newly generated location appears in the hierarchy graph
+        // for (int compIdx = 0; compIdx < newCompLoc.getSize(); compIdx++) {
+        // Location curLoc = newCompLoc.get(compIdx);
+        // getHierarchyGraph(curLoc.getDescriptor()).getHNode(curLoc.getLocDescriptor());
+        // }
+        // subGlobalFlowGraph.addMapLocationToInferCompositeLocation(targetLocalLoc, newCompLoc);
+        node.setCompositeLocation(newCompLoc);
+
+        return newCompLoc;
+
+      }
+
+    }
+    return null;
+  }
+
+  private List<NTuple<Location>> calculatePrefixListFlowGraph(FlowGraph graph, FlowNode node) {
+
+    System.out.println("\n##### calculatePrefixList node=" + node);
+
+    MethodDescriptor md = graph.getMethodDescriptor();
+    Set<FlowNode> incomingNodeSetPrefix =
+        graph.getIncomingNodeSetByPrefix(node.getDescTuple().get(0));
+    // System.out.println("---incomingNodeSetPrefix=" + incomingNodeSetPrefix);
+
+    Set<FlowNode> reachableNodeSetPrefix =
+        graph.getReachableSetFrom(node.getDescTuple().subList(0, 1));
+    // System.out.println("---reachableNodeSetPrefix=" + reachableNodeSetPrefix);
+
+    List<NTuple<Location>> prefixList = new ArrayList<NTuple<Location>>();
+
+    for (Iterator iterator = incomingNodeSetPrefix.iterator(); iterator.hasNext();) {
+      FlowNode inNode = (FlowNode) iterator.next();
+      NTuple<Location> inNodeTuple = translateToLocTuple(md, inNode.getCurrentDescTuple());
+
+      // if (inNodeTuple.get(0).getLocDescriptor() instanceof InterDescriptor
+      // || inNodeTuple.get(0).getLocDescriptor().equals(GLOBALDESC)) {
+      // continue;
+      // }
+
+      for (int i = 1; i < inNodeTuple.size(); i++) {
+        NTuple<Location> prefix = inNodeTuple.subList(0, i);
+        if (!prefixList.contains(prefix)) {
+          prefixList.add(prefix);
+        }
+      }
+    }
+
+    Collections.sort(prefixList, new Comparator<NTuple<Location>>() {
+      public int compare(NTuple<Location> arg0, NTuple<Location> arg1) {
+        int s0 = arg0.size();
+        int s1 = arg1.size();
+        if (s0 > s1) {
+          return -1;
+        } else if (s0 == s1) {
+          return 0;
+        } else {
+          return 1;
+        }
+      }
+    });
+
+    return prefixList;
+
   }
 
   private boolean containsClassDesc(ClassDescriptor cd, NTuple<Location> prefixLocTuple) {
@@ -1702,7 +1750,6 @@ public class LocationInference {
     NTuple<Location> locTuple = new NTuple<Location>();
 
     Descriptor enclosingDesc = md;
-    // System.out.println("md=" + md + "  descTuple=" + descTuple);
     for (int i = 0; i < descTuple.size(); i++) {
       Descriptor desc = descTuple.get(i);
 
@@ -1846,8 +1893,9 @@ public class LocationInference {
     // this method will return the same nodeLocTuple if the corresponding argument is literal
     // value.
 
-    FlowGraph calleeFlowGraph = getFlowGraph(mdCallee);
+    // System.out.println("translateToCallerLocTuple=" + nodeLocTuple);
 
+    FlowGraph calleeFlowGraph = getFlowGraph(mdCallee);
     NTuple<Descriptor> nodeDescTuple = translateToDescTuple(nodeLocTuple);
     if (calleeFlowGraph.isParameter(nodeDescTuple)) {
       int paramIdx = calleeFlowGraph.getParamIdx(nodeDescTuple);
@@ -1857,7 +1905,8 @@ public class LocationInference {
       // // the type of argument is primitive.
       // return nodeLocTuple.clone();
       // }
-      // System.out.println("paramIdx=" + paramIdx + "  argDescTuple=" + argDescTuple);
+      // System.out.println("paramIdx=" + paramIdx + "  argDescTuple=" + argDescTuple + " from min="
+      // + min.printNode(0));
       NTuple<Location> argLocTuple = translateToLocTuple(mdCaller, argDescTuple);
 
       NTuple<Location> callerLocTuple = new NTuple<Location>();
@@ -1886,6 +1935,29 @@ public class LocationInference {
     return false;
   }
 
+  public static boolean isReference(Descriptor desc) {
+
+    if (desc instanceof FieldDescriptor) {
+
+      TypeDescriptor type = ((FieldDescriptor) desc).getType();
+      if (type.isArray()) {
+        return false;
+      } else {
+        return type.isPtr();
+      }
+
+    } else if (desc instanceof VarDescriptor) {
+      TypeDescriptor type = ((VarDescriptor) desc).getType();
+      if (type.isArray()) {
+        return false;
+      } else {
+        return type.isPtr();
+      }
+    }
+
+    return false;
+  }
+
   private NTuple<Descriptor> translateToDescTuple(NTuple<Location> locTuple) {
 
     NTuple<Descriptor> descTuple = new NTuple<Descriptor>();
@@ -2472,7 +2544,8 @@ public class LocationInference {
           NTuple<Descriptor> srcCurTuple = srcNode.getCurrentDescTuple();
           NTuple<Descriptor> dstCurTuple = dstNode.getCurrentDescTuple();
 
-          System.out.println("-srcCurTuple=" + srcCurTuple + "  dstCurTuple=" + dstCurTuple);
+          System.out.println("-srcCurTuple=" + srcCurTuple + "  dstCurTuple=" + dstCurTuple
+              + "  srcNode=" + srcNode + "   dstNode=" + dstNode);
 
           if ((srcCurTuple.size() > 1 && dstCurTuple.size() > 1)
               && srcCurTuple.get(0).equals(dstCurTuple.get(0))) {
@@ -2667,20 +2740,31 @@ public class LocationInference {
       }
     }
 
-    rtr += "\")";
-
     if (desc instanceof MethodDescriptor) {
       System.out.println("#EXTRA LOC DECLARATION GEN=" + desc);
 
       MethodDescriptor md = (MethodDescriptor) desc;
       MethodSummary methodSummary = getMethodSummary(md);
 
+      TypeDescriptor returnType = ((MethodDescriptor) desc).getReturnType();
+      if (!ssjava.getMethodContainingSSJavaLoop().equals(desc) && returnType != null
+          && (!returnType.isVoid())) {
+        CompositeLocation returnLoc = methodSummary.getRETURNLoc();
+        if (returnLoc.getSize() == 1) {
+          String returnLocStr = generateLocationAnnoatation(methodSummary.getRETURNLoc());
+          if (rtr.indexOf(returnLocStr) == -1) {
+            rtr += "," + returnLocStr;
+          }
+        }
+      }
+      rtr += "\")";
+
       if (!ssjava.getMethodContainingSSJavaLoop().equals(desc)) {
-        TypeDescriptor returnType = ((MethodDescriptor) desc).getReturnType();
         if (returnType != null && (!returnType.isVoid())) {
           rtr +=
               "\n@RETURNLOC(\"" + generateLocationAnnoatation(methodSummary.getRETURNLoc()) + "\")";
         }
+
         CompositeLocation pcLoc = methodSummary.getPCLoc();
         if ((pcLoc != null) && (!pcLoc.get(0).isTop())) {
           rtr += "\n@PCLOC(\"" + generateLocationAnnoatation(pcLoc) + "\")";
@@ -2692,6 +2776,8 @@ public class LocationInference {
       }
       rtr += "\n@GLOBALLOC(\"" + methodSummary.getGlobalLocName() + "\")";
 
+    } else {
+      rtr += "\")";
     }
 
     return rtr;
@@ -2790,6 +2876,7 @@ public class LocationInference {
               if (mapDescToDefinitionLine.containsKey(localVarDesc)) {
                 int varLineNum = mapDescToDefinitionLine.get(localVarDesc);
                 String orgSourceLine = sourceVec.get(varLineNum);
+                System.out.println("varLineNum=" + varLineNum + "  org src=" + orgSourceLine);
                 int idx =
                     orgSourceLine.indexOf(generateVarDeclaration((VarDescriptor) localVarDesc));
                 System.out.println("idx=" + idx
@@ -3255,9 +3342,11 @@ public class LocationInference {
     // calculate a return location:
     // the return location type is lower than all parameters and the location of return values
     MethodSummary methodSummary = getMethodSummary(md);
-    if (methodSummary.getRETURNLoc() != null) {
-      return;
-    }
+    // if (methodSummary.getRETURNLoc() != null) {
+    // System.out.println("$HERE?");
+    // return;
+    // }
+
     FlowGraph fg = getFlowGraph(md);
     Map<Integer, CompositeLocation> mapParamToLoc = methodSummary.getMapParamIdxToInferLoc();
     Set<Integer> paramIdxSet = mapParamToLoc.keySet();
@@ -3305,6 +3394,13 @@ public class LocationInference {
 
       }
 
+      // makes sure that PCLOC is higher than RETURNLOC
+      CompositeLocation pcLoc = methodSummary.getPCLoc();
+      if (!pcLoc.get(0).isTop()) {
+        NTuple<Descriptor> pcLocDescTuple = translateToDescTuple(pcLoc.getTuple());
+        fg.addValueFlowEdge(pcLocDescTuple, returnDescTuple);
+      }
+
     }
 
   }
@@ -3364,7 +3460,8 @@ public class LocationInference {
     } else {
       // all parameter is started with 'this', so PCLOC will be set relative to the composite
       // location started with 'this'.
-      for (int idx = 0; idx < minSize - 1; idx++) {
+      // for (int idx = 0; idx < minSize - 1; idx++) {
+      for (int idx = 0; idx < 1; idx++) {
         Set<Descriptor> locDescSet = new HashSet<Descriptor>();
         Location curLoc = null;
         NTuple<Location> paramLocTuple = null;
@@ -3648,9 +3745,14 @@ public class LocationInference {
     for (int idx = 0; idx < numParam; idx++) {
       FlowNode paramNode = calleeFlowGraph.getParamFlowNode(idx);
       CompositeLocation compLoc = paramNode.getCompositeLocation();
+      System.out.println("paramNode=" + paramNode + "   compLoc=" + compLoc);
       if (compLoc != null && compLoc.get(0).getLocDescriptor().equals(min.getMethod().getThis())) {
-        System.out.println("$$$COMPLOC CASE=" + compLoc);
+        System.out.println("$$$COMPLOC CASE=" + compLoc + "  idx=" + idx);
+
         NTuple<Descriptor> argTuple = getNodeTupleByArgIdx(min, idx);
+        System.out.println("--- argTuple=" + argTuple + " current compLoc="
+            + callerFlowGraph.getFlowNode(argTuple).getCompositeLocation());
+
         NTuple<Descriptor> translatedParamTuple =
             translateCompositeLocationToCaller(idx, min, compLoc);
         System.out.println("add a flow edge= " + argTuple + "->" + translatedParamTuple);
@@ -3689,7 +3791,7 @@ public class LocationInference {
       tuple.add(baseTuple.get(i));
     }
 
-    for (int i = baseTuple.size(); i < compLocForParam1.getSize(); i++) {
+    for (int i = 1; i < compLocForParam1.getSize(); i++) {
       Location loc = compLocForParam1.get(i);
       tuple.add(loc.getLocDescriptor());
     }
@@ -3803,6 +3905,8 @@ public class LocationInference {
       } else if (curDescriptor instanceof NameDescriptor) {
         // it is "GLOBAL LOC" case!
         enclosingDescriptor = GLOBALDESC;
+      } else if (curDescriptor instanceof InterDescriptor) {
+        enclosingDescriptor = getFlowGraph(md).getEnclosingDescriptor(curDescriptor);
       } else {
         enclosingDescriptor = null;
       }
@@ -3991,8 +4095,10 @@ public class LocationInference {
           + "   idx=" + idx);
       if (!srcFieldDesc.equals(dstFieldDesc)) {
         // add a new edge
+        System.out.println("-ADD EDGE");
         getHierarchyGraph(cd).addEdge(srcFieldDesc, dstFieldDesc);
-      } else if (isPrimitive(srcFieldDesc) && isPrimitive(dstFieldDesc)) {
+      } else if (!isReference(srcFieldDesc) && !isReference(dstFieldDesc)) {
+        System.out.println("-ADD EDGE");
         getHierarchyGraph(cd).addEdge(srcFieldDesc, dstFieldDesc);
       }
 
@@ -4084,6 +4190,21 @@ public class LocationInference {
     System.out.println("");
     toanalyze_methodDescList = computeMethodList();
 
+    // hack... it seems that there is a problem with topological sorting.
+    // so String.toString(Object o) is appeared too higher in the call chain.
+    MethodDescriptor mdToString = null;
+    for (Iterator iterator = toanalyze_methodDescList.iterator(); iterator.hasNext();) {
+      MethodDescriptor md = (MethodDescriptor) iterator.next();
+      if (md.toString().equals("public static String String.valueOf(Object o)")) {
+        mdToString = md;
+        break;
+      }
+    }
+    if (mdToString != null) {
+      toanalyze_methodDescList.remove(mdToString);
+      toanalyze_methodDescList.addLast(mdToString);
+    }
+
     LinkedList<MethodDescriptor> methodDescList =
         (LinkedList<MethodDescriptor>) toanalyze_methodDescList.clone();
 
@@ -4426,6 +4547,7 @@ public class LocationInference {
       newImplicitTupleSet.addTupleSet(implicitFlowTupleSet);
       newImplicitTupleSet.addTupleSet(condTupleNode);
 
+      System.out.println("A5");
       newImplicitTupleSet.addGlobalFlowTupleSet(implicitFlowTupleSet.getGlobalLocTupleSet());
       newImplicitTupleSet.addGlobalFlowTupleSet(condTupleNode.getGlobalLocTupleSet());
 
@@ -4540,7 +4662,7 @@ public class LocationInference {
   private void analyzeFlowIfStatementNode(MethodDescriptor md, SymbolTable nametable,
       IfStatementNode isn, NodeTupleSet implicitFlowTupleSet) {
 
-    // System.out.println("analyzeFlowIfStatementNode=" + isn.printNode(0));
+    System.out.println("analyzeFlowIfStatementNode=" + isn.printNode(0));
 
     NodeTupleSet condTupleNode = new NodeTupleSet();
     analyzeFlowExpressionNode(md, nametable, isn.getCondition(), condTupleNode, null,
@@ -4579,6 +4701,7 @@ public class LocationInference {
     // translateToLocTuple(md, callerImplicitTuple));
     // }
     // }
+    System.out.println("A4");
     newImplicitTupleSet.addGlobalFlowTupleSet(condTupleNode.getGlobalLocTupleSet());
 
     analyzeFlowBlockNode(md, nametable, isn.getTrueBlock(), newImplicitTupleSet);
@@ -4650,12 +4773,13 @@ public class LocationInference {
       ExpressionNode en, NodeTupleSet nodeSet, NTuple<Descriptor> base,
       NodeTupleSet implicitFlowTupleSet, boolean isLHS) {
 
+    // System.out.println("en=" + en.printNode(0) + "   class=" + en.getClass());
+
     // note that expression node can create more than one flow node
     // nodeSet contains of flow nodes
     // base is always assigned to null except the case of a name node!
     NTuple<Descriptor> flowTuple;
     switch (en.kind()) {
-
     case Kind.AssignmentNode:
       analyzeFlowAssignmentNode(md, nametable, (AssignmentNode) en, nodeSet, base,
           implicitFlowTupleSet);
@@ -4741,7 +4865,7 @@ public class LocationInference {
   private void analyzeFlowTertiaryNode(MethodDescriptor md, SymbolTable nametable, TertiaryNode tn,
       NodeTupleSet nodeSet, NodeTupleSet implicitFlowTupleSet) {
 
-    // System.out.println("analyzeFlowTertiaryNode=" + tn.printNode(0));
+    System.out.println("analyzeFlowTertiaryNode=" + tn.printNode(0));
 
     NodeTupleSet tertiaryTupleNode = new NodeTupleSet();
     analyzeFlowExpressionNode(md, nametable, tn.getCond(), tertiaryTupleNode, null,
@@ -4768,8 +4892,10 @@ public class LocationInference {
       newImplicitTupleSet.addTuple(interTuple);
     }
 
+    System.out.println("A7");
     newImplicitTupleSet.addGlobalFlowTupleSet(tertiaryTupleNode.getGlobalLocTupleSet());
 
+    System.out.println("---------newImplicitTupleSet=" + newImplicitTupleSet);
     // add edges from tertiaryTupleNode to all nodes of conditional nodes
     // tertiaryTupleNode.addTupleSet(implicitFlowTupleSet);
     analyzeFlowExpressionNode(md, nametable, tn.getTrueExpr(), tertiaryTupleNode, null,
@@ -4778,6 +4904,7 @@ public class LocationInference {
     analyzeFlowExpressionNode(md, nametable, tn.getFalseExpr(), tertiaryTupleNode, null,
         newImplicitTupleSet, false);
 
+    System.out.println("A8");
     nodeSet.addGlobalFlowTupleSet(tertiaryTupleNode.getGlobalLocTupleSet());
     nodeSet.addTupleSet(tertiaryTupleNode);
 
@@ -4858,7 +4985,7 @@ public class LocationInference {
       addMapCallerMethodDescToMethodInvokeNodeSet(mdCaller, min);
 
       FlowGraph calleeFlowGraph = getFlowGraph(mdCallee);
-      System.out.println("mdCallee=" + mdCallee);
+      System.out.println("mdCallee=" + mdCallee + " calleeFlowGraph=" + calleeFlowGraph);
       Set<FlowNode> calleeReturnSet = calleeFlowGraph.getReturnNodeSet();
 
       System.out.println("---calleeReturnSet=" + calleeReturnSet);
@@ -4870,6 +4997,7 @@ public class LocationInference {
         NodeTupleSet baseNodeSet = new NodeTupleSet();
         analyzeFlowExpressionNode(mdCaller, nametable, min.getExpression(), baseNodeSet, null,
             implicitFlowTupleSet, false);
+        System.out.println("baseNodeSet=" + baseNodeSet);
 
         assert (baseNodeSet.size() == 1);
         NTuple<Descriptor> baseTuple = baseNodeSet.iterator().next();
@@ -4885,19 +5013,30 @@ public class LocationInference {
               // the location type of the return value is started with 'this'
               // reference
               NTuple<Descriptor> inFlowTuple = new NTuple<Descriptor>(baseTuple.getList());
+
+              if (inFlowTuple.get(0) instanceof InterDescriptor) {
+                // min.getExpression()
+              } else {
+
+              }
+
               inFlowTuple.addAll(returnDescTuple.subList(1, returnDescTuple.size()));
               // nodeSet.addTuple(inFlowTuple);
+              System.out.println("1CREATE A NEW TUPLE=" + inFlowTuple + "  from="
+                  + mdCallee.getThis());
               tupleSet.addTuple(inFlowTuple);
             } else {
               // TODO
+              System.out.println("returnNode=" + returnNode);
               Set<FlowNode> inFlowSet = calleeFlowGraph.getIncomingFlowNodeSet(returnNode);
               // System.out.println("inFlowSet=" + inFlowSet + "   from retrunNode=" + returnNode);
               for (Iterator iterator2 = inFlowSet.iterator(); iterator2.hasNext();) {
                 FlowNode inFlowNode = (FlowNode) iterator2.next();
                 if (inFlowNode.getDescTuple().startsWith(mdCallee.getThis())) {
                   // nodeSet.addTupleSet(baseNodeSet);
+                  System.out.println("2CREATE A NEW TUPLE=" + baseNodeSet + "  from="
+                      + mdCallee.getThis());
                   tupleSet.addTupleSet(baseNodeSet);
-
                 }
               }
             }
@@ -4922,7 +5061,7 @@ public class LocationInference {
           NodeTupleSet argTupleSet = new NodeTupleSet();
           analyzeFlowExpressionNode(mdCaller, nametable, en, argTupleSet, false);
           // if argument is liternal node, argTuple is set to NULL
-          System.out.println("argTupleSet=" + argTupleSet);
+          System.out.println("---arg idx=" + idx + "   argTupleSet=" + argTupleSet);
           NTuple<Descriptor> argTuple = generateArgTuple(mdCaller, argTupleSet);
 
           // if an argument is literal value,
@@ -4930,16 +5069,16 @@ public class LocationInference {
           // that node if needed
           if (argTuple.size() > 0
               && (argTuple.get(0).equals(GLOBALDESC) || argTuple.get(0).equals(LITERALDESC))) {
-            System.out.println("***GLOBAL ARG TUPLE CASE=" + argTuple);
-            System.out.println("8");
-
-            NTuple<Descriptor> interTuple =
-                getFlowGraph(mdCaller).createIntermediateNode().getDescTuple();
-            ((InterDescriptor) interTuple.get(0)).setMethodArgIdxPair(min, idx);
-            addFlowGraphEdge(mdCaller, argTuple, interTuple);
-            argTuple = interTuple;
-            addArgIdxMap(min, idx, argTuple);
-            System.out.println("new min mapping i=" + idx + "  ->" + argTuple);
+            /*
+             * System.out.println("***GLOBAL ARG TUPLE CASE=" + argTuple); System.out.println("8");
+             * 
+             * NTuple<Descriptor> interTuple =
+             * getFlowGraph(mdCaller).createIntermediateNode().getDescTuple(); ((InterDescriptor)
+             * interTuple.get(0)).setMethodArgIdxPair(min, idx); addFlowGraphEdge(mdCaller,
+             * argTuple, interTuple); argTuple = interTuple; addArgIdxMap(min, idx, argTuple);
+             * System.out.println("new min mapping i=" + idx + "  ->" + argTuple);
+             */
+            argTuple = new NTuple<Descriptor>();
           }
 
           addArgIdxMap(min, idx, argTuple);
@@ -4958,10 +5097,12 @@ public class LocationInference {
           // }
           // }
 
+          System.out.println("paramNode=" + paramNode + "  calleeReturnSet=" + calleeReturnSet);
           if (hasInFlowTo(calleeFlowGraph, paramNode, calleeReturnSet)
               || mdCallee.getModifiers().isNative()) {
             addParamNodeFlowingToReturnValue(mdCallee, paramNode);
             // nodeSet.addTupleSet(argTupleSet);
+            System.out.println("3CREATE A NEW TUPLE=" + argTupleSet + "  from=" + paramNode);
             tupleSet.addTupleSet(argTupleSet);
           }
         }
@@ -4970,8 +5111,42 @@ public class LocationInference {
 
       if (mdCallee.getReturnType() != null && !mdCallee.getReturnType().isVoid()) {
         FlowReturnNode setNode = getFlowGraph(mdCaller).createReturnNode(min);
-        setNode.addTupleSet(tupleSet);
+
+        if (needToGenerateInterLoc(tupleSet)) {
+          System.out.println("20");
+          FlowGraph fg = getFlowGraph(mdCaller);
+          FlowNode interNode = fg.createIntermediateNode();
+          interNode.setFormHolder(true);
+
+          NTuple<Descriptor> interTuple = interNode.getDescTuple();
+
+          for (Iterator iterator = tupleSet.iterator(); iterator.hasNext();) {
+            NTuple<Descriptor> tuple = (NTuple<Descriptor>) iterator.next();
+
+            Set<NTuple<Descriptor>> addSet = new HashSet<NTuple<Descriptor>>();
+            FlowNode node = fg.getFlowNode(tuple);
+            if (node instanceof FlowReturnNode) {
+              addSet.addAll(fg.getReturnTupleSet(((FlowReturnNode) node).getReturnTupleSet()));
+            } else {
+              addSet.add(tuple);
+            }
+            for (Iterator iterator2 = addSet.iterator(); iterator2.hasNext();) {
+              NTuple<Descriptor> higher = (NTuple<Descriptor>) iterator2.next();
+              addFlowGraphEdge(mdCaller, higher, interTuple);
+            }
+          }
+
+          setNode.addTuple(interTuple);
+          System.out.println("ADD TUPLESET=" + interTuple + " to returnnode=" + setNode);
+
+        } else {
+          setNode.addTupleSet(tupleSet);
+          System.out.println("ADD TUPLESET=" + tupleSet + " to returnnode=" + setNode);
+
+        }
+        // setNode.addTupleSet(tupleSet);
         nodeSet.addTuple(setNode.getDescTuple());
+
       }
 
       // propagateFlowsFromCallee(min, md, min.getMethod());
@@ -4984,8 +5159,14 @@ public class LocationInference {
         NTuple<Location> calleeReturnLocTuple =
             translateToLocTuple(mdCallee, calleeReturnNode.getDescTuple());
         System.out.println("calleeReturnLocTuple=" + calleeReturnLocTuple);
-        nodeSet.addGlobalFlowTuple(translateToCallerLocTuple(min, mdCallee, mdCaller,
-            calleeReturnLocTuple));
+        NTuple<Location> transaltedToCaller =
+            translateToCallerLocTuple(min, mdCallee, mdCaller, calleeReturnLocTuple);
+        // System.out.println("translateToCallerLocTuple="
+        // + translateToCallerLocTuple(min, mdCallee, mdCaller, calleeReturnLocTuple));
+        if (transaltedToCaller.size() > 0) {
+          nodeSet.addGlobalFlowTuple(translateToCallerLocTuple(min, mdCallee, mdCaller,
+              calleeReturnLocTuple));
+        }
       }
 
       System.out.println("min nodeSet=" + nodeSet);
@@ -5035,9 +5216,13 @@ public class LocationInference {
   private boolean hasInFlowTo(FlowGraph fg, FlowNode inNode, Set<FlowNode> nodeSet) {
     // return true if inNode has in-flows to nodeSet
 
+    if (nodeSet.contains(inNode)) {
+      // in this case, the method directly returns a parameter variable.
+      return true;
+    }
     // Set<FlowNode> reachableSet = fg.getReachFlowNodeSetFrom(inNode);
     Set<FlowNode> reachableSet = fg.getReachableSetFrom(inNode.getDescTuple());
-    // System.out.println("inNode=" + inNode + "  reachalbeSet=" + reachableSet);
+    System.out.println("inNode=" + inNode + "  reachalbeSet=" + reachableSet);
 
     for (Iterator iterator = reachableSet.iterator(); iterator.hasNext();) {
       FlowNode fn = (FlowNode) iterator.next();
@@ -5074,14 +5259,16 @@ public class LocationInference {
   private void analyzeFlowArrayAccessNode(MethodDescriptor md, SymbolTable nametable,
       ArrayAccessNode aan, NodeTupleSet nodeSet, boolean isLHS) {
 
-    // System.out.println("analyzeFlowArrayAccessNode aan=" + aan.printNode(0));
+    System.out.println("analyzeFlowArrayAccessNode aan=" + aan.printNode(0));
     String currentArrayAccessNodeExpStr = aan.printNode(0);
     arrayAccessNodeStack.push(aan.printNode(0));
 
     NodeTupleSet expNodeTupleSet = new NodeTupleSet();
     NTuple<Descriptor> base =
         analyzeFlowExpressionNode(md, nametable, aan.getExpression(), expNodeTupleSet, isLHS);
+    System.out.println("-base=" + base);
 
+    nodeSet.setMethodInvokeBaseDescTuple(base);
     NodeTupleSet idxNodeTupleSet = new NodeTupleSet();
     analyzeFlowExpressionNode(md, nametable, aan.getIndex(), idxNodeTupleSet, isLHS);
 
@@ -5128,9 +5315,17 @@ public class LocationInference {
           }
           nodeSetArrayAccessExp.clear();
           nodeSetArrayAccessExp.addTuple(interTuple);
+          FlowGraph fg = getFlowGraph(md);
+
+          System.out.println("base=" + base);
+          if (base != null) {
+            fg.addMapInterLocNodeToEnclosingDescriptor(interTuple.get(0),
+                getClassTypeDescriptor(base.get(base.size() - 1)));
+          }
         }
       }
 
+      System.out.println("A1");
       nodeSet.addGlobalFlowTupleSet(idxNodeTupleSet.getGlobalLocTupleSet());
       nodeSet.addTupleSet(nodeSetArrayAccessExp);
 
@@ -5150,15 +5345,19 @@ public class LocationInference {
     NodeTupleSet leftOpSet = new NodeTupleSet();
     NodeTupleSet rightOpSet = new NodeTupleSet();
 
+    System.out.println("analyzeFlowOpNode=" + on.printNode(0));
+
     // left operand
     analyzeFlowExpressionNode(md, nametable, on.getLeft(), leftOpSet, null, implicitFlowTupleSet,
         false);
+    System.out.println("--leftOpSet=" + leftOpSet);
 
     if (on.getRight() != null) {
       // right operand
       analyzeFlowExpressionNode(md, nametable, on.getRight(), rightOpSet, null,
           implicitFlowTupleSet, false);
     }
+    System.out.println("--rightOpSet=" + rightOpSet);
 
     Operation op = on.getOp();
 
@@ -5197,6 +5396,7 @@ public class LocationInference {
       nodeSet.addTupleSet(leftOpSet);
       nodeSet.addTupleSet(rightOpSet);
 
+      System.out.println("A6");
       nodeSet.addGlobalFlowTupleSet(leftOpSet.getGlobalLocTupleSet());
       nodeSet.addGlobalFlowTupleSet(rightOpSet.getGlobalLocTupleSet());
 
@@ -5327,7 +5527,6 @@ public class LocationInference {
       analyzeFlowExpressionNode(md, nametable, aan.getIndex(), idxNodeTupleSet, base,
           implicitFlowTupleSet, isLHS);
 
-      nodeSet.addTupleSet(idxNodeTupleSet);
     }
     base =
         analyzeFlowExpressionNode(md, nametable, left, nodeSet, base, implicitFlowTupleSet, isLHS);
@@ -5363,6 +5562,7 @@ public class LocationInference {
         }
 
       } else {
+        nodeSet.addTupleSet(idxNodeTupleSet);
 
         // if it is the array case and not the LHS case
         if (isArrayCase) {
@@ -5390,10 +5590,15 @@ public class LocationInference {
                 NTuple<Descriptor> higherTuple = iter.next();
                 addFlowGraphEdge(md, higherTuple, interTuple);
               }
+
+              FlowGraph fg = getFlowGraph(md);
+              fg.addMapInterLocNodeToEnclosingDescriptor(interTuple.get(0),
+                  getClassTypeDescriptor(base.get(base.size() - 1)));
+
               nodeSet.clear();
               flowFieldTuple = interTuple;
             }
-
+            System.out.println("A3");
             nodeSet.addGlobalFlowTupleSet(idxNodeTupleSet.getGlobalLocTupleSet());
           }
 
@@ -5434,10 +5639,10 @@ public class LocationInference {
       analyzeFlowExpressionNode(md, nametable, an.getSrc(), nodeSetRHS, null, implicitFlowTupleSet,
           false);
 
-      // System.out.println("-analyzeFlowAssignmentNode=" + an.printNode(0));
-      // System.out.println("-nodeSetLHS=" + nodeSetLHS);
-      // System.out.println("-nodeSetRHS=" + nodeSetRHS);
-      // System.out.println("-implicitFlowTupleSet=" + implicitFlowTupleSet);
+      System.out.println("-analyzeFlowAssignmentNode=" + an.printNode(0));
+      System.out.println("-nodeSetLHS=" + nodeSetLHS);
+      System.out.println("-nodeSetRHS=" + nodeSetRHS);
+      System.out.println("-implicitFlowTupleSet=" + implicitFlowTupleSet);
       // System.out.println("-");
 
       if (an.getOperation().getOp() >= 2 && an.getOperation().getOp() <= 12) {
@@ -5456,7 +5661,6 @@ public class LocationInference {
       NTuple<Descriptor> interTuple = null;
       if (needToGenerateInterLoc(nodeSetRHS)) {
         System.out.println("2");
-
         interTuple = getFlowGraph(md).createIntermediateNode().getDescTuple();
       }
 
@@ -5483,10 +5687,10 @@ public class LocationInference {
         NTuple<Location> calleeReturnLocTuple = iterator.next();
         for (Iterator<NTuple<Descriptor>> iter2 = nodeSetLHS.iterator(); iter2.hasNext();) {
           NTuple<Descriptor> callerLHSTuple = iter2.next();
-          globalFlowGraph.addValueFlowEdge(calleeReturnLocTuple,
-              translateToLocTuple(md, callerLHSTuple));
           System.out.println("$$$ GLOBAL FLOW ADD=" + calleeReturnLocTuple + " -> "
               + translateToLocTuple(md, callerLHSTuple));
+          globalFlowGraph.addValueFlowEdge(calleeReturnLocTuple,
+              translateToLocTuple(md, callerLHSTuple));
         }
       }
 
@@ -5536,6 +5740,7 @@ public class LocationInference {
 
     if (nodeSet != null) {
       nodeSet.addTupleSet(nodeSetLHS);
+      System.out.println("A2");
       nodeSet.addGlobalFlowTupleSet(nodeSetLHS.getGlobalLocTupleSet());
     }
   }
@@ -5601,7 +5806,6 @@ public class LocationInference {
 
           String highLocId = pair.getFirst();
           String lowLocId = pair.getSecond();
-          System.out.println("addedLocSet=" + addedLocSet);
           if (!addedLocSet.contains(highLocId)) {
             addedLocSet.add(highLocId);
             drawNode(bw, locOrder, simpleHierarchyGraph, highLocId);