From e3df684f4f2e191f8871d026b5193e8f69d32137 Mon Sep 17 00:00:00 2001 From: Graham Date: Mon, 27 Jan 2020 21:18:54 +0000 Subject: [PATCH] Inline JSRs This is required for some later analyses to work correctly. --- .../dev/openrs2/asm/classpath/JsrInliner.kt | 19 +++++++++++++++++++ .../java/dev/openrs2/asm/classpath/Library.kt | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 asm/src/main/java/dev/openrs2/asm/classpath/JsrInliner.kt diff --git a/asm/src/main/java/dev/openrs2/asm/classpath/JsrInliner.kt b/asm/src/main/java/dev/openrs2/asm/classpath/JsrInliner.kt new file mode 100644 index 00000000..630ad86c --- /dev/null +++ b/asm/src/main/java/dev/openrs2/asm/classpath/JsrInliner.kt @@ -0,0 +1,19 @@ +package dev.openrs2.asm.classpath + +import org.objectweb.asm.ClassVisitor +import org.objectweb.asm.MethodVisitor +import org.objectweb.asm.Opcodes +import org.objectweb.asm.commons.JSRInlinerAdapter + +class JsrInliner(cv: ClassVisitor) : ClassVisitor(Opcodes.ASM7, cv) { + override fun visitMethod( + access: Int, + name: String, + descriptor: String, + signature: String?, + exceptions: Array? + ): MethodVisitor { + val mv = super.visitMethod(access, name, descriptor, signature, exceptions) + return JSRInlinerAdapter(mv, access, name, descriptor, signature, exceptions) + } +} diff --git a/asm/src/main/java/dev/openrs2/asm/classpath/Library.kt b/asm/src/main/java/dev/openrs2/asm/classpath/Library.kt index d5000b91..6d1fdff4 100644 --- a/asm/src/main/java/dev/openrs2/asm/classpath/Library.kt +++ b/asm/src/main/java/dev/openrs2/asm/classpath/Library.kt @@ -159,7 +159,7 @@ class Library constructor() : Iterable { val clazz = ClassNode() val reader = ClassReader(`in`) - reader.accept(clazz, ClassReader.SKIP_DEBUG) + reader.accept(JsrInliner(clazz), ClassReader.SKIP_DEBUG) library.add(clazz) }