Added code to methods missing implementations.
Added a make method for a partial graph with a given set of roots and a given set of nodes. Added checks for containment of pred/succ nodes to get[Pred/Succ]NodeNumbers, which were missing the checks. Made getNode/getNumber methods return null/-1 for nodes not in partial graph (instead of throwing an exception). May reconsider this later. git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@1467 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
d602c65f6b
commit
cb4012d939
|
@ -35,6 +35,16 @@ public class PartialCallGraph extends DelegatingGraph<CGNode> implements CallGra
|
|||
this.partialRoots = partialRoots;
|
||||
}
|
||||
|
||||
public static PartialCallGraph make(final CallGraph CG, final Set<CGNode> partialRoots, final Collection<CGNode> nodes) {
|
||||
Graph<CGNode> partialGraph = GraphSlicer.prune(CG, new Filter() {
|
||||
public boolean accepts(Object o) {
|
||||
return nodes.contains(o);
|
||||
}
|
||||
});
|
||||
|
||||
return new PartialCallGraph(CG, partialRoots, partialGraph);
|
||||
}
|
||||
|
||||
public static PartialCallGraph make(CallGraph CG, Set<CGNode> partialRoots) {
|
||||
final Set<CGNode> nodes = DFS.getReachableNodes(CG, partialRoots);
|
||||
Graph<CGNode> partialGraph = GraphSlicer.prune(CG, new Filter() {
|
||||
|
@ -57,11 +67,7 @@ public class PartialCallGraph extends DelegatingGraph<CGNode> implements CallGra
|
|||
|
||||
public CGNode getNode(IMethod method, Context C) {
|
||||
CGNode x = cg.getNode(method, C);
|
||||
if (containsNode(x)) {
|
||||
return x;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return (containsNode(x) ? x : null);
|
||||
}
|
||||
|
||||
public Set<CGNode> getNodes(MethodReference m) {
|
||||
|
@ -98,20 +104,21 @@ public class PartialCallGraph extends DelegatingGraph<CGNode> implements CallGra
|
|||
|
||||
public CGNode getNode(int index) {
|
||||
CGNode n = cg.getNode(index);
|
||||
Assertions._assert(containsNode(n));
|
||||
return n;
|
||||
return (containsNode(n) ? n : null);
|
||||
}
|
||||
|
||||
public int getNumber(CGNode n) {
|
||||
Assertions._assert(containsNode(n));
|
||||
return cg.getNumber(n);
|
||||
return (containsNode(n) ? cg.getNumber(n) : -1);
|
||||
}
|
||||
|
||||
public IntSet getSuccNodeNumbers(CGNode node) {
|
||||
Assertions._assert(containsNode(node));
|
||||
MutableIntSet x = IntSetUtil.make();
|
||||
for (Iterator ns = getSuccNodes(node); ns.hasNext();) {
|
||||
x.add(getNumber((CGNode) ns.next()));
|
||||
CGNode succ = (CGNode) ns.next();
|
||||
if (containsNode(succ)) {
|
||||
x.add(getNumber(succ));
|
||||
}
|
||||
}
|
||||
|
||||
return x;
|
||||
|
@ -121,24 +128,35 @@ public class PartialCallGraph extends DelegatingGraph<CGNode> implements CallGra
|
|||
Assertions._assert(containsNode(node));
|
||||
MutableIntSet x = IntSetUtil.make();
|
||||
for (Iterator ns = getPredNodes(node); ns.hasNext();) {
|
||||
x.add(getNumber((CGNode) ns.next()));
|
||||
CGNode pred = (CGNode) ns.next();
|
||||
if (containsNode(pred)) {
|
||||
x.add(getNumber(pred));
|
||||
}
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getNumberOfTargets(CGNode node, CallSiteReference site) {
|
||||
Assertions.UNREACHABLE("TODO");
|
||||
return 0;
|
||||
return (containsNode(node) ? getPossibleTargets(node, site).size() : -1);
|
||||
}
|
||||
|
||||
public Iterator<CallSiteReference> getPossibleSites(CGNode src, CGNode target) {
|
||||
Assertions.UNREACHABLE("TODO");
|
||||
return null;
|
||||
return ((containsNode(src) && containsNode(target)) ? cg.getPossibleSites(src, target) : null);
|
||||
}
|
||||
|
||||
public Set<CGNode> getPossibleTargets(CGNode node, CallSiteReference site) {
|
||||
Assertions.UNREACHABLE("TODO");
|
||||
return null;
|
||||
if (!containsNode(node)) {
|
||||
return null;
|
||||
}
|
||||
Set<CGNode> result = HashSetFactory.make();
|
||||
for (Iterator ns = cg.getPossibleTargets(node, site).iterator(); ns.hasNext();) {
|
||||
CGNode target = (CGNode) ns.next();
|
||||
if (containsNode(target)) {
|
||||
result.add(target);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue