small cleanups

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@2893 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
sjfink 2008-06-18 21:06:24 +00:00
parent fd26dd0327
commit 60bff330b9
1 changed files with 19 additions and 38 deletions

View File

@ -36,7 +36,6 @@ import com.ibm.wala.util.collections.HashSetFactory;
import com.ibm.wala.util.collections.IntMapIterator; import com.ibm.wala.util.collections.IntMapIterator;
import com.ibm.wala.util.collections.SparseVector; import com.ibm.wala.util.collections.SparseVector;
import com.ibm.wala.util.debug.Assertions; import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.debug.Trace;
import com.ibm.wala.util.functions.IntFunction; import com.ibm.wala.util.functions.IntFunction;
import com.ibm.wala.util.graph.EdgeManager; import com.ibm.wala.util.graph.EdgeManager;
import com.ibm.wala.util.graph.NumberedEdgeManager; import com.ibm.wala.util.graph.NumberedEdgeManager;
@ -49,16 +48,12 @@ import com.ibm.wala.util.intset.MutableSharedBitVectorIntSet;
import com.ibm.wala.util.intset.SparseIntSet; import com.ibm.wala.util.intset.SparseIntSet;
/** /**
* A call graph which explicitly holds the target for each call site in each * A call graph which explicitly holds the target for each call site in each node.
* node.
*
* *
* @author sfink * @author sfink
*/ */
public class ExplicitCallGraph extends BasicCallGraph implements BytecodeConstants { public class ExplicitCallGraph extends BasicCallGraph implements BytecodeConstants {
private static final boolean DEBUG = false;
protected final IClassHierarchy cha; protected final IClassHierarchy cha;
protected final AnalysisOptions options; protected final AnalysisOptions options;
@ -107,27 +102,16 @@ public class ExplicitCallGraph extends BasicCallGraph implements BytecodeConstan
} }
/** /**
* Method findOrCreateNode.
*
* @param method
* @return NodeImpl
*/ */
@Override @Override
public CGNode findOrCreateNode(IMethod method, Context C) throws CancelException { public CGNode findOrCreateNode(IMethod method, Context C) throws CancelException {
if (Assertions.verifyAssertions) { assert method != null : "null method";
if (method == null || C == null) { assert C != null : "null context for method " + method;
Assertions._assert(method != null, "null method");
Assertions._assert(C != null, "null context for method " + method);
}
}
Key k = new Key(method, C); Key k = new Key(method, C);
NodeImpl result = getNode(k); NodeImpl result = getNode(k);
if (result == null) { if (result == null) {
if (maxNumberOfNodes == -1 || getNumberOfNodes() <= maxNumberOfNodes) { if (maxNumberOfNodes == -1 || getNumberOfNodes() <= maxNumberOfNodes) {
result = makeNode(method, C); result = makeNode(method, C);
if (DEBUG) {
Trace.println("Create node for " + method + "hash code " + method.hashCode());
}
registerNode(k, result); registerNode(k, result);
} else { } else {
throw CancelException.make("Too many nodes"); throw CancelException.make("Too many nodes");
@ -139,10 +123,8 @@ public class ExplicitCallGraph extends BasicCallGraph implements BytecodeConstan
public class ExplicitNode extends NodeImpl { public class ExplicitNode extends NodeImpl {
/** /**
* A Mapping from call site program counter (int) -> Object, where Object is * A Mapping from call site program counter (int) -> Object, where Object is a CGNode if we've discovered exactly
* a CGNode if we've discovered exactly one target for the site, or an * one target for the site, or an IntSet of node numbers if we've discovered more than one target for the site.
* IntSet of node numbers if we've discovered more than one target for the
* site.
*/ */
protected final SparseVector<Object> targets = new SparseVector<Object>(); protected final SparseVector<Object> targets = new SparseVector<Object>();
@ -198,7 +180,6 @@ public class ExplicitCallGraph extends BasicCallGraph implements BytecodeConstan
}); });
} }
protected int getNumberOfTargets(CallSiteReference site) { protected int getNumberOfTargets(CallSiteReference site) {
Object result = targets.get(site.getProgramCounter()); Object result = targets.get(site.getProgramCounter());
@ -350,8 +331,8 @@ public class ExplicitCallGraph extends BasicCallGraph implements BytecodeConstan
/** /**
* for each y, the {x | (x,y) is an edge) * for each y, the {x | (x,y) is an edge)
*/ */
final IBinaryNaturalRelation predecessors = new BasicNaturalRelation( final IBinaryNaturalRelation predecessors = new BasicNaturalRelation(new byte[] { BasicNaturalRelation.SIMPLE_SPACE_STINGY },
new byte[] { BasicNaturalRelation.SIMPLE_SPACE_STINGY }, BasicNaturalRelation.SIMPLE); BasicNaturalRelation.SIMPLE);
public IntSet getSuccNodeNumbers(CGNode node) { public IntSet getSuccNodeNumbers(CGNode node) {
ExplicitNode n = (ExplicitNode) node; ExplicitNode n = (ExplicitNode) node;