コード例 #1
0
 public ILInstruction(OpCode opcode, object argument, Type argumentType, ILInstructionType instructionType = ILInstructionType.OpCode)
 {
     OpCode          = opcode;
     Argument        = argument;
     ArgumentType    = argumentType;
     InstructionType = instructionType;
 }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
 public ILInstruction(
     int offset,
     ILInstructionType type,
     ILInstructionFlagsContext flagsContext,
     ushort popCount,
     ushort pushCount,
     object argument)
     : this(offset, type, flagsContext, popCount, pushCount, argument, null)
 {
 }
コード例 #4
0
ファイル: Disassembler.cs プロジェクト: m4rs-mt/ILGPU
 /// <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);
コード例 #5
0
 /// <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));
 }
コード例 #6
0
ファイル: ILInstruction.cs プロジェクト: m4rs-mt/ILGPU
 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;
 }
コード例 #7
0
 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;
 }
コード例 #8
0
 public ILInstruction(
     int offset,
     ILInstructionType type,
     ILInstructionFlagsContext flagsContext,
     ushort popCount,
     ushort pushCount,
     object argument)
     : this(
         offset,
         type,
         flagsContext,
         popCount,
         pushCount,
         argument,
         SequencePoint.Invalid)
 {
 }
コード例 #9
0
        /// <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);
        }
コード例 #10
0
ファイル: il's.cs プロジェクト: JimmyJune/il2js
		public ILInstruction(int nextInstructionPosition, ILInstructionType type, params string[] args) {
			this.Type = type;
			this.Arguments = args;
			this.NextInstructionPosition = nextInstructionPosition;
		}
コード例 #11
0
ファイル: MethodCompiler.cs プロジェクト: JimmyJune/il2js
 protected LinkedListNode<ILInstruction> Instructions_Add(ILInstructionType type, params string[] args)
 {
     return this._Instructions.AddLast(new ILInstruction(this.Position, type, args));
 }