Replace Guava's ImmutableSet with Kotlin's Set type

master
Graham 5 years ago
parent 5fa44c9016
commit 8aa3a79166
  1. 2
      deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.kt
  2. 9
      deob/src/main/java/dev/openrs2/deob/analysis/IntValue.java
  3. 12
      deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.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<ImmutableSet<Int>?>?) : Interpreter<IntValue>(Opcodes.ASM7) {
class IntInterpreter(private val parameters: Array<Set<Int>?>?) : Interpreter<IntValue>(Opcodes.ASM7) {
private val basicInterpreter = BasicInterpreter()
override fun newValue(type: Type?): IntValue? {

@ -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<Integer> intValues) {
public static IntValue newConstant(BasicValue basicValue, Set<Integer> 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<Integer> intValues;
private final Set<Integer> intValues;
private IntValue(BasicValue basicValue, ImmutableSet<Integer> intValues) {
private IntValue(BasicValue basicValue, Set<Integer> intValues) {
this.basicValue = basicValue;
this.intValues = intValues;
}
@ -49,7 +50,7 @@ public final class IntValue implements Value {
return intValues.iterator().next();
}
public ImmutableSet<Integer> getIntValues() {
public Set<Integer> getIntValues() {
Preconditions.checkArgument(!isUnknown());
return intValues;
}

@ -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<ArgRef, SourcedIntValue> = HashMultimap.create()
private val conditionalCalls: Multimap<DisjointSet.Partition<MemberRef>?, ConditionalCall> = HashMultimap.create()
private val constArgs = mutableMapOf<DisjointSet.Partition<MemberRef>, Array<ImmutableSet<Int>?>>()
private val constArgs = mutableMapOf<DisjointSet.Partition<MemberRef>, Array<Set<Int>?>>()
private lateinit var inheritedMethodSets: DisjointSet<MemberRef>
private var branchesSimplified = 0
private var constantsInlined = 0
@ -103,8 +102,8 @@ class DummyArgTransformer : Transformer() {
method: DisjointSet.Partition<MemberRef>,
arg: Int,
intValues: Collection<SourcedIntValue>
): ImmutableSet<Int>? {
val builder = ImmutableSet.builder<Int>()
): Set<Int>? {
val set = mutableSetOf<Int>()
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<ImmutableSet<Int>?>(args)
val parameters = arrayOfNulls<Set<Int>?>(args)
for (i in 0 until args) {
val parameter = union(method, i, argValues[ArgRef(method, i)])

Loading…
Cancel
Save