From c0da020649485de91b1555972dce8cc429c11227 Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 15 Feb 2020 16:54:57 +0000 Subject: [PATCH] Fix handling of argumentsAndReturnSizes for static methods --- asm/src/main/java/dev/openrs2/asm/StackMetadata.kt | 4 ++-- .../java/dev/openrs2/deob/transform/DummyArgTransformer.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/asm/src/main/java/dev/openrs2/asm/StackMetadata.kt b/asm/src/main/java/dev/openrs2/asm/StackMetadata.kt index dcc622665e..932204582d 100644 --- a/asm/src/main/java/dev/openrs2/asm/StackMetadata.kt +++ b/asm/src/main/java/dev/openrs2/asm/StackMetadata.kt @@ -205,8 +205,8 @@ fun AbstractInsnNode.stackMetadata(): StackMetadata = when (this) { val argumentsAndReturnSizes = Type.getArgumentsAndReturnSizes(desc) val pushes = argumentsAndReturnSizes and 0x3 var pops = argumentsAndReturnSizes shr 2 - if (opcode != Opcodes.INVOKESTATIC) { - pops++ + if (opcode == Opcodes.INVOKESTATIC) { + pops-- } StackMetadata(pops, pushes) } diff --git a/deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.kt index 528f11f0eb..1d88cb462b 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.kt @@ -179,7 +179,7 @@ class DummyArgTransformer : Transformer() { var callerSlots = Type.getArgumentsAndReturnSizes(method.desc) shr 2 if (method.access and Opcodes.ACC_STATIC != 0) { - callerSlots++ + callerSlots-- } if (load.`var` >= callerSlots) { continue