From 2471418d4a2de02f5cf9d0383d7190dacd280df0 Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 2 May 2020 23:45:00 +0100 Subject: [PATCH] Add is prefix to boolean extension properties Signed-off-by: Graham --- asm/src/main/java/dev/openrs2/asm/InsnListUtils.kt | 2 +- asm/src/main/java/dev/openrs2/asm/InsnNodeUtils.kt | 4 ++-- build.gradle.kts | 6 +++--- .../openrs2/deob/transform/ConstantArgTransformer.kt | 10 +++++----- .../openrs2/deob/transform/UnusedLocalTransformer.kt | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/asm/src/main/java/dev/openrs2/asm/InsnListUtils.kt b/asm/src/main/java/dev/openrs2/asm/InsnListUtils.kt index 01044332f7..7718ff3072 100644 --- a/asm/src/main/java/dev/openrs2/asm/InsnListUtils.kt +++ b/asm/src/main/java/dev/openrs2/asm/InsnListUtils.kt @@ -26,7 +26,7 @@ fun getExpression( } insn = insn.previous - } while (insn != null && insn.sequential && filter(insn)) + } while (insn != null && insn.isSequential && filter(insn)) return null } diff --git a/asm/src/main/java/dev/openrs2/asm/InsnNodeUtils.kt b/asm/src/main/java/dev/openrs2/asm/InsnNodeUtils.kt index b8278da533..3d9135b7ae 100644 --- a/asm/src/main/java/dev/openrs2/asm/InsnNodeUtils.kt +++ b/asm/src/main/java/dev/openrs2/asm/InsnNodeUtils.kt @@ -265,7 +265,7 @@ val AbstractInsnNode.intConstant: Int? } } -val AbstractInsnNode.sequential: Boolean +val AbstractInsnNode.isSequential: Boolean get() = when (this) { is LabelNode -> false is JumpInsnNode -> false @@ -274,7 +274,7 @@ val AbstractInsnNode.sequential: Boolean else -> opcode !in THROW_RETURN_OPCODES } -val AbstractInsnNode.pure: Boolean +val AbstractInsnNode.isPure: Boolean get() = when (opcode) { in PURE_OPCODES -> true in IMPURE_OPCODES -> false diff --git a/build.gradle.kts b/build.gradle.kts index 6f88b31cad..77fd96f904 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -87,10 +87,10 @@ allprojects { } } -val Project.free: Boolean +val Project.isFree: Boolean get() = name != "nonfree" && parent?.name != "nonfree" -configure(subprojects.filter { it.free }) { +configure(subprojects.filter { it.isFree }) { apply(plugin = "jacoco") plugins.withType { @@ -215,7 +215,7 @@ tasks.dokka { outputDirectory = "${project.buildDir}/kdoc" outputFormat = "html" - subProjects = subprojects.filter { it.free && it.name != "deob-annotations" }.map { it.name } + subProjects = subprojects.filter { it.isFree && it.name != "deob-annotations" }.map { it.name } configuration { includeNonPublic = true 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 0f20e12c0e..6d0ff2c01c 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt @@ -9,8 +9,8 @@ import dev.openrs2.asm.createIntConstant import dev.openrs2.asm.deleteExpression import dev.openrs2.asm.hasCode import dev.openrs2.asm.intConstant +import dev.openrs2.asm.isPure import dev.openrs2.asm.nextReal -import dev.openrs2.asm.pure import dev.openrs2.asm.replaceExpression import dev.openrs2.asm.stackMetadata import dev.openrs2.asm.transform.Transformer @@ -230,13 +230,13 @@ class ConstantArgTransformer : Transformer() { for (insn in alwaysTakenBranches) { val replacement = JumpInsnNode(GOTO, insn.label) - if (method.instructions.replaceExpression(insn, replacement, AbstractInsnNode::pure)) { + if (method.instructions.replaceExpression(insn, replacement, AbstractInsnNode::isPure)) { simplified++ } } for (insn in neverTakenBranches) { - if (method.instructions.deleteExpression(insn, AbstractInsnNode::pure)) { + if (method.instructions.deleteExpression(insn, AbstractInsnNode::isPure)) { simplified++ } } @@ -259,7 +259,7 @@ class ConstantArgTransformer : Transformer() { if (insn.intConstant != null) { // already constant continue - } else if (!insn.pure) { + } else if (!insn.isPure) { // can't replace instructions with a side effect continue } else if (insn.stackMetadata.pushes != 1) { @@ -287,7 +287,7 @@ class ConstantArgTransformer : Transformer() { } val replacement = createIntConstant(value) - if (method.instructions.replaceExpression(insn, replacement, AbstractInsnNode::pure)) { + if (method.instructions.replaceExpression(insn, replacement, AbstractInsnNode::isPure)) { inlined++ } } diff --git a/deob/src/main/java/dev/openrs2/deob/transform/UnusedLocalTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/UnusedLocalTransformer.kt index eabc92b9ed..5f6078a768 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/UnusedLocalTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/UnusedLocalTransformer.kt @@ -4,7 +4,7 @@ import com.github.michaelbull.logging.InlineLogger import dev.openrs2.asm.classpath.ClassPath import dev.openrs2.asm.classpath.Library import dev.openrs2.asm.deleteExpression -import dev.openrs2.asm.pure +import dev.openrs2.asm.isPure import dev.openrs2.asm.transform.Transformer import dev.openrs2.deob.analysis.LiveVariableAnalyzer import org.objectweb.asm.Opcodes @@ -42,7 +42,7 @@ class UnusedLocalTransformer : Transformer() { } for (insn in deadStores) { - if (method.instructions.deleteExpression(insn, AbstractInsnNode::pure)) { + if (method.instructions.deleteExpression(insn, AbstractInsnNode::isPure)) { localsRemoved++ } }