Exemplo n.º 1
0
        public static object GetRtObject(ITokenOperand memberRef)
        {
            if (memberRef == null)
            {
                return(null);
            }
            var tdr = memberRef as ITypeDefOrRef;

            if (tdr != null)
            {
                return(GetRtType(tdr));
            }
            var field = memberRef as IField;

            if (field != null && field.FieldSig != null)
            {
                return(GetRtField(field));
            }
            var method = memberRef as IMethod;

            if (method != null && method.MethodSig != null)
            {
                return(GetRtMethod(method));
            }

            throw new ApplicationException(string.Format("Unknown MemberRef: {0}", memberRef));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a new instruction with a token operand
 /// </summary>
 /// <param name="opCode">The opcode</param>
 /// <param name="token">The token</param>
 /// <returns>A new <see cref="Instruction"/> instance</returns>
 public static Instruction Create(OpCode opCode, ITokenOperand token)
 {
     if (opCode.OperandType != OperandType.InlineTok)
     {
         throw new ArgumentException("Opcode does not have a token operand", "opCode");
     }
     return(new Instruction(opCode, token));
 }
Exemplo n.º 3
0
        public static object GetRtObject(ITokenOperand memberRef)
        {
            if (memberRef == null)
            {
                return(null);
            }
            if (memberRef is ITypeDefOrRef tdr)
            {
                return(GetRtType(tdr));
            }
            if (memberRef is IField field && field.FieldSig != null)
            {
                return(GetRtField(field));
            }
            if (memberRef is IMethod method && method.MethodSig != null)
            {
                return(GetRtMethod(method));
            }

            throw new ApplicationException($"Unknown MemberRef: {memberRef}");
        }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a new instruction with a token operand
 /// </summary>
 /// <param name="token">The token</param>
 /// <returns>A new <see cref="Instruction"/> instance</returns>
 public Instruction ToInstruction(ITokenOperand token) => Instruction.Create(this, token);
Exemplo n.º 5
0
 /// <summary>
 /// Creates a new instruction with a token operand
 /// </summary>
 /// <param name="token">The token</param>
 /// <returns>A new <see cref="Instruction"/> instance</returns>
 public Instruction ToInstruction(ITokenOperand token)
 {
     return(Instruction.Create(this, token));
 }
Exemplo n.º 6
0
		public static object GetRtObject(ITokenOperand memberRef) {
			if (memberRef == null)
				return null;
			var tdr = memberRef as ITypeDefOrRef;
			if (tdr != null)
				return GetRtType(tdr);
			var field = memberRef as IField;
			if (field != null && field.FieldSig != null)
				return GetRtField(field);
			var method = memberRef as IMethod;
			if (method != null && method.MethodSig != null)
				return GetRtMethod(method);

			throw new ApplicationException(string.Format("Unknown MemberRef: {0}", memberRef));
		}
Exemplo n.º 7
0
 public static IILEmitter Emit(this IILEmitter emitter, OpCode code, ITokenOperand to) =>
 emitter.Emit(Instruction.Create(code, to));
Exemplo n.º 8
0
 public Instructions Emit(OpCode opCode, ITokenOperand value)
 {
     return(Insert(Instruction.Create(opCode, value)));
 }
Exemplo n.º 9
0
		/// <summary>
		/// Creates a new instruction with a token operand
		/// </summary>
		/// <param name="token">The token</param>
		/// <returns>A new <see cref="Instruction"/> instance</returns>
		public Instruction ToInstruction(ITokenOperand token) {
			return Instruction.Create(this, token);
		}
Exemplo n.º 10
0
 public Instruction Create(OpCode op, ITokenOperand v)
 {
     return(op.ToInstruction(v));
 }
Exemplo n.º 11
0
 public ILProcessor Emit(OpCode op, ITokenOperand v)
 {
     return(Append(op.ToInstruction(v)));
 }
Exemplo n.º 12
0
        public static void Emit(this ICollection <Instruction> instructions, OpCode opCode, ITokenOperand token)
        {
            var instruction = Instruction.Create(opCode, token);

            instructions.Add(instruction);
        }
Exemplo n.º 13
0
		/// <summary>
		/// Creates a new instruction with a token operand
		/// </summary>
		/// <param name="opCode">The opcode</param>
		/// <param name="token">The token</param>
		/// <returns>A new <see cref="Instruction"/> instance</returns>
		public static Instruction Create(OpCode opCode, ITokenOperand token) {
			if (opCode.OperandType != OperandType.InlineTok)
				throw new ArgumentException("Opcode does not have a token operand", "opCode");
			return new Instruction(opCode, token);
		}