This commit is contained in:
Adam
2016-04-14 18:38:31 -04:00
parent 7ed4db9d5c
commit ad4352ec4e

View File

@@ -1,5 +1,6 @@
package net.runelite.deob.deobfuscators;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -17,14 +18,14 @@ import net.runelite.asm.attributes.code.instructions.Goto;
import net.runelite.asm.attributes.code.instructions.If;
import net.runelite.asm.attributes.code.instructions.New;
import net.runelite.asm.execution.Execution;
import net.runelite.asm.execution.Frame;
import net.runelite.asm.execution.InstructionContext;
import net.runelite.asm.execution.MethodContext;
public class IllegalStateExceptions implements Deobfuscator
{
private int count;
private Set<Instruction> interesting = new HashSet<>();
private InstructionContext currentInstruction;
private List<InstructionContext> toRemove = new ArrayList<>();
/* find if, new, ..., athrow, replace with goto */
private void findInteresting(ClassGroup group)
@@ -66,24 +67,25 @@ public class IllegalStateExceptions implements Deobfuscator
{
if (interesting.contains(ic.getInstruction()))
{
assert currentInstruction == null;
currentInstruction = ic;
toRemove.add(ic);
}
}
private void visit(Frame f)
private void visit(MethodContext ctx)
{
if (currentInstruction == null)
return;
processOne(currentInstruction);
currentInstruction = null;
for (InstructionContext ictx : toRemove)
processOne(ictx);
toRemove.clear();
}
private void processOne(InstructionContext ic)
{
Instruction ins = ic.getInstruction();
Instructions instructions = ins.getInstructions();
if (instructions == null)
return;
List<Instruction> ilist = instructions.getInstructions();
JumpingInstruction jumpIns = (JumpingInstruction) ins;
@@ -132,11 +134,9 @@ public class IllegalStateExceptions implements Deobfuscator
Execution execution = new Execution(group);
execution.addExecutionVisitor(i -> visit(i));
execution.addFrameVisitor(i -> visit(i));
execution.addMethodContextVisitor(i -> visit(i));
execution.populateInitialMethods();
execution.run();
assert currentInstruction == null;
System.out.println("Removed " + count + " illegal state exceptions");
}