Got rid of IntegerContextItem and BooleanContextItem and replaced them
by uses of ContextItem.Value. git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@4514 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
1ae581819f
commit
ec7be6dc39
|
@ -50,41 +50,6 @@ import com.ibm.wala.util.intset.IntSetUtil;
|
|||
import com.ibm.wala.util.intset.MutableIntSet;
|
||||
|
||||
public class ForInContextSelector implements ContextSelector {
|
||||
|
||||
public static class IntegerContextItem implements ContextItem {
|
||||
private final int value;
|
||||
|
||||
public IntegerContextItem(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + value;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
IntegerContextItem other = (IntegerContextItem) obj;
|
||||
if (value != other.value)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public final static ContextKey FORIN_KEY = new ContextKey() { };
|
||||
public final static ContextKey FORIN_PARM_INDEX = new ContextKey() { };
|
||||
|
||||
|
@ -165,7 +130,7 @@ public class ForInContextSelector implements ContextSelector {
|
|||
if (FORIN_KEY.equals(key)) {
|
||||
return FORIN_MARKER;
|
||||
} else if(FORIN_PARM_INDEX.equals(key)) {
|
||||
return new IntegerContextItem(index);
|
||||
return ContextItem.Value.make(index);
|
||||
} else {
|
||||
return super.get(key);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.ibm.wala.cast.js.ipa.callgraph;
|
||||
|
||||
import com.ibm.wala.cast.ipa.callgraph.AstContextInsensitiveSSAContextInterpreter;
|
||||
import com.ibm.wala.cast.js.ipa.callgraph.JavaScriptFunctionApplyContextSelector.BooleanContextItem;
|
||||
import com.ibm.wala.cast.js.ipa.summaries.JavaScriptSummarizedFunction;
|
||||
import com.ibm.wala.cast.js.ipa.summaries.JavaScriptSummary;
|
||||
import com.ibm.wala.cast.js.loader.JSCallSiteReference;
|
||||
|
@ -11,6 +10,7 @@ import com.ibm.wala.classLoader.IClass;
|
|||
import com.ibm.wala.ipa.callgraph.AnalysisCache;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
|
||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||
import com.ibm.wala.ipa.callgraph.ContextItem;
|
||||
import com.ibm.wala.ssa.ConstantValue;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
|
@ -40,10 +40,11 @@ public class JavaScriptFunctionApplyContextInterpreter extends AstContextInsensi
|
|||
@Override
|
||||
public IR getIR(CGNode node) {
|
||||
assert understands(node);
|
||||
BooleanContextItem isNonNullArray = (BooleanContextItem) node.getContext().get(JavaScriptFunctionApplyContextSelector.APPLY_NON_NULL_ARGS);
|
||||
@SuppressWarnings("unchecked")
|
||||
ContextItem.Value<Boolean> isNonNullArray = (ContextItem.Value<Boolean>) node.getContext().get(JavaScriptFunctionApplyContextSelector.APPLY_NON_NULL_ARGS);
|
||||
// isNonNullArray can be null if, e.g., due to recursion bounding we have no
|
||||
// information on the arguments parameter
|
||||
if (isNonNullArray == null || isNonNullArray.val) {
|
||||
if (isNonNullArray == null || isNonNullArray.getValue()) {
|
||||
return makeIRForArgList(node);
|
||||
} else {
|
||||
return makeIRForNoArgList(node);
|
||||
|
|
|
@ -33,42 +33,6 @@ public class JavaScriptFunctionApplyContextSelector implements ContextSelector {
|
|||
public static final ContextKey APPLY_NON_NULL_ARGS = new ContextKey() {
|
||||
};
|
||||
|
||||
public static class BooleanContextItem implements ContextItem {
|
||||
final boolean val;
|
||||
|
||||
BooleanContextItem(boolean val) {
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (val ? 1231 : 1237);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
BooleanContextItem other = (BooleanContextItem) obj;
|
||||
if (val != other.val)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BooleanContextItem [val=" + val + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final ContextSelector base;
|
||||
private ContextSelector oneLevel;
|
||||
|
||||
|
@ -95,11 +59,12 @@ public class JavaScriptFunctionApplyContextSelector implements ContextSelector {
|
|||
/**
|
||||
* was the argsList argument a non-null Array?
|
||||
*/
|
||||
private final BooleanContextItem isNonNullArray;
|
||||
private final ContextItem.Value<Boolean> isNonNullArray;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ApplyContext(Context delegate, boolean isNonNullArray) {
|
||||
this.delegate = delegate;
|
||||
this.isNonNullArray = new BooleanContextItem(isNonNullArray);
|
||||
this.isNonNullArray = ContextItem.Value.make(isNonNullArray);
|
||||
}
|
||||
|
||||
public ContextItem get(ContextKey name) {
|
||||
|
|
|
@ -31,5 +31,27 @@ public interface ContextItem {
|
|||
return new Value<T>(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 + ((v == null) ? 0 : v.hashCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Value other = (Value) obj;
|
||||
if (v == null) {
|
||||
if (other.v != null)
|
||||
return false;
|
||||
} else if (!v.equals(other.v))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue