From 8aa3a791662d402e9db5f6a5941a68103f15cc1b Mon Sep 17 00:00:00 2001 From: Graham Date: Thu, 26 Dec 2019 11:15:02 +0000 Subject: [PATCH] Replace Guava's ImmutableSet with Kotlin's Set type --- .../java/dev/openrs2/deob/analysis/IntInterpreter.kt | 2 +- .../java/dev/openrs2/deob/analysis/IntValue.java | 9 +++++---- .../openrs2/deob/transform/DummyArgTransformer.kt | 12 +++++------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.kt b/deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.kt index 1d3022a3f0..daca06853a 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.kt +++ b/deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.kt @@ -11,7 +11,7 @@ import org.objectweb.asm.tree.analysis.AnalyzerException import org.objectweb.asm.tree.analysis.BasicInterpreter import org.objectweb.asm.tree.analysis.Interpreter -class IntInterpreter(private val parameters: Array?>?) : Interpreter(Opcodes.ASM7) { +class IntInterpreter(private val parameters: Array?>?) : Interpreter(Opcodes.ASM7) { private val basicInterpreter = BasicInterpreter() override fun newValue(type: Type?): IntValue? { diff --git a/deob/src/main/java/dev/openrs2/deob/analysis/IntValue.java b/deob/src/main/java/dev/openrs2/deob/analysis/IntValue.java index e539d369bb..986fb5cb24 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/IntValue.java +++ b/deob/src/main/java/dev/openrs2/deob/analysis/IntValue.java @@ -1,6 +1,7 @@ package dev.openrs2.deob.analysis; import java.util.Objects; +import java.util.Set; import com.google.common.base.MoreObjects; import com.google.common.base.Preconditions; @@ -13,7 +14,7 @@ public final class IntValue implements Value { return newConstant(basicValue, ImmutableSet.of(intValue)); } - public static IntValue newConstant(BasicValue basicValue, ImmutableSet intValues) { + public static IntValue newConstant(BasicValue basicValue, Set intValues) { Preconditions.checkArgument(basicValue == BasicValue.INT_VALUE); Preconditions.checkArgument(!intValues.isEmpty()); return new IntValue(basicValue, intValues); @@ -25,9 +26,9 @@ public final class IntValue implements Value { } private final BasicValue basicValue; - private final ImmutableSet intValues; + private final Set intValues; - private IntValue(BasicValue basicValue, ImmutableSet intValues) { + private IntValue(BasicValue basicValue, Set intValues) { this.basicValue = basicValue; this.intValues = intValues; } @@ -49,7 +50,7 @@ public final class IntValue implements Value { return intValues.iterator().next(); } - public ImmutableSet getIntValues() { + public Set getIntValues() { Preconditions.checkArgument(!isUnknown()); return intValues; } diff --git a/deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.kt index c3e98b757b..5aa698baeb 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.kt @@ -2,7 +2,6 @@ package dev.openrs2.deob.transform import com.github.michaelbull.logging.InlineLogger import com.google.common.collect.HashMultimap -import com.google.common.collect.ImmutableSet import com.google.common.collect.Multimap import dev.openrs2.asm.* import dev.openrs2.asm.classpath.ClassPath @@ -45,7 +44,7 @@ class DummyArgTransformer : Transformer() { private val argValues: Multimap = HashMultimap.create() private val conditionalCalls: Multimap?, ConditionalCall> = HashMultimap.create() - private val constArgs = mutableMapOf, Array?>>() + private val constArgs = mutableMapOf, Array?>>() private lateinit var inheritedMethodSets: DisjointSet private var branchesSimplified = 0 private var constantsInlined = 0 @@ -103,8 +102,8 @@ class DummyArgTransformer : Transformer() { method: DisjointSet.Partition, arg: Int, intValues: Collection - ): ImmutableSet? { - val builder = ImmutableSet.builder() + ): Set? { + val set = mutableSetOf() for ((source, intValue) in intValues) { if (intValue.isUnknown) { @@ -121,10 +120,9 @@ class DummyArgTransformer : Transformer() { } } - builder.addAll(intValue.intValues) + set.addAll(intValue.intValues) } - val set = builder.build() return if (set.isEmpty()) { null } else { @@ -319,7 +317,7 @@ class DummyArgTransformer : Transformer() { val args = (Type.getArgumentsAndReturnSizes(method.first().desc) shr 2) - 1 var allUnknown = true - val parameters = arrayOfNulls?>(args) + val parameters = arrayOfNulls?>(args) for (i in 0 until args) { val parameter = union(method, i, argValues[ArgRef(method, i)])