Test seems promising

This commit is contained in:
Adam
2015-12-13 12:39:48 -05:00
parent 69600fbf4e
commit 5ca2e373f5
16 changed files with 248 additions and 5 deletions

View File

@@ -32,7 +32,7 @@ public abstract class Instruction implements Cloneable
public String toString()
{
Method m = this.getInstructions().getCode().getAttributes().getMethod();
return super.toString() + " in " + m + " at pc " + this.getPc();
return super.toString() + " in " + m + " at pc 0x" + Integer.toHexString(this.getPc());
}
@Override

View File

@@ -5,7 +5,7 @@ import java.util.List;
import net.runelite.deob.Method;
import net.runelite.deob.pool.PoolEntry;
public interface InvokeInstruction
public interface InvokeInstruction extends MappableInstruction
{
public void removeParameter(int idx);

View File

@@ -0,0 +1,8 @@
package net.runelite.deob.attributes.code.instruction.types;
import net.runelite.deob.execution.InstructionContext;
public interface MappableInstruction
{
void map(InstructionContext ctx, InstructionContext other);
}

View File

@@ -1,5 +1,5 @@
package net.runelite.deob.attributes.code.instruction.types;
public interface SetFieldInstruction extends FieldInstruction
public interface SetFieldInstruction extends FieldInstruction, MappableInstruction
{
}

View File

@@ -22,6 +22,12 @@ public class Goto extends Instruction implements JumpingInstruction
{
super(instructions, type, pc);
}
@Override
public String toString()
{
return "goto " + to + " (at pc " + (this.getPc() + offset) + ")";
}
public Goto(Instructions instructions, Instruction to)
{

View File

@@ -15,8 +15,9 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import net.runelite.deob.attributes.code.instruction.types.MappableInstruction;
public class If extends Instruction implements JumpingInstruction, ComparisonInstruction
public abstract class If extends Instruction implements JumpingInstruction, ComparisonInstruction, MappableInstruction
{
private Instruction to;
private short offset;
@@ -93,4 +94,29 @@ public class If extends Instruction implements JumpingInstruction, ComparisonIns
{
return Arrays.asList(to);
}
@Override
public final/*XXX tmp*/ void map(InstructionContext ctx, InstructionContext other)
{
InstructionContext oneLhs = ctx.getPops().get(0).getPushed().resolve(ctx.getPops().get(0)),
oneRhs = ctx.getPops().get(1).getPushed().resolve(ctx.getPops().get(1)),
twoLhs = other.getPops().get(0).getPushed().resolve(other.getPops().get(0)),
twoRhs = other.getPops().get(1).getPushed().resolve(other.getPops().get(1));
assert ctx.getInstruction().getClass().equals(other.getInstruction().getClass());
Frame branch1 = ctx.getBranches().get(0),
branch2 = other.getBranches().get(0);
assert branch1.other == null;
assert branch2.other == null;
branch1.other = branch2;
branch2.other = branch1;
// we can map these if they are getfield instructions?
//
}
}

View File

@@ -15,8 +15,9 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import net.runelite.deob.attributes.code.instruction.types.MappableInstruction;
public class If0 extends Instruction implements JumpingInstruction, ComparisonInstruction
public abstract class If0 extends Instruction implements JumpingInstruction, ComparisonInstruction, MappableInstruction
{
private Instruction to;
private short offset;
@@ -94,4 +95,24 @@ public class If0 extends Instruction implements JumpingInstruction, ComparisonIn
{
return Arrays.asList(to);
}
@Override
public final/*XXX tmp*/ void map(InstructionContext ctx, InstructionContext other)
{
InstructionContext one = ctx.getPops().get(0).getPushed().resolve(ctx.getPops().get(0)),
two = other.getPops().get(0).getPushed().resolve(other.getPops().get(0));
// we can map these if they are getfield instructions?
assert ctx.getInstruction().getClass().equals(other.getInstruction().getClass());
Frame branch1 = ctx.getBranches().get(0),
branch2 = other.getBranches().get(0);
assert branch1.other == null;
assert branch2.other == null;
branch1.other = branch2;
branch2.other = branch1;
}
}

View File

@@ -157,4 +157,11 @@ public class InvokeInterface extends Instruction implements InvokeInstruction
if (myMethods != null && !myMethods.isEmpty())
method = myMethods.get(0).getPoolInterfaceMethod(); // is this right?
}
@Override
public void map(InstructionContext ctx, InstructionContext other)
{
List<net.runelite.deob.Method> myMethods = this.getMethods(),
otherMethods = ((InvokeInterface) other.getInstruction()).getMethods();
}
}

View File

@@ -150,4 +150,11 @@ public class InvokeSpecial extends Instruction implements InvokeInstruction
if (myMethods != null && !myMethods.isEmpty())
method = myMethods.get(0).getPoolMethod();
}
@Override
public void map(InstructionContext ctx, InstructionContext other)
{
List<net.runelite.deob.Method> myMethods = this.getMethods(),
otherMethods = ((InvokeSpecial) other.getInstruction()).getMethods();
}
}

View File

@@ -160,4 +160,11 @@ public class InvokeStatic extends Instruction implements InvokeInstruction
if (myMethods != null && !myMethods.isEmpty())
method = myMethods.get(0).getPoolMethod();
}
@Override
public void map(InstructionContext ctx, InstructionContext other)
{
List<net.runelite.deob.Method> myMethods = this.getMethods(),
otherMethods = ((InvokeStatic) other.getInstruction()).getMethods();
}
}

View File

@@ -161,4 +161,11 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction
if (myMethods != null && !myMethods.isEmpty())
method = myMethods.get(0).getPoolMethod(); // is this right?
}
@Override
public void map(InstructionContext ctx, InstructionContext other)
{
List<net.runelite.deob.Method> myMethods = this.getMethods(),
otherMethods = ((InvokeVirtual) other.getInstruction()).getMethods();
}
}

View File

@@ -94,4 +94,13 @@ public class PutField extends Instruction implements SetFieldInstruction
if (myField != null)
field = myField.getPoolField();
}
@Override
public void map(InstructionContext ctx, InstructionContext other)
{
net.runelite.deob.Field myField = this.getMyField(),
otherField = ((PutField) other.getInstruction()).getMyField();
System.out.println("MAPPING " + myField + " -> " + otherField);
}
}

View File

@@ -93,4 +93,13 @@ public class PutStatic extends Instruction implements SetFieldInstruction
if (myField != null)
field = myField.getPoolField();
}
@Override
public void map(InstructionContext ctx, InstructionContext other)
{
net.runelite.deob.Field myField = this.getMyField(),
otherField = ((PutStatic) other.getInstruction()).getMyField();
System.out.println("MAPPING " + myField + " -> " + otherField);
}
}

View File

@@ -11,6 +11,7 @@ import net.runelite.deob.attributes.code.Instruction;
import net.runelite.deob.attributes.code.Instructions;
import net.runelite.deob.pool.NameAndType;
import net.runelite.deob.attributes.code.instruction.types.InvokeInstruction;
import net.runelite.deob.attributes.code.instruction.types.MappableInstruction;
import net.runelite.deob.attributes.code.instruction.types.ReturnInstruction;
import net.runelite.deob.attributes.code.instruction.types.SetFieldInstruction;
import net.runelite.deob.attributes.code.instructions.AThrow;
@@ -28,6 +29,7 @@ public class Frame
private MethodContext ctx;
protected Method nonStatic; // next non static method up the stack
private Frame caller;
public Frame other; // in the other execution for mapping
public Frame(Execution execution, Method method)
{
@@ -44,6 +46,12 @@ public class Frame
ctx = new MethodContext(execution);
nonStatic = method;
}
@Override
public String toString()
{
return "Frame{" + "cur=" + cur + '}';
}
public void initialize()
{
@@ -219,6 +227,12 @@ public class Frame
{
/* jump */
}
if (oldCur instanceof MappableInstruction)
{
execution.paused = true;
return;
}
}
}

View File

@@ -98,6 +98,11 @@ public class InstructionContext
{
return invokes;
}
public List<Frame> getBranches()
{
return branches;
}
public List<StackContext> removeStack(int idx)
{