• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IMethodCompiler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IMethodCompiler的典型用法代码示例。如果您正苦于以下问题:C# IMethodCompiler类的具体用法?C# IMethodCompiler怎么用?C# IMethodCompiler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IMethodCompiler类属于命名空间,在下文中一共展示了IMethodCompiler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Validate

        /// <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);

            var stackTypeForOperand1 = ctx.Operand1.StackType;
            var stackTypeForOperand2 = ctx.Operand2.StackType;

            if (ctx.Operand1.Type is ValueTypeSigType)
            {
                var op1Type = compiler.Method.Module.GetType ((ctx.Operand1.Type as ValueTypeSigType).Token);
                if (op1Type.BaseType.FullName == "System.Enum")
                    stackTypeForOperand1 = this.FromSigType (op1Type.Fields[0].SignatureType.Type);
            }

            if (ctx.Operand2.Type is ValueTypeSigType)
            {
                var op2Type = compiler.Method.Module.GetType ((ctx.Operand2.Type as ValueTypeSigType).Token);
                if (op2Type.BaseType.FullName == "System.Enum")
                    stackTypeForOperand2 = this.FromSigType (op2Type.Fields[0].SignatureType.Type);
            }

            var result = _opTable[(int)stackTypeForOperand1][(int)stackTypeForOperand2];

            if (result == StackTypeCode.Unknown)
                throw new InvalidOperationException (@"Invalid stack result of instruction: " + result.ToString () + " (" + ctx.Operand1.ToString () + ")");

            ctx.Result = compiler.CreateTemporary(Operand.SigTypeFromStackType(result));
        }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:33,代码来源:BinaryLogicInstruction.cs


示例2: Validate

        /// <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);

            StackTypeCode result = StackTypeCode.Unknown;
            switch (opcode)
            {
                case OpCode.Add_ovf_un:
                    result = _addovfunTable[(int)ctx.Operand1.StackType][(int)ctx.Operand2.StackType];
                    break;

                case OpCode.Sub_ovf_un:
                    result = _subovfunTable[(int)ctx.Operand1.StackType][(int)ctx.Operand2.StackType];
                    break;

                default:
                    result = _operandTable[(int)ctx.Operand1.StackType][(int)ctx.Operand2.StackType];
                    break;
            }

            if (StackTypeCode.Unknown == result)
                throw new InvalidOperationException(@"Invalid operand types passed to " + opcode);

            ctx.Result = compiler.CreateVirtualRegister(Operand.SigTypeFromStackType(result));
        }
开发者ID:grover,项目名称:MOSA-Project,代码行数:30,代码来源:ArithmeticOverflowInstruction.cs


示例3: Validate

        /// <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);

            // Simple result is the same type as the unary argument
            ctx.Result = compiler.CreateTemporary(ctx.Operand1.Type);
        }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:12,代码来源:UnaryArithmeticInstruction.cs


示例4: Validate

        /// <summary>
        /// Validates the specified instruction.
        /// </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);

            ctx.Result = ctx.Operand1;
            ctx.Result2 = ctx.Operand1;
        }
开发者ID:davidleon,项目名称:MOSA-Project,代码行数:12,代码来源:DupInstruction.cs


示例5: Validate

        /// <summary>
        /// Validates the instruction operands and creates a matching variable for the result.
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="compiler">The compiler.</param>
        public override void Validate(Context ctx, IMethodCompiler compiler)
        {
            base.Validate(ctx, compiler);

            // Validate the typecode & determine the resulting stack type
            SigType resultType;

            switch (_opcode) {
                case OpCode.Conv_u: goto case OpCode.Conv_i;
                case OpCode.Conv_i:
                    resultType = compiler.Architecture.NativeType;
                    break;

                case OpCode.Conv_i1:
                    resultType = new SigType(CilElementType.I1);
                    break;

                case OpCode.Conv_i2:
                    resultType = new SigType(CilElementType.I2);
                    break;

                case OpCode.Conv_i4:
                    resultType = new SigType(CilElementType.I4);
                    break;

                case OpCode.Conv_i8:
                    resultType = new SigType(CilElementType.I8);
                    break;

                case OpCode.Conv_r4:
                    resultType = new SigType(CilElementType.R4);
                    break;

                case OpCode.Conv_r8:
                    resultType = new SigType(CilElementType.R8);
                    break;

                case OpCode.Conv_u1:
                    resultType = new SigType(CilElementType.U1);
                    break;

                case OpCode.Conv_u2:
                    resultType = new SigType(CilElementType.U2);
                    break;

                case OpCode.Conv_u4:
                    resultType = new SigType(CilElementType.U4);
                    break;

                case OpCode.Conv_u8:
                    resultType = new SigType(CilElementType.U8);
                    break;

                default:
                    throw new NotSupportedException(@"Overflow checking conversions not supported.");
            }

            ctx.Result = compiler.CreateTemporary(resultType);
        }
开发者ID:hj1980,项目名称:Mosa,代码行数:64,代码来源:ConversionInstruction.cs


示例6: Validate

        /// <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);

            Mosa.Runtime.Metadata.Signatures.ArraySigType a = ctx.Operand1.Type as Mosa.Runtime.Metadata.Signatures.ArraySigType;
            if (null == a || 1 != a.Rank)
                throw new InvalidProgramException(@"Operand to ldlen is not a vector.");
            ctx.Result = compiler.CreateTemporary(new SigType(CilElementType.I));
        }
开发者ID:rtownsend,项目名称:MOSA-Project,代码行数:14,代码来源:LdlenInstruction.cs


示例7: Validate

        /// <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);

            SZArraySigType arrayType = ctx.Operand1.Type as SZArraySigType;
            if (arrayType == null)
                throw new InvalidProgramException(@"Operand to ldlen is not a vector.");

            ctx.Result = compiler.CreateTemporary(BuiltInSigType.IntPtr);
        }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:15,代码来源:LdlenInstruction.cs


示例8: Validate

        /// <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);

            StackTypeCode result = _opTable[(int)ctx.Operand1.StackType][(int)ctx.Operand2.StackType];
            if (result == StackTypeCode.Unknown)
                throw new InvalidOperationException(@"Invalid stack result of instruction.");

            ctx.Result = compiler.CreateTemporary(Operand.SigTypeFromStackType(result));
        }
开发者ID:davidbjornn,项目名称:MOSA-Project,代码行数:15,代码来源:BinaryLogicInstruction.cs


示例9: Run

 public static void Run(IMethodCompiler methodCompiler, IPipelineStage stage)
 {
     Run(
         methodCompiler.InternalTrace,
         stage,
         methodCompiler.Method,
         methodCompiler.InstructionSet,
         methodCompiler.BasicBlocks
     );
 }
开发者ID:grover,项目名称:MOSA-Project,代码行数:10,代码来源:InstructionLogger.cs


示例10: Setup

        /// <summary>
        /// Setups the specified compiler.
        /// </summary>
        /// <param name="compiler">The compiler.</param>
        public void Setup(IMethodCompiler compiler)
        {
            if (compiler == null)
                throw new ArgumentNullException ("compiler");

            MethodCompiler = compiler;
            InstructionSet = compiler.InstructionSet;
            BasicBlocks = compiler.BasicBlocks;
            Architecture = compiler.Architecture;
        }
开发者ID:54616E6E6572,项目名称:Mosa,代码行数:14,代码来源:BaseStage.cs


示例11:

        /// <summary>
        /// Setup stage specific processing on the compiler context.
        /// </summary>
        /// <param name="methodCompiler">The compiler context to perform processing in.</param>
        void IMethodCompilerStage.Setup(IMethodCompiler methodCompiler)
        {
            base.Setup(methodCompiler);

            IStackLayoutProvider stackLayoutProvider = methodCompiler.Pipeline.FindFirst<IStackLayoutProvider>();

            stackSize = (stackLayoutProvider == null) ? 0 : stackLayoutProvider.LocalsSize;

            Debug.Assert((stackSize % 4) == 0, @"Stack size of method can't be divided by 4!!");
        }
开发者ID:toddhainsworth,项目名称:MOSA-Project,代码行数:14,代码来源:IRTransformationStage.cs


示例12: Validate

        /// <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);

            StackTypeCode result = _operandTable[(int)ctx.Operand1.StackType][(int)ctx.Operand2.StackType];
            Debug.Assert(StackTypeCode.Unknown != result, @"Can't shift with the given stack operands.");
            if (StackTypeCode.Unknown == result)
                throw new InvalidOperationException(@"Invalid stack state for pairing (" + ctx.Operand1.StackType + ", " + ctx.Operand2.StackType + ")");

            ctx.Result = compiler.CreateTemporary(Operand.SigTypeFromStackType(result));
        }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:16,代码来源:ShiftInstruction.cs


示例13: Validate

        /// <summary>
        /// Validates the instruction operands and creates a matching variable for the result.
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="compiler">The compiler.</param>
        public override void Validate(Context ctx, IMethodCompiler compiler)
        {
            base.Validate(ctx, compiler);

            // Validate the operand
            StackTypeCode result = _opTable[(int)ctx.Operand1.StackType];
            if (StackTypeCode.Unknown == result)
                throw new InvalidOperationException(@"Invalid operand to Not instruction.");

            ctx.Result = compiler.CreateTemporary(ctx.Operand1.Type);
        }
开发者ID:rtownsend,项目名称:MOSA-Project,代码行数:16,代码来源:NotInstruction.cs


示例14: Validate

        /// <summary>
        /// Validates the instruction operands and creates a matching variable for the result.
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="compiler">The compiler.</param>
        public override void Validate(Context ctx, IMethodCompiler compiler)
        {
            base.Validate(ctx, compiler);

            // Validate the operand
            StackTypeCode result = _typeCodes[(int)ctx.Operand1.StackType];
            if (StackTypeCode.Unknown == result)
                throw new InvalidOperationException(@"Invalid operand to Neg instruction [" + result + "]");

            ctx.Result = compiler.CreateVirtualRegister(ctx.Operand1.Type);
        }
开发者ID:grover,项目名称:MOSA-Project,代码行数:16,代码来源:NegInstruction.cs


示例15: ComputeTypeSize

        private static int ComputeTypeSize(TokenTypes token, IMethodCompiler compiler)
        {
            IMetadataProvider metadata = compiler.Assembly.Metadata;
            Metadata.Tables.TypeDefRow typeDefinition;
            Metadata.Tables.TypeDefRow followingTypeDefinition;
            metadata.Read(token, out typeDefinition);
            metadata.Read(token + 1, out followingTypeDefinition);

            int result = 0;
            TokenTypes fieldList = typeDefinition.FieldList;
            while (fieldList != followingTypeDefinition.FieldList)
                result += FieldSize(fieldList++, compiler);

            return result;
        }
开发者ID:hj1980,项目名称:Mosa,代码行数:15,代码来源:InitObjInstruction.cs


示例16: Validate

        /// <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);

            // Make sure the base is a typed reference
            throw new NotImplementedException();
            /*
                if (!Object.ReferenceEquals(_operands[0].Type, MetadataTypeReference.FromName(compiler.Assembly.Metadata, @"System", @"TypedReference")))
                {
                    Debug.Assert(false);
                    throw new InvalidProgramException(@"Invalid stack object.");
                }

                // Push the loaded value
                _results[0] = CreateResultOperand(_typeRef);
             */
        }
开发者ID:davidbjornn,项目名称:MOSA-Project,代码行数:22,代码来源:RefanyvalInstruction.cs


示例17: FieldSize

        private static int FieldSize(TokenTypes field, IMethodCompiler compiler)
        {
            Metadata.Tables.FieldRow fieldRow;
            compiler.Assembly.Metadata.Read(field, out fieldRow);
            FieldSignature signature = Signature.FromMemberRefSignatureToken(compiler.Assembly.Metadata, fieldRow.SignatureBlobIdx) as FieldSignature;

            // If the field is another struct, we have to dig down and compute its size too.
            if (signature.Type.Type == CilElementType.ValueType)
            {
                TokenTypes valueTypeSig = ValueTokenTypeFromSignature(compiler.Assembly.Metadata, fieldRow.SignatureBlobIdx);
                return ComputeTypeSize(valueTypeSig, compiler);
            }

            int size, alignment;
            compiler.Architecture.GetTypeRequirements(signature.Type, out size, out alignment);
            return size;
        }
开发者ID:hj1980,项目名称:Mosa,代码行数:17,代码来源:InitObjInstruction.cs


示例18: ArgumentNullException

        /// <summary>
        /// Initializes a new instance of <see cref="BaseCodeEmitter"/>.
        /// </summary>
        /// <param name="compiler">The compiler.</param>
        /// <param name="codeStream">The stream the machine code is written to.</param>
        /// <param name="linker">The linker used to resolve external addresses.</param>
        void ICodeEmitter.Initialize(IMethodCompiler compiler, Stream codeStream, IAssemblyLinker linker)
        {
            Debug.Assert(null != compiler, @"MachineCodeEmitter needs a method compiler.");
            if (compiler == null)
                throw new ArgumentNullException(@"compiler");
            Debug.Assert(null != codeStream, @"MachineCodeEmitter needs a code stream.");
            if (codeStream == null)
                throw new ArgumentNullException(@"codeStream");
            Debug.Assert(null != linker, @"MachineCodeEmitter needs a linker.");
            if (linker == null)
                throw new ArgumentNullException(@"linker");

            this.compiler = compiler;
            this.codeStream = codeStream;
            this.codeStreamBasePosition = codeStream.Position;
            this.linker = linker;
        }
开发者ID:grover,项目名称:MOSA-Project,代码行数:23,代码来源:BaseCodeEmitter.cs


示例19: SetInvokeTarget

        /// <summary>
        /// Sets the invoke target.
        /// </summary>
        /// <param name="ctx">The context.</param>
        /// <param name="compiler">The compiler.</param>
        /// <param name="method">The method.</param>
        private static void SetInvokeTarget(Context ctx, IMethodCompiler compiler, RuntimeMethod method)
        {
            if (method == null)
                throw new ArgumentNullException(@"method");

            // Signature of the call target
            // Number of parameters required for the call

            ctx.InvokeTarget = method;

            // Retrieve the target signature
            MethodSignature signature = ctx.InvokeTarget.Signature;

            // Fix the parameter list
            byte paramCount = (byte)signature.Parameters.Length;
            if (signature.HasThis && !signature.HasExplicitThis)
                paramCount++;

            // Setup operands for parameters and the return value
            if (signature.ReturnType.Type != CilElementType.Void)
            {
                ctx.ResultCount = 1;
                ctx.Result = compiler.CreateTemporary(signature.ReturnType);
            }
            else
                ctx.ResultCount = 0;

            ctx.OperandCount = paramCount;
        }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:35,代码来源:InvokeInstruction.cs


示例20: Validate

        /// <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);

            int paramCount = ctx.InvokeTarget.Signature.Parameters.Length;

            if (ctx.InvokeTarget.Signature.HasThis && !ctx.InvokeTarget.Signature.HasExplicitThis)
                paramCount++;

            // Validate the operands...
            Debug.Assert(ctx.OperandCount == paramCount, @"Operand count doesn't match parameter count.");

            //for (int i = 0; i < ctx.OperandCount; i++)
            //{
            /* FIXME: Check implicit conversions
            // if (ops[i] != null) {
                Debug.Assert(_operands[i].Type == _parameterTypes[i]);
                if (_operands[i].Type != _parameterTypes[i])
                {
                    // FIXME: Determine if we can do an implicit conversion
                    throw new ExecutionEngineException(@"Invalid operand types.");
                }
            */
            //}
        }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:30,代码来源:InvokeInstruction.cs



注:本文中的IMethodCompiler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IMethodData类代码示例发布时间:2022-05-24
下一篇:
C# IMethodCallMessage类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap