From 36de671078d9cae2dea4358897a298950980f3d1 Mon Sep 17 00:00:00 2001 From: Christian Banse Date: Sun, 31 Dec 2023 20:00:16 +0100 Subject: [PATCH] Use information of operand value to determine type for java locals This PR uses the already existing information of the operand's value type to determine the type for java locals. Previously, most of the stack variables were of "unknown" type . Fixes #635 --- .../java/sootup/java/bytecode/frontend/Operand.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sootup.java.bytecode/src/main/java/sootup/java/bytecode/frontend/Operand.java b/sootup.java.bytecode/src/main/java/sootup/java/bytecode/frontend/Operand.java index 5f185ce9224..6411bc70c4b 100644 --- a/sootup.java.bytecode/src/main/java/sootup/java/bytecode/frontend/Operand.java +++ b/sootup.java.bytecode/src/main/java/sootup/java/bytecode/frontend/Operand.java @@ -21,9 +21,7 @@ * . * #L% */ -import java.util.stream.Collectors; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; + import org.objectweb.asm.tree.AbstractInsnNode; import sootup.core.jimple.Jimple; import sootup.core.jimple.basic.Immediate; @@ -35,6 +33,10 @@ import sootup.core.jimple.common.stmt.Stmt; import sootup.core.jimple.visitor.ReplaceUseStmtVisitor; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.stream.Collectors; + /** * Stack operand. * @@ -67,7 +69,7 @@ class Operand { Local getOrAssignValueToStackLocal() { if (stackLocal == null) { - changeStackLocal(methodSource.newStackLocal()); + changeStackLocal(methodSource.newStackLocal().withType(value.getType())); } return stackLocal;