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

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

Loading…
Cancel
Save