+ }
+
+ private boolean checkFlowNodeReturnThisField(MethodDescriptor md) {
+
+ MethodDescriptor methodDescEventLoop = ssjava.getMethodContainingSSJavaLoop();
+ GlobalFlowGraph globalFlowGraph = getSubGlobalFlowGraph(methodDescEventLoop);
+
+ FlowGraph flowGraph = getFlowGraph(md);
+
+ ClassDescriptor enclosingDesc = getClassTypeDescriptor(md.getThis());
+ if (enclosingDesc == null) {
+ return false;
+ }
+
+ int count = 0;
+ Set<FlowNode> returnNodeSet = flowGraph.getReturnNodeSet();
+ Set<GlobalFlowNode> globalReturnNodeSet = new HashSet<GlobalFlowNode>();
+ for (Iterator iterator = returnNodeSet.iterator(); iterator.hasNext();) {
+ FlowNode flowNode = (FlowNode) iterator.next();
+ NTuple<Location> locTuple = translateToLocTuple(md, flowNode.getDescTuple());
+ GlobalFlowNode globalReturnNode = globalFlowGraph.getFlowNode(locTuple);
+ globalReturnNodeSet.add(globalReturnNode);
+
+ List<NTuple<Location>> prefixList = calculatePrefixList(globalFlowGraph, globalReturnNode);
+ for (int i = 0; i < prefixList.size(); i++) {
+ NTuple<Location> curPrefix = prefixList.get(i);
+ ClassDescriptor cd =
+ getClassTypeDescriptor(curPrefix.get(curPrefix.size() - 1).getLocDescriptor());
+ if (cd != null && cd.equals(enclosingDesc)) {
+ count++;
+ break;
+ }
+ }
+
+ }
+
+ if (count == returnNodeSet.size()) {
+ mapMethodDescriptorToCompositeReturnCase.put(md, Boolean.TRUE);
+
+ NameDescriptor returnLocDesc = new NameDescriptor("RLOC" + (locSeed++));
+ NTuple<Descriptor> rDescTuple = new NTuple<Descriptor>();
+ rDescTuple.add(md.getThis());
+ rDescTuple.add(returnLocDesc);
+
+ for (Iterator iterator = returnNodeSet.iterator(); iterator.hasNext();) {
+ FlowNode rnode = (FlowNode) iterator.next();
+ flowGraph.addValueFlowEdge(rnode.getDescTuple(), rDescTuple);
+ }
+
+ getMethodSummary(md).setRETURNLoc(new CompositeLocation(translateToLocTuple(md, rDescTuple)));
+
+ } else {
+ mapMethodDescriptorToCompositeReturnCase.put(md, Boolean.FALSE);
+ }
+
+ return mapMethodDescriptorToCompositeReturnCase.get(md).booleanValue();
+
+ }
+
+ private boolean needToGenerateCompositeLocation(GlobalFlowNode node, NTuple<Location> curPrefix) {
+ // return true if there is a path between a node to which we want to give a composite location
+ // and nodes which start with curPrefix
+
+ Location targetLocalLoc = node.getLocTuple().get(0);
+
+ if (targetLocalLoc.getLocDescriptor() instanceof InterDescriptor) {
+ if (((InterDescriptor) targetLocalLoc.getLocDescriptor()).isHolder()) {
+ return true;
+ }
+ }
+
+ MethodDescriptor md = (MethodDescriptor) targetLocalLoc.getDescriptor();
+ GlobalFlowGraph globalFlowGraph = getSubGlobalFlowGraph(md);
+ FlowGraph flowGraph = getFlowGraph(md);
+
+ // System.out.println("flowGraph.getReturnNodeSet()=" + flowGraph.getReturnNodeSet());
+ // System.out.println("flowGraph.contains(node.getDescTuple())="
+ // + flowGraph.contains(node.getDescTuple()) + " flowGraph.getFlowNode(node.getDescTuple())="
+ // + flowGraph.getFlowNode(node.getDescTuple()));
+
+ // if (flowGraph.contains(node.getDescTuple())
+ // && flowGraph.getReturnNodeSet().contains(flowGraph.getFlowNode(node.getDescTuple()))) {
+ // // return checkFlowNodeReturnThisField(flowGraph);
+ // }
+ FlowNode flowNode = flowGraph.getFlowNode(node.getDescTuple());
+ Set<FlowNode> reachableSet = flowGraph.getReachFlowNodeSetFrom(flowNode);
+
+ Location lastLocationOfPrefix = curPrefix.get(curPrefix.size() - 1);
+ ClassDescriptor cd;
+ if (lastLocationOfPrefix.getLocDescriptor() instanceof VarDescriptor) {
+ cd = ((VarDescriptor) lastLocationOfPrefix.getLocDescriptor()).getType().getClassDesc();
+ } else {
+ // it is a field descriptor
+ cd = ((FieldDescriptor) lastLocationOfPrefix.getLocDescriptor()).getType().getClassDesc();
+ }
+
+ System.out.println("-----class descriptor=" + cd);
+ System.out.println("-----reachableSet from=" + reachableSet);
+
+ for (Iterator iterator2 = reachableSet.iterator(); iterator2.hasNext();) {
+ FlowNode reachalbeNode = (FlowNode) iterator2.next();
+ NTuple<Location> locTuple = translateToLocTuple(md, reachalbeNode.getDescTuple());
+ Location lastLoc = locTuple.get(locTuple.size() - 1);
+ Descriptor enclosingDescriptor = lastLoc.getDescriptor();
+
+ if (enclosingDescriptor != null && enclosingDescriptor.equals(cd)) {
+ return true;
+ }
+ }
+
+ return false;