Improve consistency of isClassRenamable and isMethodImmutable

This commit:

* Renames isMethodImmutable to isMethodRenamable and flips the value of
  the boolean it outputs accordingly.
* Updates all uses of isMethodRenamable to account for this.
* Makes the internal implementation more similar to isClassRenamable.

Signed-off-by: Graham <gpe@openrs2.dev>
bzip2
Graham 5 years ago
parent f4933a2b59
commit 5c1768e824
  1. 18
      deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt
  2. 6
      deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.kt

@ -204,25 +204,21 @@ class TypedRemapper private constructor(
return true
}
fun isMethodImmutable(classPath: ClassPath, partition: DisjointSet.Partition<MemberRef>): Boolean {
fun isMethodRenamable(classPath: ClassPath, partition: DisjointSet.Partition<MemberRef>): Boolean {
for (method in partition) {
val clazz = classPath[method.owner]!!
if (method.name in EXCLUDED_METHODS) {
return true
}
if (clazz.dependency) {
return true
if (method.name in EXCLUDED_METHODS || clazz.dependency) {
return false
}
val access = clazz.getAccess(MemberDesc(method))
if (access != null && (access and Opcodes.ACC_NATIVE) != 0) {
return true
if (access != null && access and Opcodes.ACC_NATIVE != 0) {
return false
}
}
return false
return true
}
private fun createMethodMapping(
@ -233,7 +229,7 @@ class TypedRemapper private constructor(
var id = 0
for (partition in disjointSet) {
if (isMethodImmutable(classPath, partition)) {
if (!isMethodRenamable(classPath, partition)) {
continue
}

@ -69,7 +69,7 @@ class UnusedArgTransformer : Transformer() {
}
is MethodInsnNode -> {
val invokePartition = inheritedMethodSets[MemberRef(insn)]
if (invokePartition == null || TypedRemapper.isMethodImmutable(classPath, invokePartition)) {
if (invokePartition == null || !TypedRemapper.isMethodRenamable(classPath, invokePartition)) {
continue@frame
}
@ -113,7 +113,7 @@ class UnusedArgTransformer : Transformer() {
}
val partition = inheritedMethodSets[MemberRef(insn)]
if (partition == null || TypedRemapper.isMethodImmutable(classPath, partition)) {
if (partition == null || !TypedRemapper.isMethodRenamable(classPath, partition)) {
continue
}
@ -146,7 +146,7 @@ class UnusedArgTransformer : Transformer() {
): Boolean {
// delete unused int args from the method itself
val partition = inheritedMethodSets[MemberRef(clazz, method)]!!
if (TypedRemapper.isMethodImmutable(classPath, partition)) {
if (!TypedRemapper.isMethodRenamable(classPath, partition)) {
return false
}

Loading…
Cancel
Save