From 7e422447efb494066dc09a599e4ea82a80cf467c Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 2 May 2020 23:54:20 +0100 Subject: [PATCH] Convert hasCode() to a property Signed-off-by: Graham --- asm/src/main/java/dev/openrs2/asm/ClassNodeRemapper.kt | 2 +- asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt | 5 ++--- asm/src/main/java/dev/openrs2/asm/transform/Transformer.kt | 2 +- .../dev/openrs2/bundler/transform/BufferSizeTransformer.kt | 2 +- .../java/dev/openrs2/deob/transform/BitwiseOpTransformer.kt | 2 +- .../dev/openrs2/deob/transform/ConstantArgTransformer.kt | 2 +- .../java/dev/openrs2/deob/transform/CounterTransformer.kt | 2 +- .../dev/openrs2/deob/transform/OpaquePredicateTransformer.kt | 2 +- .../main/java/dev/openrs2/deob/transform/ResetTransformer.kt | 2 +- .../java/dev/openrs2/deob/transform/UnusedArgTransformer.kt | 4 ++-- 10 files changed, 12 insertions(+), 13 deletions(-) diff --git a/asm/src/main/java/dev/openrs2/asm/ClassNodeRemapper.kt b/asm/src/main/java/dev/openrs2/asm/ClassNodeRemapper.kt index 095106c167..1f13a00c0c 100644 --- a/asm/src/main/java/dev/openrs2/asm/ClassNodeRemapper.kt +++ b/asm/src/main/java/dev/openrs2/asm/ClassNodeRemapper.kt @@ -31,7 +31,7 @@ fun ClassNode.remap(remapper: Remapper) { method.signature = remapper.mapSignature(method.signature, false) method.exceptions = method.exceptions.map(remapper::mapType) - if (method.hasCode()) { + if (method.hasCode) { ClassForNameUtils.remap(remapper, method) for (insn in method.instructions) { diff --git a/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt b/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt index fddb3a907a..c1fbc97bae 100644 --- a/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt +++ b/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt @@ -123,9 +123,8 @@ fun MethodNode.removeDeadCode(owner: String) { } while (changed) } -fun MethodNode.hasCode(): Boolean { - return access and (Opcodes.ACC_NATIVE or Opcodes.ACC_ABSTRACT) == 0 -} +val MethodNode.hasCode + get() = access and (Opcodes.ACC_NATIVE or Opcodes.ACC_ABSTRACT) == 0 fun MethodNode.copy(): MethodNode { val copy = MethodNode( diff --git a/asm/src/main/java/dev/openrs2/asm/transform/Transformer.kt b/asm/src/main/java/dev/openrs2/asm/transform/Transformer.kt index ebb1fc17f5..8c96709e5c 100644 --- a/asm/src/main/java/dev/openrs2/asm/transform/Transformer.kt +++ b/asm/src/main/java/dev/openrs2/asm/transform/Transformer.kt @@ -26,7 +26,7 @@ abstract class Transformer { for (method in clazz.methods) { changed = changed or preTransformMethod(classPath, library, clazz, method) - if (method.hasCode()) { + if (method.hasCode) { changed = changed or transformCode(classPath, library, clazz, method) } diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/BufferSizeTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/BufferSizeTransformer.kt index 5696fa4ba4..a10c8c37b6 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/BufferSizeTransformer.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/BufferSizeTransformer.kt @@ -26,7 +26,7 @@ class BufferSizeTransformer : Transformer() { for (library in classPath.libraries) { for (clazz in library) { for (method in clazz.methods) { - if (!method.hasCode()) { + if (!method.hasCode) { continue } diff --git a/deob/src/main/java/dev/openrs2/deob/transform/BitwiseOpTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/BitwiseOpTransformer.kt index 50d6361c4d..14961f5564 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/BitwiseOpTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/BitwiseOpTransformer.kt @@ -27,7 +27,7 @@ class BitwiseOpTransformer : Transformer() { for (library in classPath.libraries) { for (clazz in library) { for (method in clazz.methods) { - if (!method.hasCode()) { + if (!method.hasCode) { continue } diff --git a/deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt index 4fd29c92d4..c6e2b8353a 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt @@ -99,7 +99,7 @@ class ConstantArgTransformer : Transformer() { // find ClassNode/MethodNode val owner = classPath.getClassNode(ref.owner) ?: return val originalMethod = owner.methods.singleOrNull { it.name == ref.name && it.desc == ref.desc } ?: return - if (!originalMethod.hasCode()) { + if (!originalMethod.hasCode) { return } diff --git a/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.kt index b406e6200c..8d26696d91 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.kt @@ -26,7 +26,7 @@ class CounterTransformer : Transformer() { for (library in classPath.libraries) { for (clazz in library) { for (method in clazz.methods) { - if (method.hasCode()) { + if (method.hasCode) { findCounters(method, references, resets, increments) } } diff --git a/deob/src/main/java/dev/openrs2/deob/transform/OpaquePredicateTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/OpaquePredicateTransformer.kt index 5e64065e77..1dd6aeb0ad 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/OpaquePredicateTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/OpaquePredicateTransformer.kt @@ -30,7 +30,7 @@ class OpaquePredicateTransformer : Transformer() { for (library in classPath.libraries) { for (clazz in library) { for (method in clazz.methods) { - if (method.hasCode()) { + if (method.hasCode) { findFlowObstructors(library, method) } } diff --git a/deob/src/main/java/dev/openrs2/deob/transform/ResetTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/ResetTransformer.kt index 6cd901d481..2d59aa8b36 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/ResetTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/ResetTransformer.kt @@ -28,7 +28,7 @@ class ResetTransformer : Transformer() { for (library in classPath.libraries) { for (clazz in library) { for (method in clazz.methods) { - if (!method.hasCode()) { + if (!method.hasCode) { continue } diff --git a/deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.kt index 91ed1637a9..08f84d4d1d 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.kt @@ -36,7 +36,7 @@ class UnusedArgTransformer : Transformer() { for (library in classPath.libraries) { for (clazz in library) { for (method in clazz.methods) { - if (method.hasCode()) { + if (method.hasCode) { populateRetainedArgs(classPath, clazz, method) } } @@ -94,7 +94,7 @@ class UnusedArgTransformer : Transformer() { method: MethodNode ): Boolean { // delete unused int args from call sites - if (!method.hasCode()) { + if (!method.hasCode) { return false }