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

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

Loading…
Cancel
Save