From 55646c838409da713d8c82329a906841c372eaa4 Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 10 Aug 2019 22:16:05 +0100 Subject: [PATCH] Add newParameterValue() implementation to IntInterpreter --- .../openrs2/deob/analysis/IntInterpreter.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.java b/deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.java index 30fc754c1c..9cf47f2d86 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.java +++ b/deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.java @@ -16,8 +16,11 @@ import org.objectweb.asm.tree.analysis.Interpreter; public final class IntInterpreter extends Interpreter { private final Interpreter basicInterpreter = new BasicInterpreter(); - public IntInterpreter() { + private final Integer[] parameters; + + public IntInterpreter(Integer[] parameters) { super(Opcodes.ASM7); + this.parameters = parameters; } @Override @@ -30,6 +33,33 @@ public final class IntInterpreter extends Interpreter { return IntValue.newUnknown(basicValue); } + @Override + public IntValue newParameterValue(boolean isInstanceMethod, int local, Type type) { + var basicValue = basicInterpreter.newParameterValue(isInstanceMethod, local, type); + if (basicValue == null) { + return null; + } + + if (parameters != null) { + int parameterIndex; + if (isInstanceMethod) { + if (local == 0) { + return IntValue.newUnknown(basicValue); + } + parameterIndex = local - 1; + } else { + parameterIndex = local; + } + + var parameter = parameters[parameterIndex]; + if (parameter != null) { + return IntValue.newConstant(basicValue, parameter); + } + } + + return IntValue.newUnknown(basicValue); + } + @Override public IntValue newOperation(AbstractInsnNode insn) throws AnalyzerException { var basicValue = basicInterpreter.newOperation(insn);