Build jump graph

This commit is contained in:
Adam
2014-12-01 12:16:51 -05:00
parent 44f018727f
commit df28895fc8
7 changed files with 74 additions and 2 deletions

View File

@@ -1,11 +1,17 @@
package info.sigterm.deob.attributes.code;
import java.util.ArrayList;
public class Instruction
{
private Instructions instructions;
private InstructionType type;
private int pc;
protected int length = 1;
private int pc; // offset into method this instructions resides at
protected int length = 1; // length of this instruction
private ArrayList<Instruction> jump = new ArrayList<Instruction>(); // instructions which this instruction jumps to
private ArrayList<Instruction> from = new ArrayList<Instruction>(); // instructions which jump to this instruction
public Instruction(Instructions instructions, InstructionType type, int pc)
{
@@ -14,8 +20,27 @@ public class Instruction
this.pc = pc;
}
public int getPc()
{
return pc;
}
public int getLength()
{
return length;
}
protected void addJump(int offset)
{
Instruction other = instructions.findInstruction(pc + offset);
assert other != null;
assert other != this;
this.jump.add(other);
other.from.add(this);
}
public void buildJumpGraph()
{
}
}