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:
parent
0daaa48d6a
commit
b9f03da7f6
|
@ -114,6 +114,11 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
|
||||||
|
|
||||||
private final ModRef modRef;
|
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) {
|
public SDG(final CallGraph cg, PointerAnalysis pa, DataDependenceOptions dOptions, ControlDependenceOptions cOptions) {
|
||||||
this(cg, pa, ModRef.make(), dOptions, cOptions, null);
|
this(cg, pa, ModRef.make(), dOptions, cOptions, null);
|
||||||
}
|
}
|
||||||
|
@ -156,11 +161,14 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
|
||||||
*/
|
*/
|
||||||
private void eagerConstruction() {
|
private void eagerConstruction() {
|
||||||
// Assertions.UNREACHABLE();
|
// Assertions.UNREACHABLE();
|
||||||
|
if (!eagerComputed) {
|
||||||
|
eagerComputed = true;
|
||||||
computeAllPDGs();
|
computeAllPDGs();
|
||||||
for (PDG pdg : pdgMap.values()) {
|
for (PDG pdg : pdgMap.values()) {
|
||||||
addPDGStatementNodes(pdg.getCallGraphNode());
|
addPDGStatementNodes(pdg.getCallGraphNode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void addPDGStatementNodes(CGNode node) {
|
private void addPDGStatementNodes(CGNode node) {
|
||||||
if (!statementsAdded.contains(node)) {
|
if (!statementsAdded.contains(node)) {
|
||||||
|
@ -194,7 +202,8 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean containsNode(Statement N) {
|
public boolean containsNode(Statement N) {
|
||||||
Assertions.UNREACHABLE();
|
// this may be bad. Are you sure you want to call this?
|
||||||
|
eagerConstruction();
|
||||||
return super.containsNode(N);
|
return super.containsNode(N);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +216,8 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Statement getNode(int number) {
|
public Statement getNode(int number) {
|
||||||
Assertions.UNREACHABLE();
|
// this may be bad. Are you sure you want to call this?
|
||||||
|
eagerConstruction();
|
||||||
return super.getNode(number);
|
return super.getNode(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue