From b7347b2632d4ed2cedf027b6b7c6bdb5d90db41b Mon Sep 17 00:00:00 2001 From: Graham Date: Fri, 30 Aug 2019 19:20:38 +0100 Subject: [PATCH] Move ArgRef to the top level I'm going to use it in another Transformer. --- .../main/java/dev/openrs2/deob/ArgRef.java | 42 +++++++++++++++++++ .../deob/transform/DummyArgTransformer.java | 30 +------------ 2 files changed, 43 insertions(+), 29 deletions(-) create mode 100644 deob/src/main/java/dev/openrs2/deob/ArgRef.java diff --git a/deob/src/main/java/dev/openrs2/deob/ArgRef.java b/deob/src/main/java/dev/openrs2/deob/ArgRef.java new file mode 100644 index 0000000000..e4fc98f82f --- /dev/null +++ b/deob/src/main/java/dev/openrs2/deob/ArgRef.java @@ -0,0 +1,42 @@ +package dev.openrs2.deob; + +import java.util.Objects; + +import dev.openrs2.asm.MemberRef; +import dev.openrs2.util.collect.DisjointSet; + +public final class ArgRef { + private final DisjointSet.Partition method; + private final int arg; + + public ArgRef(DisjointSet.Partition method, int arg) { + this.method = method; + this.arg = arg; + } + + public DisjointSet.Partition getMethod() { + return method; + } + + public int getArg() { + return arg; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArgRef argRef = (ArgRef) o; + return arg == argRef.arg && + method.equals(argRef.method); + } + + @Override + public int hashCode() { + return Objects.hash(method, arg); + } +} diff --git a/deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.java b/deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.java index 45f46e4f75..8212ea6628 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.java +++ b/deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Map; -import java.util.Objects; import java.util.Set; import com.google.common.base.Preconditions; @@ -16,6 +15,7 @@ import dev.openrs2.asm.MemberRef; import dev.openrs2.asm.StackMetadata; import dev.openrs2.asm.classpath.ClassPath; import dev.openrs2.asm.transform.Transformer; +import dev.openrs2.deob.ArgRef; import dev.openrs2.deob.analysis.IntInterpreter; import dev.openrs2.deob.analysis.IntValue; import dev.openrs2.util.collect.DisjointSet; @@ -34,34 +34,6 @@ import org.slf4j.LoggerFactory; public final class DummyArgTransformer extends Transformer { private static final Logger logger = LoggerFactory.getLogger(DummyArgTransformer.class); - private static final class ArgRef { - private final DisjointSet.Partition method; - private final int arg; - - public ArgRef(DisjointSet.Partition method, int arg) { - this.method = method; - this.arg = arg; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ArgRef argRef = (ArgRef) o; - return arg == argRef.arg && - method.equals(argRef.method); - } - - @Override - public int hashCode() { - return Objects.hash(method, arg); - } - } - private enum BranchResult { ALWAYS_TAKEN, NEVER_TAKEN,