X-Git-Url: http://plrg.eecs.uci.edu/git/?p=IRC.git;a=blobdiff_plain;f=Robust%2Fsrc%2FAnalysis%2FSSJava%2FFlowGraph.java;h=c2a8f8ecc98f1b34288a25729b7bc5a739e43966;hp=f71b82d07c07e392cb7e4f917ab752854cc776df;hb=8d750e51bc5fa6b54ed568859dd8a6a25ad9e4c4;hpb=52bd77482e98618483034a513931c50a870b9a47 diff --git a/Robust/src/Analysis/SSJava/FlowGraph.java b/Robust/src/Analysis/SSJava/FlowGraph.java index f71b82d0..c2a8f8ec 100644 --- a/Robust/src/Analysis/SSJava/FlowGraph.java +++ b/Robust/src/Analysis/SSJava/FlowGraph.java @@ -41,6 +41,8 @@ public class FlowGraph { Map mapMethodInvokeNodeToFlowReturnNode; + Map mapIntersectionDescToEnclosingDescriptor; + public static int interseed = 0; boolean debug = true; @@ -57,6 +59,7 @@ public class FlowGraph { this.mapFlowNodeToOutEdgeSet = new HashMap>(); this.mapFlowNodeToInEdgeSet = new HashMap>(); this.mapMethodInvokeNodeToFlowReturnNode = new HashMap(); + this.mapIntersectionDescToEnclosingDescriptor = new HashMap(); if (!md.isStatic()) { // create a node for 'this' varialbe @@ -74,6 +77,15 @@ public class FlowGraph { } + public void addMapInterLocNodeToEnclosingDescriptor(Descriptor interDesc, ClassDescriptor desc) { + System.out.println("##### INTERLOC=" + interDesc + " enclosing desc=" + desc); + mapIntersectionDescToEnclosingDescriptor.put(interDesc, desc); + } + + public ClassDescriptor getEnclosingDescriptor(Descriptor interDesc) { + return mapIntersectionDescToEnclosingDescriptor.get(interDesc); + } + public Map, FlowNode> getMapDescTupleToInferNode() { return mapDescTupleToInferNode; } @@ -306,7 +318,7 @@ public class FlowGraph { addOutEdge(fromNode, edge); addInEdge(toNode, edge); - // System.out.println("add a new edge=" + edge); + System.out.println("add a new edge=" + edge); } private void addInEdge(FlowNode toNode, FlowEdge edge) { @@ -338,6 +350,7 @@ public class FlowGraph { public FlowNode createNewFlowNode(NTuple tuple) { + // System.out.println("createNewFlowNode=" + tuple); if (!mapDescTupleToInferNode.containsKey(tuple)) { FlowNode node = new FlowNode(tuple); mapDescTupleToInferNode.put(tuple, node); @@ -388,7 +401,8 @@ public class FlowGraph { Set dstNodeSet = new HashSet(); if (originalDstNode instanceof FlowReturnNode) { FlowReturnNode rnode = (FlowReturnNode) originalDstNode; - Set> rtupleSet = rnode.getReturnTupleSet(); + Set> rtupleSetFromRNode = rnode.getReturnTupleSet(); + Set> rtupleSet = getReturnTupleSet(rtupleSetFromRNode); for (Iterator iterator2 = rtupleSet.iterator(); iterator2.hasNext();) { NTuple rtuple = (NTuple) iterator2.next(); dstNodeSet.add(getFlowNode(rtuple)); @@ -442,11 +456,13 @@ public class FlowGraph { Set srcNodeSet = new HashSet(); if (originalSrcNode instanceof FlowReturnNode) { FlowReturnNode rnode = (FlowReturnNode) originalSrcNode; - Set> rtupleSet = rnode.getReturnTupleSet(); + Set> rtupleSetFromRNode = rnode.getReturnTupleSet(); + Set> rtupleSet = getReturnTupleSet(rtupleSetFromRNode); + System.out.println("#rnode=" + rnode + " rtupleSet=" + rtupleSet); for (Iterator iterator2 = rtupleSet.iterator(); iterator2.hasNext();) { NTuple rtuple = (NTuple) iterator2.next(); if (rtuple.startsWith(prefix)) { - System.out.println("rtuple=" + rtuple + " give it to recur=" + originalSrcNode); + // System.out.println("rtuple=" + rtuple + " give it to recur=" + originalSrcNode); recurReachableSetFrom(originalSrcNode, reachableSet); } } @@ -461,6 +477,21 @@ public class FlowGraph { return reachableSet; } + public Set> getReturnTupleSet(Set> in) { + + Set> normalTupleSet = new HashSet>(); + for (Iterator iterator2 = in.iterator(); iterator2.hasNext();) { + NTuple tuple = (NTuple) iterator2.next(); + FlowNode tupleNode = getFlowNode(tuple); + if (tupleNode instanceof FlowReturnNode) { + normalTupleSet.addAll(getReturnTupleSet(((FlowReturnNode) tupleNode).getReturnTupleSet())); + } else { + normalTupleSet.add(tuple); + } + } + return normalTupleSet; + } + // private void getReachFlowNodeSetFrom(FlowNode fn, Set visited) { // // for (Iterator iterator = fn.getOutEdgeSet().iterator(); @@ -528,7 +559,7 @@ public class FlowGraph { Descriptor localDesc = fn.getDescTuple().get(0); - if (fn.isIntermediate()) { + if (fn.isIntermediate() && fn.getDescTuple().size() == 1) { Location interLoc = new Location(md, localDesc.getSymbol()); interLoc.setLocDescriptor(localDesc); locTuple.add(interLoc); @@ -550,6 +581,8 @@ public class FlowGraph { loc.setLocDescriptor(curDesc); if (curDesc instanceof VarDescriptor) { cd = ((VarDescriptor) curDesc).getType().getClassDesc(); + } else if (curDesc instanceof InterDescriptor) { + cd = mapIntersectionDescToEnclosingDescriptor.get(curDesc); } else { // otherwise it should be the last element cd = null; @@ -598,7 +631,8 @@ public class FlowGraph { if (incomingNode instanceof FlowReturnNode) { FlowReturnNode rnode = (FlowReturnNode) incomingNode; Set> nodeTupleSet = rnode.getReturnTupleSet(); - for (Iterator iterator3 = nodeTupleSet.iterator(); iterator3.hasNext();) { + Set> rtupleSet = getReturnTupleSet(nodeTupleSet); + for (Iterator iterator3 = rtupleSet.iterator(); iterator3.hasNext();) { NTuple nodeTuple = (NTuple) iterator3.next(); FlowNode fn = getFlowNode(nodeTuple); if (!visited.contains(fn)) {