a small optimization to eager construction; implement a few more methods

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@2378 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
sjfink 2008-01-11 20:19:09 +00:00
parent 0daaa48d6a
commit b9f03da7f6
1 changed files with 20 additions and 10 deletions

View File

@ -114,6 +114,11 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
private final ModRef modRef;
/**
* Have we eagerly populated all nodes of this SDG?
*/
private boolean eagerComputed = false;
public SDG(final CallGraph cg, PointerAnalysis pa, DataDependenceOptions dOptions, ControlDependenceOptions cOptions) {
this(cg, pa, ModRef.make(), dOptions, cOptions, null);
}
@ -156,11 +161,14 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
*/
private void eagerConstruction() {
// Assertions.UNREACHABLE();
if (!eagerComputed) {
eagerComputed = true;
computeAllPDGs();
for (PDG pdg : pdgMap.values()) {
addPDGStatementNodes(pdg.getCallGraphNode());
}
}
}
private void addPDGStatementNodes(CGNode node) {
if (!statementsAdded.contains(node)) {
@ -194,7 +202,8 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
@Override
public boolean containsNode(Statement N) {
Assertions.UNREACHABLE();
// this may be bad. Are you sure you want to call this?
eagerConstruction();
return super.containsNode(N);
}
@ -207,7 +216,8 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
@Override
public Statement getNode(int number) {
Assertions.UNREACHABLE();
// this may be bad. Are you sure you want to call this?
eagerConstruction();
return super.getNode(number);
}