misc. cleanups to check for illegal parameters
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@1691 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
1bb1c1e394
commit
a35a3e05fd
|
@ -30,7 +30,10 @@ public class BooleanIdentity extends UnaryOperator {
|
|||
}
|
||||
|
||||
@Override
|
||||
public byte evaluate(IVariable lhs, IVariable rhs) {
|
||||
public byte evaluate(IVariable lhs, IVariable rhs) throws IllegalArgumentException {
|
||||
if (lhs == null) {
|
||||
throw new IllegalArgumentException("lhs == null");
|
||||
}
|
||||
BooleanVariable L = (BooleanVariable) lhs;
|
||||
BooleanVariable R = (BooleanVariable) rhs;
|
||||
|
||||
|
|
|
@ -31,7 +31,10 @@ public class UnaryBitVectorUnion extends UnaryOperator {
|
|||
|
||||
|
||||
@Override
|
||||
public byte evaluate(IVariable lhs, IVariable rhs) {
|
||||
public byte evaluate(IVariable lhs, IVariable rhs) throws IllegalArgumentException {
|
||||
if (lhs == null) {
|
||||
throw new IllegalArgumentException("lhs == null");
|
||||
}
|
||||
BitVectorVariable L = (BitVectorVariable) lhs;
|
||||
BitVectorVariable R = (BitVectorVariable) rhs;
|
||||
|
||||
|
|
|
@ -75,8 +75,11 @@ public class SimpleDemandPointsTo extends AbstractDemandPointsTo {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Collection<InstanceKey> getPointsTo(PointerKey pk) throws UnimplementedError {
|
||||
public Collection<InstanceKey> getPointsTo(PointerKey pk) throws IllegalArgumentException, UnimplementedError {
|
||||
|
||||
if (pk == null) {
|
||||
throw new IllegalArgumentException("pk == null");
|
||||
}
|
||||
Assertions._assert(pk instanceof LocalPointerKey, "we only handle locals");
|
||||
LocalPointerKey lpk = (LocalPointerKey) pk;
|
||||
// Create an (initially empty) dependence graph
|
||||
|
|
|
@ -27,7 +27,10 @@ public final class TrueOperator extends UnaryOperator {
|
|||
}
|
||||
|
||||
@Override
|
||||
public byte evaluate(IVariable lhs, IVariable rhs) {
|
||||
public byte evaluate(IVariable lhs, IVariable rhs) throws IllegalArgumentException {
|
||||
if (lhs == null) {
|
||||
throw new IllegalArgumentException("lhs == null");
|
||||
}
|
||||
BooleanVariable L = (BooleanVariable) lhs;
|
||||
if (L.getValue()) {
|
||||
return NOT_CHANGED;
|
||||
|
|
|
@ -30,7 +30,10 @@ public final class UnaryOr extends UnaryOperator {
|
|||
|
||||
|
||||
@Override
|
||||
public byte evaluate(IVariable lhs, IVariable rhs) {
|
||||
public byte evaluate(IVariable lhs, IVariable rhs) throws IllegalArgumentException {
|
||||
if (lhs == null) {
|
||||
throw new IllegalArgumentException("lhs == null");
|
||||
}
|
||||
BooleanVariable L = (BooleanVariable) lhs;
|
||||
BooleanVariable R = (BooleanVariable) rhs;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
package com.ibm.wala.ipa.callgraph;
|
||||
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -27,49 +27,25 @@ import com.ibm.wala.util.debug.Assertions;
|
|||
*
|
||||
* @author sfink
|
||||
*/
|
||||
public class CGEdge {
|
||||
private final CGNode src;
|
||||
public class CGEdge extends Pair<CGNode,CGNode>{
|
||||
|
||||
private final CGNode dest;
|
||||
|
||||
public CGEdge(CGNode src, CGNode dest) {
|
||||
this.src = src;
|
||||
this.dest = dest;
|
||||
super(src,dest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(this.getClass().equals(obj.getClass()));
|
||||
}
|
||||
CGEdge other = (CGEdge) obj;
|
||||
return src.equals(other.src) && dest.equals(other.dest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 4027 * src.hashCode() + dest.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[" + src.toString() + "," + dest.toString() + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the node at the tail of this edge
|
||||
*/
|
||||
public CGNode getDest() {
|
||||
return dest;
|
||||
return snd;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the node at the head of this edge.
|
||||
*/
|
||||
public CGNode getSrc() {
|
||||
return src;
|
||||
return fst;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,56 +13,30 @@ package com.ibm.wala.ipa.callgraph.propagation.rta;
|
|||
import com.ibm.wala.classLoader.CallSiteReference;
|
||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||
import com.ibm.wala.types.Selector;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.collections.Pair;
|
||||
|
||||
/**
|
||||
* A utility class consisting of a pair CallSiteReference x CGNode
|
||||
*/
|
||||
public final class CallSite {
|
||||
private final CallSiteReference site;
|
||||
|
||||
private final CGNode node;
|
||||
public final class CallSite extends Pair<CallSiteReference, CGNode>{
|
||||
|
||||
public CallSite(CallSiteReference site, CGNode node) {
|
||||
this.site = site;
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 3229 * site.hashCode() + node.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null) {
|
||||
return false;
|
||||
}
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(getClass().equals(o.getClass()));
|
||||
}
|
||||
CallSite other = (CallSite) o;
|
||||
return node.equals(other.node) && site.equals(other.site);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return site.toString() + " " + node.toString();
|
||||
super(site,node);
|
||||
}
|
||||
|
||||
public CGNode getNode() {
|
||||
return node;
|
||||
return snd;
|
||||
}
|
||||
|
||||
public CallSiteReference getSite() {
|
||||
return site;
|
||||
return fst;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Selector that identifies this site
|
||||
*/
|
||||
public Selector getSelector() {
|
||||
return site.getDeclaredTarget().getSelector();
|
||||
return getSite().getDeclaredTarget().getSelector();
|
||||
}
|
||||
|
||||
}
|
|
@ -348,7 +348,10 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
|
|||
}
|
||||
}
|
||||
|
||||
public static CallSiteReference makeCallSiteReference(ClassLoaderReference loader, int pc, IInvokeInstruction call) {
|
||||
public static CallSiteReference makeCallSiteReference(ClassLoaderReference loader, int pc, IInvokeInstruction call) throws IllegalArgumentException {
|
||||
if (call == null) {
|
||||
throw new IllegalArgumentException("call == null");
|
||||
}
|
||||
CallSiteReference site = null;
|
||||
if (call instanceof InvokeInstruction) {
|
||||
InvokeInstruction c = (InvokeInstruction) call;
|
||||
|
|
|
@ -728,7 +728,10 @@ public class SSACFG implements ControlFlowGraph {
|
|||
/*
|
||||
* @see com.ibm.wala.util.graph.NumberedGraph#getNumber(com.ibm.wala.util.graph.Node)
|
||||
*/
|
||||
public int getNumber(IBasicBlock N) {
|
||||
public int getNumber(IBasicBlock N) throws IllegalArgumentException {
|
||||
if (N == null) {
|
||||
throw new IllegalArgumentException("N == null");
|
||||
}
|
||||
BasicBlock b = (BasicBlock) N;
|
||||
return b.getNumber();
|
||||
}
|
||||
|
@ -1022,7 +1025,10 @@ public class SSACFG implements ControlFlowGraph {
|
|||
return getSuccNodeNumbers(src).contains(getNumber(dst));
|
||||
}
|
||||
|
||||
public IntSet getSuccNodeNumbers(IBasicBlock node) {
|
||||
public IntSet getSuccNodeNumbers(IBasicBlock node) throws IllegalArgumentException {
|
||||
if (node == null) {
|
||||
throw new IllegalArgumentException("node == null");
|
||||
}
|
||||
BasicBlock b = (BasicBlock) node;
|
||||
IBasicBlock n = cfg.getNode(b.getNumber());
|
||||
return cfg.getSuccNodeNumbers(n);
|
||||
|
|
|
@ -237,7 +237,10 @@ public class ExplodedControlFlowGraph implements ControlFlowGraph {
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public int getPredNodeCount(IBasicBlock N) {
|
||||
public int getPredNodeCount(IBasicBlock N) throws IllegalArgumentException {
|
||||
if (N == null) {
|
||||
throw new IllegalArgumentException("N == null");
|
||||
}
|
||||
ExplodedBasicBlock b = (ExplodedBasicBlock) N;
|
||||
if (b.isEntryBlock()) {
|
||||
return 0;
|
||||
|
@ -249,7 +252,10 @@ public class ExplodedControlFlowGraph implements ControlFlowGraph {
|
|||
}
|
||||
}
|
||||
|
||||
public Iterator<? extends IBasicBlock> getPredNodes(IBasicBlock N) {
|
||||
public Iterator<? extends IBasicBlock> getPredNodes(IBasicBlock N) throws IllegalArgumentException {
|
||||
if (N == null) {
|
||||
throw new IllegalArgumentException("N == null");
|
||||
}
|
||||
ExplodedBasicBlock b = (ExplodedBasicBlock) N;
|
||||
if (b.isEntryBlock()) {
|
||||
return EmptyIterator.instance();
|
||||
|
|
|
@ -27,7 +27,9 @@ import com.ibm.wala.util.debug.Assertions;
|
|||
public final class CacheReference {
|
||||
|
||||
private final static byte SOFT = 0;
|
||||
|
||||
private final static byte WEAK = 1;
|
||||
|
||||
private final static byte HARD = 2;
|
||||
|
||||
// should be SOFT except during debugging.
|
||||
|
@ -36,31 +38,32 @@ public final class CacheReference {
|
|||
public final static Object make(final Object referent) {
|
||||
|
||||
switch (choice) {
|
||||
case SOFT :
|
||||
return new SoftReference<Object>(referent);
|
||||
case WEAK :
|
||||
return new WeakReference<Object>(referent);
|
||||
case HARD :
|
||||
return referent;
|
||||
default :
|
||||
Assertions.UNREACHABLE();
|
||||
return null;
|
||||
case SOFT:
|
||||
return new SoftReference<Object>(referent);
|
||||
case WEAK:
|
||||
return new WeakReference<Object>(referent);
|
||||
case HARD:
|
||||
return referent;
|
||||
default:
|
||||
Assertions.UNREACHABLE();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public final static Object get(final Object reference) {
|
||||
if (reference == null)
|
||||
if (reference == null) {
|
||||
return null;
|
||||
}
|
||||
switch (choice) {
|
||||
case SOFT :
|
||||
return ((SoftReference) reference).get();
|
||||
case WEAK :
|
||||
return ((WeakReference) reference).get();
|
||||
case HARD :
|
||||
return reference;
|
||||
default :
|
||||
Assertions.UNREACHABLE();
|
||||
return null;
|
||||
case SOFT:
|
||||
return ((SoftReference) reference).get();
|
||||
case WEAK:
|
||||
return ((WeakReference) reference).get();
|
||||
case HARD:
|
||||
return reference;
|
||||
default:
|
||||
Assertions.UNREACHABLE();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ import com.ibm.wala.util.collections.Filter;
|
|||
* a regular expression
|
||||
*
|
||||
* @author sjfink
|
||||
*
|
||||
*/
|
||||
public class PackageExpressionFilter implements Filter {
|
||||
|
||||
|
@ -31,7 +30,10 @@ public class PackageExpressionFilter implements Filter {
|
|||
this.pattern = Pattern.compile(pattern);
|
||||
}
|
||||
|
||||
public boolean accepts(Object o) {
|
||||
public boolean accepts(Object o) throws IllegalArgumentException {
|
||||
if (o == null) {
|
||||
throw new IllegalArgumentException("o == null");
|
||||
}
|
||||
IClass c = (IClass) o;
|
||||
if (c.getName().getPackage() == null) {
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue