Allow prePass and postPass to force another pass

bzip2
Graham 5 years ago
parent 3ed591d89b
commit 81bbc71e29
  1. 14
      asm/src/main/java/dev/openrs2/asm/transform/Transformer.kt
  2. 7
      deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.kt

@ -13,9 +13,8 @@ abstract class Transformer {
var changed: Boolean var changed: Boolean
do { do {
changed = false changed = prePass(classPath)
prePass(classPath)
for (library in classPath.libraries) { for (library in classPath.libraries) {
for (clazz in library) { for (clazz in library) {
changed = changed or transformClass(classPath, library, clazz) changed = changed or transformClass(classPath, library, clazz)
@ -35,7 +34,8 @@ abstract class Transformer {
} }
} }
} }
postPass(classPath)
changed = changed or postPass(classPath)
} while (changed) } while (changed)
postTransform(classPath) postTransform(classPath)
@ -45,8 +45,8 @@ abstract class Transformer {
// empty // empty
} }
protected open fun prePass(classPath: ClassPath) { protected open fun prePass(classPath: ClassPath): Boolean {
// empty return false
} }
protected open fun transformClass(classPath: ClassPath, library: Library, clazz: ClassNode): Boolean { protected open fun transformClass(classPath: ClassPath, library: Library, clazz: ClassNode): Boolean {
@ -89,8 +89,8 @@ abstract class Transformer {
return false return false
} }
protected open fun postPass(classPath: ClassPath) { protected open fun postPass(classPath: ClassPath): Boolean {
// empty return false
} }
protected open fun postTransform(classPath: ClassPath) { protected open fun postTransform(classPath: ClassPath) {

@ -149,9 +149,10 @@ class DummyArgTransformer : Transformer() {
constantsInlined = 0 constantsInlined = 0
} }
override fun prePass(classPath: ClassPath) { override fun prePass(classPath: ClassPath): Boolean {
argValues.clear() argValues.clear()
conditionalCalls.clear() conditionalCalls.clear()
return false
} }
override fun transformCode( override fun transformCode(
@ -327,7 +328,7 @@ class DummyArgTransformer : Transformer() {
return changed return changed
} }
override fun postPass(classPath: ClassPath) { override fun postPass(classPath: ClassPath): Boolean {
for (method in inheritedMethodSets) { for (method in inheritedMethodSets) {
val args = (Type.getArgumentsAndReturnSizes(method.first().desc) shr 2) - 1 val args = (Type.getArgumentsAndReturnSizes(method.first().desc) shr 2) - 1
@ -348,6 +349,8 @@ class DummyArgTransformer : Transformer() {
constArgs[method] = parameters constArgs[method] = parameters
} }
} }
return false
} }
override fun postTransform(classPath: ClassPath) { override fun postTransform(classPath: ClassPath) {

Loading…
Cancel
Save