Skip to content

Commit

Permalink
It should be a for each element get instruction.
Browse files Browse the repository at this point in the history
  • Loading branch information
khatchad committed Dec 20, 2023
1 parent 639f4dd commit 8bd6779
Showing 1 changed file with 24 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

import com.ibm.wala.cast.ipa.callgraph.AstSSAPropagationCallGraphBuilder;
import com.ibm.wala.cast.ipa.callgraph.GlobalObjectKey;
import com.ibm.wala.cast.ir.ssa.AstGlobalRead;
import com.ibm.wala.cast.ir.ssa.AstPropertyRead;
import com.ibm.wala.cast.ir.ssa.EachElementGetInstruction;
import com.ibm.wala.cast.python.ipa.summaries.BuiltinFunctions.BuiltinFunction;
import com.ibm.wala.cast.python.ir.PythonLanguage;
import com.ibm.wala.cast.python.ssa.PythonInstructionVisitor;
Expand Down Expand Up @@ -187,34 +187,29 @@ public void visitPropertyRead(AstPropertyRead instruction) {
PythonPropertyRead ppr = (PythonPropertyRead) instruction;
SSAInstruction memberRefDef = du.getDef(ppr.getMemberRef());

if (memberRefDef != null && memberRefDef instanceof AstGlobalRead) {
AstGlobalRead agr = (AstGlobalRead) memberRefDef;

if (agr.isStatic()) {
// most likely a for each "property."
final PointerKey memberRefKey = this.getPointerKeyForLocal(ppr.getMemberRef());

// for each def of the property read.
for (int i = 0; i < ppr.getNumberOfDefs(); i++) {
PointerKey defKey = this.getPointerKeyForLocal(ppr.getDef(i));

// add an assignment constraint straight away as the traversal variable won't have a
// non-empty points-to set but still may be used for a dataflow analysis.
if (this.system.newConstraint(defKey, assignOperator, memberRefKey))
logger.fine(
() ->
"Added new system constraint for global read from: "
+ defKey
+ " to: "
+ memberRefKey
+ " for instruction: "
+ instruction
+ ".");
else
logger.fine(
() ->
"No constraint added for global read in instruction: " + instruction + ".");
}
if (memberRefDef != null && memberRefDef instanceof EachElementGetInstruction) {
// most likely a for each "property."
final PointerKey memberRefKey = this.getPointerKeyForLocal(ppr.getMemberRef());

// for each def of the property read.
for (int i = 0; i < ppr.getNumberOfDefs(); i++) {
PointerKey defKey = this.getPointerKeyForLocal(ppr.getDef(i));

// add an assignment constraint straight away as the traversal variable won't have a
// non-empty points-to set but still may be used for a dataflow analysis.
if (this.system.newConstraint(defKey, assignOperator, memberRefKey))
logger.fine(
() ->
"Added new system constraint for global read from: "
+ defKey
+ " to: "
+ memberRefKey
+ " for instruction: "
+ instruction
+ ".");
else
logger.fine(
() -> "No constraint added for global read in instruction: " + instruction + ".");
}
}
}
Expand Down

0 comments on commit 8bd6779

Please sign in to comment.