forked from openrs2/openrs2
This allows us to avoid needing to worry about manipulating stack frames in individual transformers, which adds lots of complexity. It's much easier to just make ASM generate them for us. Signed-off-by: Graham <gpe@openrs2.dev>bzip2
parent
1805873385
commit
e6402d52c2
@ -0,0 +1,21 @@ |
||||
package dev.openrs2.asm.classpath |
||||
|
||||
import org.objectweb.asm.ClassWriter |
||||
|
||||
class StackFrameClassWriter(private val classPath: ClassPath) : ClassWriter(COMPUTE_FRAMES) { |
||||
override fun getCommonSuperClass(type1: String, type2: String): String { |
||||
var c = classPath[type1]!! |
||||
val d = classPath[type2]!! |
||||
return when { |
||||
c.isAssignableFrom(d) -> type1 |
||||
d.isAssignableFrom(c) -> type2 |
||||
c.`interface` || d.`interface` -> "java/lang/Object" |
||||
else -> { |
||||
do { |
||||
c = c.superClass!! |
||||
} while (!c.isAssignableFrom(d)) |
||||
c.name |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue