public ILInstruction(OpCode opcode, object argument, Type argumentType, ILInstructionType instructionType = ILInstructionType.OpCode) { OpCode = opcode; Argument = argument; ArgumentType = argumentType; InstructionType = instructionType; }
/// <summary> /// Disassembles a call to the given method. /// </summary> /// <param name="type">The instruction type.</param> /// <param name="methodToken">The token of the method to be disassembled.</param> private void DisassembleCall(ILInstructionType type, int methodToken) { var method = ResolveMethod(methodToken); var popCount = method.GetParameters().Length; var methodInfo = method as MethodInfo; int pushCount = 0; if (methodInfo != null) { popCount += method.GetParameterOffset(); if (methodInfo.ReturnType != typeof(void)) { pushCount = 1; } } else if (method is ConstructorInfo) { if (type == ILInstructionType.Newobj) { // We have to push the new object pushCount += 1; } else { Debug.Assert(type == ILInstructionType.Call, "Invalid constructor call"); popCount += 1; } } AppendInstruction(type, (ushort)popCount, (ushort)pushCount, method); }
public ILInstruction( int offset, ILInstructionType type, ILInstructionFlagsContext flagsContext, ushort popCount, ushort pushCount, object argument) : this(offset, type, flagsContext, popCount, pushCount, argument, null) { }
/// <summary> /// Appends an instruction to the current instruction list. /// </summary> /// <param name="type">The instruction type.</param> /// <param name="popCount"> /// The number of elements to pop from the stack. /// </param> /// <param name="pushCount"> /// The number of elements to push onto the stack. /// </param> /// <param name="argument">The argument of the instruction.</param> private void AppendInstruction( ILInstructionType type, ushort popCount, ushort pushCount, object argument = null) => AppendInstructionWithFlags( type, popCount, pushCount, ILInstructionFlags.None, argument);
/// <summary> /// Appends an instruction to the current instruction list. /// </summary> /// <param name="type">The instruction type.</param> /// <param name="popCount">The number of elements to pop from the stack.</param> /// <param name="pushCount">The number of elements to push onto the stack.</param> /// <param name="additionalFlags">Additional instruction flags.</param> /// <param name="argument">The argument of the instruction.</param> private void AppendInstructionWithFlags( ILInstructionType type, ushort popCount, ushort pushCount, ILInstructionFlags additionalFlags, object argument = null) { // Merge with current flags instructions.Add(new ILInstruction( instructionOffset, type, new ILInstructionFlagsContext(additionalFlags | flags, flagsArgument), popCount, pushCount, argument, CurrentSequencePoint)); }
public ILInstruction( int offset, ILInstructionType type, ILInstructionFlagsContext flagsContext, ushort popCount, ushort pushCount, object argument, Location location) { Offset = offset; InstructionType = type; FlagsContext = flagsContext; PopCount = popCount; PushCount = pushCount; Argument = argument; Location = location ?? Location.Unknown; }
public ILInstruction( int offset, ILInstructionType type, ILInstructionFlagsContext flagsContext, ushort popCount, ushort pushCount, object argument, SequencePoint sequencePoint) { Offset = offset; InstructionType = type; FlagsContext = flagsContext; PopCount = popCount; PushCount = pushCount; Argument = argument; SequencePoint = sequencePoint; }
public ILInstruction( int offset, ILInstructionType type, ILInstructionFlagsContext flagsContext, ushort popCount, ushort pushCount, object argument) : this( offset, type, flagsContext, popCount, pushCount, argument, SequencePoint.Invalid) { }
/// <summary> /// Disassembles a call to the given method. /// </summary> /// <param name="type">The instruction type.</param> /// <param name="methodToken">The token of the method to be disassembled.</param> private void DisassembleCall(ILInstructionType type, int methodToken) { var method = ResolveMethod(methodToken); var popCount = method.GetParameters().Length; var methodInfo = method as MethodInfo; int pushCount = 0; if (methodInfo != null) { popCount += method.GetParameterOffset(); if (methodInfo.ReturnType != typeof(void)) { pushCount = 1; } } else if (method is ConstructorInfo) { pushCount = 1; } AppendInstruction(type, (ushort)popCount, (ushort)pushCount, method); }
public ILInstruction(int nextInstructionPosition, ILInstructionType type, params string[] args) { this.Type = type; this.Arguments = args; this.NextInstructionPosition = nextInstructionPosition; }
protected LinkedListNode<ILInstruction> Instructions_Add(ILInstructionType type, params string[] args) { return this._Instructions.AddLast(new ILInstruction(this.Position, type, args)); }