コード例 #1
0
        /// <summary>
        /// Decodes the specified instruction.
        /// </summary>
        /// <param name="ctx">The context.</param>
        /// <param name="decoder">The instruction decoder, which holds the code stream.</param>
        public override void Decode(Context ctx, IInstructionDecoder decoder)
        {
            base.Decode(ctx, decoder);

            Token token = decoder.DecodeTokenType();

            ITypeModule module = null;

            Mosa.Runtime.TypeSystem.Generic.CilGenericType genericType = decoder.Method.DeclaringType as Mosa.Runtime.TypeSystem.Generic.CilGenericType;
            if (genericType != null)
            {
                module = (decoder.Method.DeclaringType as Mosa.Runtime.TypeSystem.Generic.CilGenericType).BaseGenericType.Module;
            }
            else
            {
                module = decoder.Method.Module;
            }
            ctx.RuntimeField = module.GetField(token);

            if (ctx.RuntimeField.ContainsGenericParameter)
            {
                ;
            }

            SigType sigType = new RefSigType(ctx.RuntimeField.SignatureType);

            ctx.Result = LoadInstruction.CreateResultOperand(decoder, Operand.StackTypeFromSigType(sigType), sigType);
        }
コード例 #2
0
        /// <summary>
        /// Validates the instruction operands and creates a matching variable for the result.
        /// </summary>
        /// <param name="ctx">The context.</param>
        /// <param name="compiler">The compiler.</param>
        public override void Validate(Context ctx, IMethodCompiler compiler)
        {
            base.Validate(ctx, compiler);

            // If we're ldind.i8, fix an IL deficiency that the result may be U8
            if (opcode == OpCode.Ldind_i8 && this.typeRef.Type == CilElementType.I8)
            {
                SigType    opType = ctx.Operand1.Type;
                RefSigType rst    = opType as RefSigType;
                PtrSigType ptr    = opType as PtrSigType;

                if (rst != null && rst.ElementType.Type == CilElementType.U8 ||
                    ptr != null && ptr.ElementType.Type == CilElementType.U8)
                {
                    ctx.Result = compiler.CreateTemporary(BuiltInSigType.UInt64);
                }
            }
        }