/// <summary> /// Creates a new instruction with the given opcode. /// </summary> /// <param name="opcode">Opcode</param> public MsilInstruction(OpCode opcode) { OpCode = opcode; switch (opcode.OperandType) { case OperandType.InlineNone: Operand = null; break; case OperandType.ShortInlineBrTarget: case OperandType.InlineBrTarget: Operand = new MsilOperandBrTarget(this); break; case OperandType.InlineField: Operand = new MsilOperandInline.MsilOperandReflected <FieldInfo>(this); break; case OperandType.ShortInlineI: case OperandType.InlineI: Operand = new MsilOperandInline.MsilOperandInt32(this); break; case OperandType.InlineI8: Operand = new MsilOperandInline.MsilOperandInt64(this); break; case OperandType.InlineMethod: Operand = new MsilOperandInline.MsilOperandReflected <MethodBase>(this); break; case OperandType.InlineR: Operand = new MsilOperandInline.MsilOperandDouble(this); break; case OperandType.InlineSig: Operand = new MsilOperandInline.MsilOperandSignature(this); break; case OperandType.InlineString: Operand = new MsilOperandInline.MsilOperandString(this); break; case OperandType.InlineSwitch: Operand = new MsilOperandSwitch(this); break; case OperandType.InlineTok: Operand = new MsilOperandInline.MsilOperandReflected <MemberInfo>(this); break; case OperandType.InlineType: Operand = new MsilOperandInline.MsilOperandReflected <Type>(this); break; case OperandType.ShortInlineVar: case OperandType.InlineVar: if (OpCode.IsLocalStore() || OpCode.IsLocalLoad() || OpCode.IsLocalLoadByRef()) { Operand = new MsilOperandInline.MsilOperandLocal(this); } else { Operand = new MsilOperandInline.MsilOperandArgument(this); } break; case OperandType.ShortInlineR: Operand = new MsilOperandInline.MsilOperandSingle(this); break; #pragma warning disable 618 case OperandType.InlinePhi: #pragma warning restore 618 default: throw new ArgumentOutOfRangeException(); } }