private LocationInference infer;
- private final HNode topNode;
- private final HNode bottomNode;
-
public BuildLattice(LocationInference infer) {
this.infer = infer;
- topNode = new HNode(infer.ssjava.TOP);
- bottomNode = new HNode(infer.ssjava.BOTTOM);
}
public SSJavaLattice<String> buildLattice(Descriptor desc) {
for (Iterator iterator = nodeSet.iterator(); iterator.hasNext();) {
HNode node = (HNode) iterator.next();
System.out.println("node=" + node);
+
if (node.isSkeleton() && (!visited.contains(node))) {
visited.add(node);
} else if (endCombNodeSet.size() == 0) {
// the outNode is (directly/transitively) connected to the bottom node
// therefore, we just add a dummy bottom HNode to the endCombNodeSet.
- endCombNodeSet.add(bottomNode);
+ endCombNodeSet.add(LocationInference.BOTTOMHNODE);
}
-
recurDFSNormalNode(desc, lattice, startNode, endCombNodeSet, visited,
mapIntermediateLoc, 1, locSummary, outNode);
}
System.out.println("n=" + node);
// an intermediate node 'node' may be located between "TOP" location and a skeleton node
- int sizeIncomingNode = simpleGraph.getIncomingNodeSet(node).size();
+ if (simpleGraph.getIncomingNodeSet(node).size() == 0) {
- if (sizeIncomingNode == 0) {
// this node will be directly connected to the TOP location
// start adding the following nodes from this node
endCombNodeSet.add(getCombinationNodeInSCGraph(desc, endNode));
}
- HNode startNode = topNode;
+ System.out.println("endCombNodeSet=" + endCombNodeSet);
+ HNode startNode = LocationInference.TOPHNODE;
visited.add(startNode);
if (endCombNodeSet.size() > 0) {
// follows the straight line up to another skeleton/combination node
Set<HNode> visited, Map<TripleItem, String> mapIntermediateLoc, LocationSummary locSummary,
HNode cnode) {
+ System.out.println("expandCombinationNode=" + cnode);
// expand the combination node 'outNode'
// here we need to expand the corresponding combination location in the lattice
HNode combinationNodeInSCGraph = getCombinationNodeInSCGraph(desc, cnode);
endCombNodeSet =
removeTransitivelyReachToNode(desc, combinationNodeInSCGraph, endCombNodeSet);
-
recurDFS(desc, lattice, combinationNodeInSCGraph, endCombNodeSet, visited,
mapIntermediateLoc, 1, locSummary, cnode);
} else {
- endCombNodeSet.add(bottomNode);
- System.out.println("---endCombNodeSet is zero");
- System.out.println("---endNodeSetFromSimpleGraph=" + endNodeSetFromSimpleGraph);
- System.out.println("---incoming=" + simpleGraph.getIncomingNodeSet(cnode));
+ endCombNodeSet.add(LocationInference.BOTTOMHNODE);
+ // System.out.println("---endCombNodeSet is zero");
+ // System.out.println("---endNodeSetFromSimpleGraph=" + endNodeSetFromSimpleGraph);
+ // System.out.println("---incoming=" + simpleGraph.getIncomingNodeSet(cnode));
recurDFS(desc, lattice, combinationNodeInSCGraph, endCombNodeSet, visited,
mapIntermediateLoc, 1, locSummary, cnode);
Set<String> belowSet = new HashSet<String>();
for (Iterator iterator = endNodeSet.iterator(); iterator.hasNext();) {
HNode endNode = (HNode) iterator.next();
- belowSet.add(endNode.getName());
+ String locName;
+ if (locSummary.getMapHNodeNameToLocationName().containsKey(endNode.getName())) {
+ locName = locSummary.getLocationName(endNode.getName());
+ } else {
+ locName = endNode.getName();
+ }
+ belowSet.add(locName);
}
-
lattice.insertNewLocationBetween(above, belowSet, newLocName);
mapIntermediateLoc.put(item, newLocName);
}
locSummary.addMapHNodeNameToLocationName(curNode.getName(), locName);
- // System.out.println("-TripleItem=" + item);
- // System.out.println("-curNode=" + curNode.getName() + " locName=" + locName);
+ if (curNode.isSharedNode()) {
+ lattice.addSharedLoc(locName);
+ }
+ System.out.println("-TripleItem=" + item);
+ System.out.println("-curNode=" + curNode.getName() + " S=" + curNode.isSharedNode()
+ + " locName=" + locName);
Set<HNode> outSet = graph.getOutgoingNodeSet(curNode);
for (Iterator iterator2 = outSet.iterator(); iterator2.hasNext();) {
HNode outNode = (HNode) iterator2.next();
+ // System.out.println("recurDFS outNode=" + outNode);
+ // System.out.println("---cur combinationNodeInSCGraph=" + combinationNodeInSCGraph);
+ // System.out.println("---outNode combinationNodeInSCGraph="
+ // + getCombinationNodeInSCGraph(desc, outNode));
if (!outNode.isSkeleton() && !visited.contains(outNode)) {
- if (combinationNodeInSCGraph.equals(getCombinationNodeInSCGraph(desc, outNode))) {
- visited.add(outNode);
- recurDFS(desc, lattice, combinationNodeInSCGraph, endNodeSet, visited,
- mapIntermediateLoc, idx + 1, locSummary, outNode);
+ if (outNode.isCombinationNode()) {
+ // check whether the next combination node is different from the current node
+ if (combinationNodeInSCGraph.equals(getCombinationNodeInSCGraph(desc, outNode))) {
+ visited.add(outNode);
+ recurDFS(desc, lattice, combinationNodeInSCGraph, endNodeSet, visited,
+ mapIntermediateLoc, idx + 1, locSummary, outNode);
+ } else {
+ expandCombinationNode(desc, lattice, visited, mapIntermediateLoc, locSummary, outNode);
+ }
}
+
}
}