public static int IdentifyJumpOrReturn(BytecodeInstruction bci) { int op = (int)bci.opcode; if (op > 68 && op <= 72) //return op { return(0); } if (op == 84) //JMP { return(1); } if (op >= 0 && op <= 15) //comparison op { return(3); } if (op > 72 && op <= 82) //for loop or iterator loop { return(4); } if (op == 48) //UCLO { return(5); } return(-1); //not jump or return. }
/// <summary> /// Contains an IRMap translated opcode and the registers at execution time for a particular bytecode instruction. /// </summary> /// <param name="iROp"></param> /// <param name="originalOp"></param> /// <param name="originalIndex">Index of original instruction.</param> /// <param name="regA"></param> /// <param name="regB"></param> /// <param name="regC"></param> public IntegratedInstruction(IRMap iROp, BytecodeInstruction bci) { this.bci = bci; this.iROp = iROp; registers = bci.regs; originalOp = bci.opcode; originalIndex = bci.index; }
private BytecodeInstruction GetJumpInstruction(int index) { BytecodeInstruction bci = bytecodeInstructions[index]; if (DecompilePrototype.IdentifyJumpOrReturn(bci) <= 0) { return(null); } return(bci); }
private void AddTopOfFileJump() { BytecodeInstruction jmpTop = new BytecodeInstruction(OpCodes.JMP, -1); jmpTop.registers.a = 0; jmpTop.registers.c = 0; jmpTop.registers.b = 128; Jump top = new Jump(jmpTop, 1, -1, pt); jumps.Add(top); }
public Jump(BytecodeInstruction jmp, int jumpType, int nameIndex, Prototype pt) { index = jmp.bciIndexInPrototype; this.jumpType = jumpType; if (jumpType == 1) //calculate jump distance. may be negative. { distance = ((jmp.registers.b << 8) | jmp.registers.c) - 0x8000; } else if (jumpType == 3) { distance = 1; //conditionals/returns } target = index + distance + 1; //the target bci. }
public Comparison(LStateContext ctx, BytecodeInstruction bci) { this.ctx = ctx; this.bci = bci; }
/// <summary> /// (A op B) /// Example: (A == 2) /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <param name="op"></param> public Condition(Prototype pt, BytecodeInstruction condi) { //this.a = a; //this.b = b; op = map[condi.opcode]; }