Mono.Cecil.Cil.Instruction.GetSize C# (CSharp) Method

GetSize() public method

public GetSize ( ) : int
return int
        public int GetSize()
        {
            int size = opcode.Size;

            switch (opcode.OperandType) {
            case OperandType.InlineSwitch:
                return size + (1 + ((Instruction []) operand).Length) * 4;
            case OperandType.InlineI8:
            case OperandType.InlineR:
                return size + 8;
            case OperandType.InlineBrTarget:
            case OperandType.InlineField:
            case OperandType.InlineI:
            case OperandType.InlineMethod:
            case OperandType.InlineString:
            case OperandType.InlineTok:
            case OperandType.InlineType:
            case OperandType.ShortInlineR:
            case OperandType.InlineSig:
                return size + 4;
            case OperandType.InlineArg:
            case OperandType.InlineVar:
                return size + 2;
            case OperandType.ShortInlineBrTarget:
            case OperandType.ShortInlineI:
            case OperandType.ShortInlineArg:
            case OperandType.ShortInlineVar:
                return size + 1;
            default:
                return size;
            }
        }

Usage Example

Esempio n. 1
0
        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;
        }
All Usage Examples Of Mono.Cecil.Cil.Instruction::GetSize