private Map<HNode, TripleItem> mapSharedNodeToTripleItem;
private Map<HNode, Integer> mapHNodeToHighestIndex;
+ private Map<Pair<HNode, HNode>, Integer> mapItemToHighestIndex;
+
public BuildLattice(LocationInference infer) {
this.infer = infer;
this.mapSharedNodeToTripleItem = new HashMap<HNode, TripleItem>();
this.mapHNodeToHighestIndex = new HashMap<HNode, Integer>();
+ this.mapItemToHighestIndex = new HashMap<Pair<HNode, HNode>, Integer>();
+
}
public SSJavaLattice<String> buildLattice(Descriptor desc) {
HierarchyGraph inputGraph, LocationSummary locSummary,
Map<Set<Integer>, Set<Set<Integer>>> mapImSucc) {
- HierarchyGraph simpleHierarchyGraph = infer.getSimpleHierarchyGraph(desc);
-
SSJavaLattice<String> lattice =
new SSJavaLattice<String>(SSJavaAnalysis.TOP, SSJavaAnalysis.BOTTOM);
}
+ inputGraph.removeRedundantEdges();
return lattice;
}
// startNode = node;
// }
- Set<HNode> endNodeSetFromSimpleGraph =
- simpleGraph.getDirectlyReachableSkeletonCombinationNodeFrom(outNode, null);
+ // TODO
+ // Set<HNode> endNodeSetFromSimpleGraph =
+ // simpleGraph.getDirectlyReachableSkeletonCombinationNodeFrom(outNode, null);
+ // Set<HNode> endCombNodeSet = new HashSet<HNode>();
+ // for (Iterator iterator3 = endNodeSetFromSimpleGraph.iterator();
+ // iterator3.hasNext();) {
+ // HNode endNode = (HNode) iterator3.next();
+ // endCombNodeSet.add(getCombinationNodeInSCGraph(desc, endNode));
+ // }
+
+ Set<HNode> endCombNodeSet = scGraph.getOutgoingNodeSet(startNode);
- // System.out.println("endNodeSetFromSimpleGraph=" + endNodeSetFromSimpleGraph
- // + " from=" + outNode);
- Set<HNode> endCombNodeSet = new HashSet<HNode>();
- for (Iterator iterator3 = endNodeSetFromSimpleGraph.iterator(); iterator3.hasNext();) {
- HNode endNode = (HNode) iterator3.next();
- endCombNodeSet.add(getCombinationNodeInSCGraph(desc, endNode));
- }
// System.out.println("endCombNodeSet=" + endCombNodeSet);
visited.add(outNode);
if (endCombNodeSet.size() > 0) {
HNode sharedNode = (HNode) iterator.next();
TripleItem item = mapSharedNodeToTripleItem.get(sharedNode);
String nonSharedLocName = mapIntermediateLoc.get(item);
- // System.out.println("sharedNode=" + sharedNode + " locName=" + nonSharedLocName);
+
+ System.out.println("sharedNode=" + sharedNode + " locName=" + nonSharedLocName);
String newLocName;
if (locSummary.getHNodeNameSetByLatticeLoationName(nonSharedLocName) != null
Set<String> belowElementSet = new HashSet<String>();
belowElementSet.addAll(lattice.get(nonSharedLocName));
- // System.out.println("nonSharedLocName=" + nonSharedLocName + " belowElementSet="
- // + belowElementSet + " newLocName=" + newLocName);
+ System.out.println("nonSharedLocName=" + nonSharedLocName + " belowElementSet="
+ + belowElementSet + " newLocName=" + newLocName);
lattice.insertNewLocationBetween(nonSharedLocName, belowElementSet, newLocName);
} else {
}
HierarchyGraph simpleGraph = infer.getSimpleHierarchyGraph(desc);
+ HierarchyGraph scGraph = infer.getSkeletonCombinationHierarchyGraph(desc);
Set<HNode> combineSkeletonNodeSet = simpleGraph.getCombineSetByCombinationNode(cnode);
// System.out.println("combinationNodeSet=" + combinationNodeSet);
- Set<HNode> endNodeSetFromSimpleGraph =
- simpleGraph.getDirectlyReachableSkeletonCombinationNodeFrom(cnode, combinationNodeSet);
+ // TODO
+ // Set<HNode> endNodeSetFromSimpleGraph =
+ // simpleGraph.getDirectlyReachableSkeletonCombinationNodeFrom(cnode, combinationNodeSet);
// System.out.println("-endNodeSetFromSimpleGraph=" + endNodeSetFromSimpleGraph);
- Set<HNode> endCombNodeSet = new HashSet<HNode>();
- for (Iterator iterator3 = endNodeSetFromSimpleGraph.iterator(); iterator3.hasNext();) {
- HNode endNode = (HNode) iterator3.next();
- endCombNodeSet.add(getCombinationNodeInSCGraph(desc, endNode));
- }
+ // Set<HNode> endCombNodeSet = new HashSet<HNode>();
+ // for (Iterator iterator3 = endNodeSetFromSimpleGraph.iterator(); iterator3.hasNext();) {
+ // HNode endNode = (HNode) iterator3.next();
+ // endCombNodeSet.add(getCombinationNodeInSCGraph(desc, endNode));
+ // }
+
+ Set<HNode> endCombNodeSet = scGraph.getOutgoingNodeSet(combinationNodeInSCGraph);
visited.add(cnode);
// follows the straight line up to another skeleton/combination node
int idx, LocationSummary locSummary, HNode curNode) {
TripleItem item = new TripleItem(startNode, endNodeSet, idx);
- // System.out.println("item=" + item);
if (!mapIntermediateLoc.containsKey(item)) {
// need to create a new intermediate location in the lattice
String newLocName = "ILOC" + (LocationInference.locSeed++);
System.out.println("---incomingHNodeSetToOutNode=" + incomingHNodeSetToOutNode);
if (!outNode.isSkeleton() && !outNode.isCombinationNode() && !visited.contains(outNode)) {
+ Pair<HNode, HNode> pair = new Pair(startNode, outNode);
if (visited.containsAll(simpleHierarchyGraph.getIncomingNodeSet(outNode))) {
visited.add(outNode);
- int newidx = getCurrentHighestIndex(outNode, idx + 1);
+ int newidx = getCurrentHighestIndex(pair, idx + 1);
+ // int newidx = getCurrentHighestIndex(outNode, idx + 1);
recurDFSNormalNode(desc, lattice, startNode, endNodeSet, visited, mapIntermediateLoc,
newidx, locSummary, outNode);
// recurDFSNormalNode(desc, lattice, startNode, endNodeSet, visited, mapIntermediateLoc,
// idx + 1, locSummary, outNode);
} else {
- updateHighestIndex(outNode, idx + 1);
+ updateHighestIndex(pair, idx + 1);
+ // updateHighestIndex(outNode, idx + 1);
System.out.println("NOT RECUR");
}
} else if (!outNode.isSkeleton() && outNode.isCombinationNode() && !visited.contains(outNode)) {
// check whether the next combination node is different from the current node
if (combinationNodeInSCGraph.equals(getCombinationNodeInSCGraph(desc, outNode))) {
+ Pair<HNode, HNode> pair = new Pair(combinationNodeInSCGraph, outNode);
if (visited.containsAll(incomingCombinedHNodeSet)) {
visited.add(outNode);
System.out.println("-------curIdx=" + (idx + 1));
- int newIdx = getCurrentHighestIndex(outNode, idx + 1);
+
+ int newIdx = getCurrentHighestIndex(pair, idx + 1);
+ // int newIdx = getCurrentHighestIndex(outNode, idx + 1);
System.out.println("-------newIdx=" + newIdx);
recurDFS(desc, lattice, combinationNodeInSCGraph, endNodeSet, visited,
mapIntermediateLoc, newIdx, locSummary, outNode);
// recurDFS(desc, lattice, combinationNodeInSCGraph, endNodeSet, visited,
// mapIntermediateLoc, idx + 1, locSummary, outNode);
} else {
- updateHighestIndex(outNode, idx + 1);
+ updateHighestIndex(pair, idx + 1);
+ // updateHighestIndex(outNode, idx + 1);
System.out.println("-----NOT RECUR!");
}
} else {
}
+ private int getCurrentHighestIndex(Pair<HNode, HNode> pair, int curIdx) {
+ int recordedIdx = getCurrentHighestIndex(pair);
+ if (recordedIdx > curIdx) {
+ return recordedIdx;
+ } else {
+ return curIdx;
+ }
+ }
+
private int getCurrentHighestIndex(HNode node, int curIdx) {
int recordedIdx = getCurrentHighestIndex(node);
if (recordedIdx > curIdx) {
}
}
+ private int getCurrentHighestIndex(Pair<HNode, HNode> pair) {
+ if (!mapItemToHighestIndex.containsKey(pair)) {
+ mapItemToHighestIndex.put(pair, new Integer(-1));
+ }
+ return mapItemToHighestIndex.get(pair).intValue();
+ }
+
+ private void updateHighestIndex(Pair<HNode, HNode> pair, int idx) {
+ if (idx > getCurrentHighestIndex(pair)) {
+ mapItemToHighestIndex.put(pair, new Integer(idx));
+ }
+ }
+
private int getCurrentHighestIndex(HNode node) {
if (!mapHNodeToHighestIndex.containsKey(node)) {
mapHNodeToHighestIndex.put(node, new Integer(-1));