/// <summary> /// Get the jump target of the branch instruction at index i. /// The resulting InstructionRange will have length 0. /// Use Extend or ExtendBackwards to give it a size. /// The length being 0, ExtendBackwards won't include the instruction being pointed at. /// </summary> public InstructionRange Follow(int i) { var op = insts[start + i].operand; if (op == null || !(op is Label)) { throw new Exception("Expected a branch instruction, got: " + insts[start + i]); } Label lbl = (Label)op; int pos = insts.FindIndex(inst => inst.labels.Contains(lbl)); if (pos < 0) { throw new Exception($"Label not found: LBL_{lbl.GetHashCode()}"); } var res = new InstructionRange(insts, pos, 0); // Hack.Log($"Jump points to {pos}:"); return(res); }
public void ExtendBackwards(InstructionRange ext) { length = start + length - ext.start; start = ext.start; }
public void Extend(InstructionRange ext) { length = ext.start + ext.length - start; }