|
|
@ -1,6 +1,5 @@ |
|
|
|
package dev.openrs2.deob.transform; |
|
|
|
package dev.openrs2.deob.transform; |
|
|
|
|
|
|
|
|
|
|
|
import com.google.common.collect.ImmutableSet; |
|
|
|
|
|
|
|
import dev.openrs2.asm.InsnNodeUtils; |
|
|
|
import dev.openrs2.asm.InsnNodeUtils; |
|
|
|
import dev.openrs2.asm.classpath.ClassPath; |
|
|
|
import dev.openrs2.asm.classpath.ClassPath; |
|
|
|
import dev.openrs2.asm.transform.Transformer; |
|
|
|
import dev.openrs2.asm.transform.Transformer; |
|
|
@ -14,24 +13,6 @@ import org.slf4j.LoggerFactory; |
|
|
|
public final class DummyLocalTransformer extends Transformer { |
|
|
|
public final class DummyLocalTransformer extends Transformer { |
|
|
|
private static final Logger logger = LoggerFactory.getLogger(DummyLocalTransformer.class); |
|
|
|
private static final Logger logger = LoggerFactory.getLogger(DummyLocalTransformer.class); |
|
|
|
|
|
|
|
|
|
|
|
private static final int TYPES = 5; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final ImmutableSet<Integer> LOAD_OPCODES = ImmutableSet.of( |
|
|
|
|
|
|
|
Opcodes.ILOAD, |
|
|
|
|
|
|
|
Opcodes.LLOAD, |
|
|
|
|
|
|
|
Opcodes.FLOAD, |
|
|
|
|
|
|
|
Opcodes.DLOAD, |
|
|
|
|
|
|
|
Opcodes.ALOAD |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final ImmutableSet<Integer> STORE_OPCODES = ImmutableSet.of( |
|
|
|
|
|
|
|
Opcodes.ISTORE, |
|
|
|
|
|
|
|
Opcodes.LSTORE, |
|
|
|
|
|
|
|
Opcodes.FSTORE, |
|
|
|
|
|
|
|
Opcodes.DSTORE, |
|
|
|
|
|
|
|
Opcodes.ASTORE |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int localsRemoved; |
|
|
|
private int localsRemoved; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -47,28 +28,30 @@ public final class DummyLocalTransformer extends Transformer { |
|
|
|
* forward data flow), however, it seems to be good enough to catch |
|
|
|
* forward data flow), however, it seems to be good enough to catch |
|
|
|
* most dummy locals. |
|
|
|
* most dummy locals. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
var loads = new boolean[TYPES][method.maxLocals]; |
|
|
|
var loads = new boolean[method.maxLocals]; |
|
|
|
|
|
|
|
|
|
|
|
for (var it = method.instructions.iterator(); it.hasNext(); ) { |
|
|
|
for (var it = method.instructions.iterator(); it.hasNext(); ) { |
|
|
|
var insn = it.next(); |
|
|
|
var insn = it.next(); |
|
|
|
|
|
|
|
|
|
|
|
var opcode = insn.getOpcode(); |
|
|
|
var opcode = insn.getOpcode(); |
|
|
|
if (LOAD_OPCODES.contains(opcode)) { |
|
|
|
if (opcode != Opcodes.ILOAD) { |
|
|
|
var type = opcode - Opcodes.ILOAD; |
|
|
|
continue; |
|
|
|
var load = (VarInsnNode) insn; |
|
|
|
|
|
|
|
loads[type][load.var] = true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var load = (VarInsnNode) insn; |
|
|
|
|
|
|
|
loads[load.var] = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (var it = method.instructions.iterator(); it.hasNext(); ) { |
|
|
|
for (var it = method.instructions.iterator(); it.hasNext(); ) { |
|
|
|
var insn = it.next(); |
|
|
|
var insn = it.next(); |
|
|
|
|
|
|
|
|
|
|
|
var opcode = insn.getOpcode(); |
|
|
|
var opcode = insn.getOpcode(); |
|
|
|
if (!STORE_OPCODES.contains(opcode)) { |
|
|
|
if (opcode != Opcodes.ISTORE) { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var type = opcode - Opcodes.ISTORE; |
|
|
|
|
|
|
|
var store = (VarInsnNode) insn; |
|
|
|
var store = (VarInsnNode) insn; |
|
|
|
if (loads[type][store.var]) { |
|
|
|
if (loads[store.var]) { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|