Skip to content

Commit

Permalink
Fix non-scalar determination.
Browse files Browse the repository at this point in the history
It's only non-scalar if it's on the LHS of the property reads.
  • Loading branch information
khatchad committed Jan 8, 2024
1 parent 4274b34 commit 18e0e99
Showing 1 changed file with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,30 @@ private static void processInstructionInterprocedurally(
*/
private static boolean definitionIsNonScalar(
EachElementGetInstruction eachElementGetInstruction, DefUse du) {
for (int i = 0; i < du.getNumberOfUses(eachElementGetInstruction.getDef()); i++) {
for (Iterator<SSAInstruction> uses = du.getUses(eachElementGetInstruction.getDef());
uses.hasNext(); ) {
SSAInstruction instruction = uses.next();
if (instruction instanceof PythonPropertyRead) return true;
int def = eachElementGetInstruction.getDef();
logger.info(
"Processing definition: " + def + " of instruction: " + eachElementGetInstruction + ".");

int numberOfUses = du.getNumberOfUses(def);
logger.info(
"Definition: "
+ def
+ " of instruction: "
+ eachElementGetInstruction
+ " has "
+ numberOfUses
+ " uses.");

for (Iterator<SSAInstruction> uses = du.getUses(def); uses.hasNext(); ) {
SSAInstruction instruction = uses.next();
logger.info("Processing use: " + instruction + ".");

if (instruction instanceof PythonPropertyRead) {
PythonPropertyRead read = (PythonPropertyRead) instruction;
logger.info("Found property read use: " + read + ".");

// if the definition appears on the LHS of the read.
if (read.getObjectRef() == def) return true;
}
}
return false;
Expand Down

0 comments on commit 18e0e99

Please sign in to comment.