private void ComputeHeader() { int num = 0; Collection <Instruction> instructions = body.instructions; Instruction[] items = instructions.items; int size = instructions.size; int num2 = 0; int max_stack_size = 0; Dictionary <Instruction, int> dictionary = null; if (body.HasExceptionHandlers) { ComputeExceptionHandlerStackSize(ref dictionary); } for (int i = 0; i < size; i++) { Instruction instruction = items[i]; instruction.offset = num; num += instruction.GetSize(); ComputeStackSize(instruction, ref dictionary, ref num2, ref max_stack_size); } body.code_size = num; body.max_stack_size = max_stack_size; }
private void ComputeHeader() { int size = 0; Collection <Instruction> instructions = this.body.instructions; Instruction[] instructionArray = instructions.items; int num = instructions.size; int num1 = 0; int num2 = 0; Dictionary <Instruction, int> instructions1 = null; if (this.body.HasExceptionHandlers) { this.ComputeExceptionHandlerStackSize(ref instructions1); } for (int i = 0; i < num; i++) { Instruction instruction = instructionArray[i]; instruction.offset = size; size += instruction.GetSize(); CodeWriter.ComputeStackSize(instruction, ref instructions1, ref num1, ref num2); } this.body.code_size = size; this.body.max_stack_size = num2; }
private int GetTargetOffset(Instruction instruction) { if (instruction == null) { Instruction instruction2 = body.instructions[body.instructions.size - 1]; return(instruction2.offset + instruction2.GetSize()); } return(instruction.offset); }
private int GetTargetOffset(Instruction instruction) { if (instruction != null) { return(instruction.offset); } Instruction instruction2 = this.body.instructions[this.body.instructions.size - 1]; return(instruction2.offset + instruction2.GetSize()); }
public static int ToNop(ILProcessor ilp, Instruction ins, bool sameSize) { if (ins == null) return 0; int size = ins.GetSize(); ins.OpCode = OpCodes.Nop; ins.Operand = null; if (sameSize) { for (int i = 1; i < size; i++) { Instruction newIns = ilp.Create(OpCodes.Nop); ilp.InsertAfter(ins, newIns); } } else { size = 1; } return size; }
/// <summary> /// Update the offsets of all instructions following the given instruction. /// </summary> private static void ComputeOffsets(Instruction instruction) { var offset = instruction.Offset; while (instruction != null) { instruction.Offset = offset; offset += instruction.GetSize(); instruction = instruction.Next; } }
static int GetLength(Instruction start, Instruction end, InstructionCollection instructions) { Instruction last = instructions [instructions.Count - 1]; return((end == instructions.Outside ? last.Offset + last.GetSize() : end.Offset) - start.Offset); }
protected virtual int readShortInlineBrTarget(Instruction instr) { return currentOffset + instr.GetSize() + reader.ReadSByte(); }
static int getInstructionSize(Instruction instr) { var opcode = instr.OpCode; if (opcode == null) return 5; // Load store/field var op = instr.Operand as SwitchTargetDisplOperand; if (op == null) return instr.GetSize(); return instr.OpCode.Size + (op.targetDisplacements.Length + 1) * 4; }