Skip to content

Commit

Permalink
Address #108 (comment).
Browse files Browse the repository at this point in the history
  • Loading branch information
khatchad committed Dec 1, 2023
1 parent cd48f40 commit cc21eb9
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.ibm.wala.cast.python.types.PythonTypes;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.IField;
import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.core.util.strings.Atom;
import com.ibm.wala.fixpoint.AbstractOperator;
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
Expand All @@ -40,7 +39,6 @@
import com.ibm.wala.ssa.SSAGetInstruction;
import com.ibm.wala.ssa.SymbolTable;
import com.ibm.wala.types.FieldReference;
import com.ibm.wala.types.TypeName;
import com.ibm.wala.types.TypeReference;
import com.ibm.wala.util.collections.HashMapFactory;
import com.ibm.wala.util.collections.Pair;
Expand Down Expand Up @@ -220,7 +218,7 @@ protected void processCallingConstraints(
PointerKey rval = getPointerKeyForLocal(caller, call.getUse(i));

// If we are looking at the implicit parameter of a callable.
if (call.getCallSite().isDispatch() && i == 0 && isCallable(rval)) {
if (call.getCallSite().isDispatch() && i == 0 && refersToAnObject(rval)) {
// Ensure that lval's variable refers to the callable method instead of callable object.
IClass callable = target.getMethod().getDeclaringClass();
IntSet instanceKeysForCallable = this.getSystem().getInstanceKeysForClass(callable);
Expand Down Expand Up @@ -292,9 +290,17 @@ protected void processCallingConstraints(
}
}

protected boolean isCallable(PointerKey rval) {
/**
* Returns true iff the given {@link PointerKey} points to at least one instance whose concrete
* type equals {@link PythonTypes#object}.
*
* @param pointerKey The {@link PointerKey} in question.
* @return True iff the given {@link PointerKey} points to at least one object whose concrete type
* equals {@link PythonTypes#object}.,
*/
protected boolean refersToAnObject(PointerKey pointerKey) {
PointerAnalysis<InstanceKey> pointerAnalysis = this.getPointerAnalysis();
OrdinalSet<InstanceKey> pointsToSet = pointerAnalysis.getPointsToSet(rval);
OrdinalSet<InstanceKey> pointsToSet = pointerAnalysis.getPointsToSet(pointerKey);

for (InstanceKey instanceKey : pointsToSet) {
IClass concreteType = instanceKey.getConcreteType();
Expand Down

0 comments on commit cc21eb9

Please sign in to comment.