X-Git-Url: http://plrg.eecs.uci.edu/git/?p=IRC.git;a=blobdiff_plain;f=Robust%2Fsrc%2FAnalysis%2FSSJava%2FFlowGraph.java;h=2ab6dad9ce625cac5d96cda64b5d4f1f989c8b6a;hp=a2d1791bb8a698609a668910a803c9a742774a76;hb=9dfdca00acf795117136425841493a1b0f036f10;hpb=5b4d50ee3ad588d3c4a1406c26c1e602d04e5581 diff --git a/Robust/src/Analysis/SSJava/FlowGraph.java b/Robust/src/Analysis/SSJava/FlowGraph.java index a2d1791b..2ab6dad9 100644 --- a/Robust/src/Analysis/SSJava/FlowGraph.java +++ b/Robust/src/Analysis/SSJava/FlowGraph.java @@ -19,74 +19,157 @@ public class FlowGraph { MethodDescriptor md; - Set nodeSet; Set returnNodeSet; FlowNode thisVarNode; + Map> mapFlowNodeToInEdgeSet; + Map> mapFlowNodeToOutEdgeSet; + Map, FlowNode> mapLocTupleToFlowNode; Map> mapFlowNodeToLocTuple; // maps the composite representation of field/var descriptors to infer nodes Map, FlowNode> mapDescTupleToInferNode; - // maps an infer node to the set of neighbors which is pointed by the node - Map, Set> mapNodeToNeighborSet; - // maps a paramter descriptor to its index Map mapParamDescToIdx; + + // DS for the lattice generation + Map mapIdxToFlowNode; + + public static int interseed = 0; + boolean debug = true; public FlowGraph(MethodDescriptor md, Map mapParamDescToIdx) { this.md = md; this.mapFlowNodeToLocTuple = new HashMap>(); this.mapLocTupleToFlowNode = new HashMap, FlowNode>(); - this.nodeSet = new HashSet(); this.mapDescTupleToInferNode = new HashMap, FlowNode>(); - this.mapNodeToNeighborSet = new HashMap, Set>(); this.mapParamDescToIdx = new HashMap(); this.mapParamDescToIdx.putAll(mapParamDescToIdx); this.returnNodeSet = new HashSet(); + this.mapIdxToFlowNode = new HashMap(); + this.mapFlowNodeToOutEdgeSet = new HashMap>(); + this.mapFlowNodeToInEdgeSet = new HashMap>(); if (!md.isStatic()) { // create a node for 'this' varialbe - NTuple thisDescTuple = new NTuple(); - thisDescTuple.add(md.getThis()); - FlowNode thisNode = new FlowNode(thisDescTuple, true); + // NTuple thisDescTuple = new NTuple(); + // thisDescTuple.add(md.getThis()); + NTuple thisVarTuple = new NTuple(); thisVarTuple.add(md.getThis()); - createNewFlowNode(thisVarTuple); + FlowNode thisNode = createNewFlowNode(thisVarTuple); + thisNode.setSkeleton(true); thisVarNode = thisNode; } + setupMapIdxToDesc(); + } - public Set getNodeSet() { - return nodeSet; + public Map, FlowNode> getMapDescTupleToInferNode() { + return mapDescTupleToInferNode; } - public MethodDescriptor getMethodDescriptor() { - return md; + public void setMapDescTupleToInferNode(Map, FlowNode> in) { + this.mapDescTupleToInferNode.putAll(in); } - public Set getParameterNodeSet() { - Set paramNodeSet = new HashSet(); + public Map, FlowNode> getMapLocTupleToFlowNode() { + return mapLocTupleToFlowNode; + } + + public void setMapLocTupleToFlowNode(Map, FlowNode> in) { + this.mapLocTupleToFlowNode.putAll(in); + } + + public void setReturnNodeSet(Set in) { + this.returnNodeSet.addAll(in); + } + + public void setThisVarNode(FlowNode thisVarNode) { + this.thisVarNode = thisVarNode; + } + + public Map getMapParamDescToIdx() { + return mapParamDescToIdx; + } + + public FlowNode createIntermediateNode() { + NTuple tuple = new NTuple(); + Descriptor interDesc = new InterDescriptor(LocationInference.INTERLOC + interseed); + tuple.add(interDesc); + interseed++; + + FlowNode newNode = new FlowNode(tuple); + newNode.setIntermediate(true); + + mapDescTupleToInferNode.put(tuple, newNode); + // nodeSet.add(newNode); + + System.out.println("create new intermediate node= " + newNode); + + return newNode; + } + + private void setupMapIdxToDesc() { + + Set descSet = mapParamDescToIdx.keySet(); + for (Iterator iterator = descSet.iterator(); iterator.hasNext();) { + Descriptor paramDesc = (Descriptor) iterator.next(); + int idx = mapParamDescToIdx.get(paramDesc); + NTuple descTuple = new NTuple(); + descTuple.add(paramDesc); + FlowNode paramNode = getFlowNode(descTuple); + mapIdxToFlowNode.put(idx, paramNode); + paramNode.setSkeleton(true); + } + + } + + public int getNumParameters() { + return mapIdxToFlowNode.keySet().size(); + } + + public FlowNode getParamFlowNode(int idx) { + return mapIdxToFlowNode.get(idx); + } + + public Set getEdgeSet() { + Set edgeSet = new HashSet(); + + Set nodeSet = getNodeSet(); for (Iterator iterator = nodeSet.iterator(); iterator.hasNext();) { - FlowNode fn = (FlowNode) iterator.next(); - if (fn.isParameter()) { - paramNodeSet.add(fn); - } + FlowNode flowNode = (FlowNode) iterator.next(); + edgeSet.addAll(getOutEdgeSet(flowNode)); } - return paramNodeSet; + + return edgeSet; } - public void addNeighbor(FlowNode node, FlowNode neighbor) { - Set set = mapNodeToNeighborSet.get(node); - if (set == null) { - set = new HashSet(); + public Set getNodeSet() { + Set set = new HashSet(); + set.addAll(mapDescTupleToInferNode.values()); + return set; + } + + public MethodDescriptor getMethodDescriptor() { + return md; + } + + public boolean isParamDesc(Descriptor desc) { + + if (mapParamDescToIdx.containsKey(desc)) { + int idx = mapParamDescToIdx.get(desc); + if (!md.isStatic() && idx == 0) { + return false; + } + return true; } - set.add(neighbor); - System.out.println("add a new neighbor " + neighbor + " to " + node); + return false; } public boolean hasEdge(NTuple fromDescTuple, NTuple toDescTuple) { @@ -94,7 +177,7 @@ public class FlowGraph { FlowNode fromNode = mapDescTupleToInferNode.get(fromDescTuple); FlowNode toNode = mapDescTupleToInferNode.get(toDescTuple); - Set fromNodeOutEdgeSet = fromNode.getOutEdgeSet(); + Set fromNodeOutEdgeSet = getOutEdgeSet(fromNode); for (Iterator iterator = fromNodeOutEdgeSet.iterator(); iterator.hasNext();) { FlowEdge flowEdge = (FlowEdge) iterator.next(); if (flowEdge.getDst().equals(toNode)) { @@ -109,28 +192,80 @@ public class FlowGraph { return false; } + public Set getOutEdgeSetStartingFrom(FlowNode startNode) { + + Descriptor prefixDesc = startNode.getCurrentDescTuple().get(0); + + // returns the set of edges that share the same prefix of startNode + Set edgeSet = new HashSet(); + + for (Iterator> iter = mapFlowNodeToOutEdgeSet.values().iterator(); iter.hasNext();) { + Set nodeEdgeSet = iter.next(); + for (Iterator iter2 = nodeEdgeSet.iterator(); iter2.hasNext();) { + FlowEdge edge = iter2.next(); + if (edge.getInitTuple().get(0).equals(prefixDesc)) { + edgeSet.add(edge); + } + } + } + + return edgeSet; + } + + public Set getOutEdgeSet(FlowNode node) { + if (!mapFlowNodeToOutEdgeSet.containsKey(node)) { + mapFlowNodeToOutEdgeSet.put(node, new HashSet()); + } + return mapFlowNodeToOutEdgeSet.get(node); + } + + public Set getInEdgeSet(FlowNode node) { + if (!mapFlowNodeToInEdgeSet.containsKey(node)) { + mapFlowNodeToInEdgeSet.put(node, new HashSet()); + } + return mapFlowNodeToInEdgeSet.get(node); + } + public void addValueFlowEdge(NTuple fromDescTuple, NTuple toDescTuple) { - FlowNode fromNode = mapDescTupleToInferNode.get(fromDescTuple); - FlowNode toNode = mapDescTupleToInferNode.get(toDescTuple); + FlowNode fromNode = getFlowNode(fromDescTuple); + FlowNode toNode = getFlowNode(toDescTuple); + + if (toNode.getDescTuple().get(0).equals(LocationInference.LITERALDESC)) { + return; + } System.out.println("create an edge from " + fromNode + " to " + toNode); int fromTupleSize = fromDescTuple.size(); - NTuple curTuple = new NTuple(); + NTuple curFromTuple = new NTuple(); for (int i = 0; i < fromTupleSize; i++) { Descriptor desc = fromDescTuple.get(i); - curTuple.add(desc); - addFlowEdge(getFlowNode(curTuple), toNode, fromDescTuple, toDescTuple); + curFromTuple.add(desc); + int toTupleSize = toDescTuple.size(); + NTuple curToTuple = new NTuple(); + for (int k = 0; k < toTupleSize; k++) { + Descriptor toDesc = toDescTuple.get(k); + curToTuple.add(toDesc); + addFlowEdge(getFlowNode(curFromTuple), getFlowNode(curToTuple), fromDescTuple, toDescTuple); + } } - int toTupleSize = toDescTuple.size(); - curTuple = new NTuple(); - for (int i = 0; i < toTupleSize; i++) { - Descriptor desc = toDescTuple.get(i); - curTuple.add(desc); - addFlowEdge(fromNode, getFlowNode(curTuple), fromDescTuple, toDescTuple); - } + // int fromTupleSize = fromDescTuple.size(); + // NTuple curTuple = new NTuple(); + // for (int i = 0; i < fromTupleSize; i++) { + // Descriptor desc = fromDescTuple.get(i); + // curTuple.add(desc); + // addFlowEdge(getFlowNode(curTuple), toNode, fromDescTuple, toDescTuple); + // } + // + // int toTupleSize = toDescTuple.size(); + // curTuple = new NTuple(); + // for (int i = 0; i < toTupleSize; i++) { + // Descriptor desc = toDescTuple.get(i); + // curTuple.add(desc); + // addFlowEdge(fromNode, getFlowNode(curTuple), fromDescTuple, toDescTuple); + // } } @@ -138,19 +273,33 @@ public class FlowGraph { NTuple endTuple) { FlowEdge edge = new FlowEdge(fromNode, toNode, initTuple, endTuple); - fromNode.addOutEdge(edge); + addOutEdge(fromNode, edge); + addInEdge(toNode, edge); + + // System.out.println("add a new edge=" + edge); + } + + private void addInEdge(FlowNode toNode, FlowEdge edge) { + getInEdgeSet(toNode).add(edge); + } - System.out.println("add a new edge=" + edge); + private void addOutEdge(FlowNode fromNode, FlowEdge edge) { + if (!mapFlowNodeToOutEdgeSet.containsKey(fromNode)) { + mapFlowNodeToOutEdgeSet.put(fromNode, new HashSet()); + } + mapFlowNodeToOutEdgeSet.get(fromNode).add(edge); + } + public boolean contains(NTuple descTuple) { + return mapDescTupleToInferNode.containsKey(descTuple); } public FlowNode getFlowNode(NTuple descTuple) { - if (mapDescTupleToInferNode.containsKey(descTuple)) { - return mapDescTupleToInferNode.get(descTuple); - } else { + if (!mapDescTupleToInferNode.containsKey(descTuple)) { FlowNode node = createNewFlowNode(descTuple); - return node; + mapDescTupleToInferNode.put(descTuple, node); } + return mapDescTupleToInferNode.get(descTuple); } public FlowNode getThisVarNode() { @@ -160,10 +309,9 @@ public class FlowGraph { public FlowNode createNewFlowNode(NTuple tuple) { if (!mapDescTupleToInferNode.containsKey(tuple)) { - - FlowNode node = new FlowNode(tuple, isParamter(tuple)); + FlowNode node = new FlowNode(tuple); mapDescTupleToInferNode.put(tuple, node); - nodeSet.add(node); + // nodeSet.add(node); mapLocTupleToFlowNode.put(getLocationTuple(node), node); @@ -172,7 +320,7 @@ public class FlowGraph { getFlowNode(baseTuple).addFieldNode(node); } - System.out.println("Creating new node=" + node); + // System.out.println("Creating new node=" + node); return node; } else { return mapDescTupleToInferNode.get(tuple); @@ -180,15 +328,13 @@ public class FlowGraph { } - public void setReturnFlowNode(NTuple tuple) { + public void addReturnFlowNode(NTuple tuple) { if (!mapDescTupleToInferNode.containsKey(tuple)) { createNewFlowNode(tuple); } FlowNode node = mapDescTupleToInferNode.get(tuple); - node.setReturn(true); - returnNodeSet.add(node); } @@ -196,32 +342,102 @@ public class FlowGraph { return returnNodeSet; } - public Set getReachableFlowNodeSet(FlowNode fn) { + public Set getLocalReachFlowNodeSetFrom(FlowNode fn) { Set set = new HashSet(); - getReachableFlowNodeSet(fn, set); + recurLocalReachFlowNodeSet(fn, set); return set; } - private void getReachableFlowNodeSet(FlowNode fn, Set visited) { + private void recurLocalReachFlowNodeSet(FlowNode fn, Set visited) { - for (Iterator iterator = fn.getOutEdgeSet().iterator(); iterator.hasNext();) { + Set outEdgeSet = getOutEdgeSet(fn); + for (Iterator iterator = outEdgeSet.iterator(); iterator.hasNext();) { FlowEdge edge = (FlowEdge) iterator.next(); + FlowNode dstNode = edge.getDst(); - if (fn.equals(getFlowNode(edge.getInitTuple()))) { + if (!visited.contains(dstNode)) { + visited.add(dstNode); + recurLocalReachFlowNodeSet(dstNode, visited); + } + } - FlowNode dstNode = getFlowNode(edge.getEndTuple()); + } + + private void getReachFlowNodeSetFrom(FlowNode fn, Set visited) { + Set outEdgeSet = getOutEdgeSet(fn); + for (Iterator iterator = outEdgeSet.iterator(); iterator.hasNext();) { + FlowEdge edge = (FlowEdge) iterator.next(); + + if (fn.equals(getFlowNode(edge.getInitTuple()))) { + FlowNode dstNode = getFlowNode(edge.getEndTuple()); if (!visited.contains(dstNode)) { visited.add(dstNode); - getReachableFlowNodeSet(dstNode, visited); + getReachFlowNodeSetFrom(dstNode, visited); } } } } + public Set getReachFlowNodeSetFrom(FlowNode fn) { + Set set = new HashSet(); + getReachFlowNodeSetFrom(fn, set); + return set; + } + + public Set getReachableSetFrom(NTuple prefix) { + Set reachableSet = new HashSet(); + + Set nodeSet = getNodeSet(); + for (Iterator iterator = nodeSet.iterator(); iterator.hasNext();) { + FlowNode flowNode = (FlowNode) iterator.next(); + if (flowNode.getCurrentDescTuple().startsWith(prefix)) { + recurReachableSetFrom(flowNode, reachableSet); + } + } + + return reachableSet; + } + + // private void getReachFlowNodeSetFrom(FlowNode fn, Set visited) { + // + // for (Iterator iterator = fn.getOutEdgeSet().iterator(); + // iterator.hasNext();) { + // FlowEdge edge = (FlowEdge) iterator.next(); + // + // if (fn.equals(getFlowNode(edge.getInitTuple()))) { + // + // FlowNode dstNode = getFlowNode(edge.getEndTuple()); + // + // if (!visited.contains(dstNode)) { + // visited.add(dstNode); + // getReachFlowNodeSetFrom(dstNode, visited); + // } + // } + // } + // + // } + + private void recurReachableSetFrom(FlowNode curNode, Set reachableSet) { + + Set edgeSet = getOutEdgeSet(curNode); + for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) { + FlowEdge edge = (FlowEdge) iterator.next(); + FlowNode dstNode = getFlowNode(edge.getEndTuple()); + if (!reachableSet.contains(dstNode)) { + reachableSet.add(dstNode); + recurReachableSetFrom(dstNode, reachableSet); + } + } + + } + public Set> getReachableFlowTupleSet(Set> visited, FlowNode fn) { - for (Iterator iterator = fn.getOutEdgeSet().iterator(); iterator.hasNext();) { + + Set outEdgeSet = getOutEdgeSet(fn); + + for (Iterator iterator = outEdgeSet.iterator(); iterator.hasNext();) { FlowEdge edge = (FlowEdge) iterator.next(); if (fn.getDescTuple().equals(edge.getInitTuple())) { @@ -238,6 +454,10 @@ public class FlowGraph { return visited; } + public NTuple getLocationTuple(NTuple descTuple) { + return getLocationTuple(getFlowNode(descTuple)); + } + public NTuple getLocationTuple(FlowNode fn) { if (!mapFlowNodeToLocTuple.containsKey(fn)) { @@ -245,20 +465,52 @@ public class FlowGraph { NTuple locTuple = new NTuple(); ClassDescriptor cd = null; - for (int i = 0; i < descTuple.size(); i++) { - Descriptor curDesc = descTuple.get(i); - Location loc; - if (i == 0) { - loc = new Location(md, curDesc.getSymbol()); - loc.setLocDescriptor(md); - cd = ((VarDescriptor) curDesc).getType().getClassDesc(); - } else { - loc = new Location(cd, curDesc.getSymbol()); - loc.setLocDescriptor(curDesc); - cd = ((FieldDescriptor) curDesc).getType().getClassDesc(); + Descriptor localDesc = fn.getDescTuple().get(0); + + if (fn.isIntermediate()) { + Location interLoc = new Location(md, localDesc.getSymbol()); + interLoc.setLocDescriptor(localDesc); + locTuple.add(interLoc); + } else if (localDesc.getSymbol().equals(SSJavaAnalysis.TOP)) { + Location topLoc = new Location(md, Location.TOP); + topLoc.setLocDescriptor(LocationInference.TOPDESC); + locTuple.add(topLoc); + } else if (localDesc.getSymbol().equals(LocationInference.GLOBALLOC)) { + Location globalLoc = new Location(md, LocationInference.GLOBALLOC); + globalLoc.setLocDescriptor(LocationInference.GLOBALDESC); + locTuple.add(globalLoc); + } else { + // normal case + for (int i = 0; i < descTuple.size(); i++) { + Descriptor curDesc = descTuple.get(i); + Location loc; + if (i == 0) { + loc = new Location(md, curDesc.getSymbol()); + loc.setLocDescriptor(curDesc); + if (curDesc instanceof VarDescriptor) { + cd = ((VarDescriptor) curDesc).getType().getClassDesc(); + } else { + // otherwise it should be the last element + cd = null; + } + } else { + loc = new Location(cd, curDesc.getSymbol()); + loc.setLocDescriptor(curDesc); + + if (curDesc instanceof FieldDescriptor) { + cd = ((FieldDescriptor) curDesc).getType().getClassDesc(); + } else if (curDesc instanceof LocationDescriptor) { + cd = ((LocationDescriptor) curDesc).getEnclosingClassDesc(); + } else { + // otherwise it should be the last element of the tuple + cd = null; + } + + } + locTuple.add(loc); } - locTuple.add(loc); } + mapFlowNodeToLocTuple.put(fn, locTuple); } return mapFlowNodeToLocTuple.get(fn); @@ -272,9 +524,9 @@ public class FlowGraph { public void getIncomingFlowNodeSet(FlowNode node, Set visited) { - for (Iterator iterator = nodeSet.iterator(); iterator.hasNext();) { + for (Iterator iterator = getNodeSet().iterator(); iterator.hasNext();) { FlowNode curNode = (FlowNode) iterator.next(); - Set edgeSet = curNode.getOutEdgeSet(); + Set edgeSet = getOutEdgeSet(curNode); for (Iterator iterator2 = edgeSet.iterator(); iterator2.hasNext();) { FlowEdge flowEdge = (FlowEdge) iterator2.next(); @@ -300,9 +552,10 @@ public class FlowGraph { ClassDescriptor cd = null; - for (Iterator iterator = nodeSet.iterator(); iterator.hasNext();) { + for (Iterator iterator = getNodeSet().iterator(); iterator.hasNext();) { FlowNode node = (FlowNode) iterator.next(); - Set edgeSet = node.getOutEdgeSet(); + + Set edgeSet = getOutEdgeSet(node); for (Iterator iterator2 = edgeSet.iterator(); iterator2.hasNext();) { FlowEdge flowEdge = (FlowEdge) iterator2.next(); if (dstTuple.equals(flowEdge.getEndTuple())) { @@ -327,21 +580,98 @@ public class FlowGraph { return set; } - public boolean isParamter(NTuple tuple) { + public boolean isParameter(NTuple tuple) { // return true if a descriptor tuple is started with a parameter descriptor Descriptor firstIdxDesc = tuple.get(0); return mapParamDescToIdx.containsKey(firstIdxDesc); } public int getParamIdx(NTuple tuple) { - Descriptor firstDesc = tuple.get(0); - return mapParamDescToIdx.get(firstDesc).intValue(); + Descriptor firstIdxDesc = tuple.get(0); + return mapParamDescToIdx.get(firstIdxDesc); + } + + public FlowGraph clone() { + FlowGraph clone = new FlowGraph(md, mapParamDescToIdx); + + // clone.setNodeSet(getNodeSet()); + clone.setMapLocTupleToFlowNode(getMapLocTupleToFlowNode()); + clone.setMapFlowNodeToLocTuple(getMapFlowNodeToLocTuple()); + clone.setMapDescTupleToInferNode(getMapDescTupleToInferNode()); + + clone.setMapFlowNodeToOutEdgeSet(getMapFlowNodeToOutEdgeSet()); + clone.setReturnNodeSet(getReturnNodeSet()); + clone.setThisVarNode(getThisVarNode()); + + return clone; + } + + public Map> getMapFlowNodeToLocTuple() { + return mapFlowNodeToLocTuple; + } + + public void setMapFlowNodeToLocTuple(Map> in) { + this.mapFlowNodeToLocTuple.putAll(in); + } + + public Map> getMapFlowNodeToOutEdgeSet() { + return mapFlowNodeToOutEdgeSet; + } + + public Set getIncomingNodeSetByPrefix(Descriptor prefix) { + + Set incomingNodeSet = new HashSet(); + + for (Iterator iterator = getNodeSet().iterator(); iterator.hasNext();) { + FlowNode curNode = (FlowNode) iterator.next(); + Set outEdgeSet = getOutEdgeSet(curNode); + + for (Iterator iterator2 = outEdgeSet.iterator(); iterator2.hasNext();) { + FlowEdge outEdge = (FlowEdge) iterator2.next(); + + if (outEdge.getEndTuple().startsWith(prefix)) { + incomingNodeSet.add(curNode); + recurIncomingNodeSetByPrefix(prefix, curNode, incomingNodeSet); + + } + + } + } + + return incomingNodeSet; + + } + + private void recurIncomingNodeSetByPrefix(Descriptor prefix, FlowNode node, Set visited) { + + Set inEdgeSet = getInEdgeSet(node); + + for (Iterator iterator = inEdgeSet.iterator(); iterator.hasNext();) { + FlowEdge inEdge = (FlowEdge) iterator.next(); + + FlowNode inNode = getFlowNode(inEdge.getInitTuple()); + if (!inEdge.getInitTuple().startsWith(prefix) && !visited.contains(inNode)) { + visited.add(inNode); + recurIncomingNodeSetByPrefix(prefix, inNode, visited); + } + } + + } + + public void setMapFlowNodeToOutEdgeSet(Map> inMap) { + Set keySet = inMap.keySet(); + for (Iterator iterator = keySet.iterator(); iterator.hasNext();) { + FlowNode key = (FlowNode) iterator.next(); + Set newEdgeSet = new HashSet(); + newEdgeSet.addAll(inMap.get(key)); + mapFlowNodeToOutEdgeSet.put(key, newEdgeSet); + } } private void drawEdges(FlowNode node, BufferedWriter bw, Set addedNodeSet, Set addedEdgeSet) throws IOException { - Set edgeSet = node.getOutEdgeSet(); + Set edgeSet = getOutEdgeSet(node); for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) { FlowEdge flowEdge = iterator.next(); @@ -378,8 +708,12 @@ public class FlowGraph { } public void writeGraph() throws java.io.IOException { + writeGraph(""); + } - String graphName = "flowgraph_" + md.toString(); + public void writeGraph(String suffix) throws java.io.IOException { + + String graphName = "flowgraph_" + md.toString() + suffix; graphName = graphName.replaceAll("[\\W]", ""); BufferedWriter bw = new BufferedWriter(new FileWriter(graphName + ".dot")); @@ -388,7 +722,8 @@ public class FlowGraph { // then visit every flow node - Iterator iter = nodeSet.iterator(); + // Iterator iter = nodeSet.iterator(); + Iterator iter = getNodeSet().iterator(); Set addedEdgeSet = new HashSet(); Set addedNodeSet = new HashSet(); @@ -412,7 +747,7 @@ public class FlowGraph { } public boolean constainsNode(FlowNode node) { - return nodeSet.contains(node); + return getNodeSet().contains(node); } private void drawSubgraph(FlowNode node, BufferedWriter bw, Set addedSet) @@ -444,4 +779,5 @@ public class FlowGraph { bw.write("}\n"); } + } \ No newline at end of file