diff --git a/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt b/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt index f690d80c70..89b99aebb4 100644 --- a/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt +++ b/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt @@ -133,3 +133,15 @@ fun MethodNode.removeDeadCode(owner: String) { fun MethodNode.hasCode(): Boolean { return access and (Opcodes.ACC_NATIVE or Opcodes.ACC_ABSTRACT) == 0 } + +fun MethodNode.copy(): MethodNode { + val copy = MethodNode( + access, + name, + desc, + signature, + exceptions?.toTypedArray() + ) + accept(copy) + return copy +} diff --git a/deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt index 8cfb9983ba..6cd222cdd3 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt @@ -4,6 +4,7 @@ import com.github.michaelbull.logging.InlineLogger import dev.openrs2.asm.MemberRef import dev.openrs2.asm.classpath.ClassPath import dev.openrs2.asm.classpath.Library +import dev.openrs2.asm.copy import dev.openrs2.asm.createIntConstant import dev.openrs2.asm.deleteExpression import dev.openrs2.asm.hasCode @@ -105,14 +106,7 @@ class ConstantArgTransformer : Transformer() { * final pass, as we might discover more routes through the call graph * later which reduce the number of branches we can simplify. */ - val method = MethodNode( - originalMethod.access, - originalMethod.name, - originalMethod.desc, - originalMethod.signature, - originalMethod.exceptions?.toTypedArray() - ) - originalMethod.accept(method) + val method = originalMethod.copy() // find existing constant arguments val args = getArgs(ref)