当前位置: 首页>>代码示例>>C#>>正文


C# BaseMethodCompiler类代码示例

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


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

示例1: Resolve

        /// <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 Resolve(Context ctx, BaseMethodCompiler compiler)
        {
            base.Resolve(ctx, compiler);

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

            switch (opcode)
            {
                case OpCode.Conv_u: goto case OpCode.Conv_i;
                case OpCode.Conv_i: resultType = compiler.TypeSystem.BuiltIn.I; break;
                case OpCode.Conv_i1: resultType = compiler.TypeSystem.BuiltIn.I1; break;
                case OpCode.Conv_i2: resultType = compiler.TypeSystem.BuiltIn.I2; break;
                case OpCode.Conv_i4: resultType = compiler.TypeSystem.BuiltIn.I4; break;
                case OpCode.Conv_i8: resultType = compiler.TypeSystem.BuiltIn.I8; break;
                case OpCode.Conv_r4: resultType = compiler.TypeSystem.BuiltIn.R4; break;
                case OpCode.Conv_r8: resultType = compiler.TypeSystem.BuiltIn.R8; break;
                case OpCode.Conv_u1: resultType = compiler.TypeSystem.BuiltIn.U1; break;
                case OpCode.Conv_u2: resultType = compiler.TypeSystem.BuiltIn.U2; break;
                case OpCode.Conv_u4: resultType = compiler.TypeSystem.BuiltIn.U4; break;
                case OpCode.Conv_u8: resultType = compiler.TypeSystem.BuiltIn.U8; break;
                case OpCode.Conv_ovf_i: goto case OpCode.Conv_i;
                case OpCode.Conv_ovf_u: goto case OpCode.Conv_i;
                case OpCode.Conv_ovf_i_un: goto case OpCode.Conv_i;
                case OpCode.Conv_ovf_u_un: goto case OpCode.Conv_i;
                case OpCode.Conv_r_un: resultType = compiler.TypeSystem.BuiltIn.R8; break;
                default: throw new NotSupportedException(@"Overflow checking conversions not supported.");
            }

            ctx.Result = compiler.CreateVirtualRegister(resultType.GetStackType());
        }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:36,代码来源:ConversionInstruction.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, BaseMethodCompiler 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:jeffreye,项目名称:MOSA-Project,代码行数:30,代码来源:ArithmeticOverflowInstruction.cs

示例3: foreach

        /// <summary>
        /// Replaces the intrinsic call site
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="methodCompiler">The method compiler.</param>
        void IIntrinsicInternalMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler)
        {
            var result = context.Result;
            var operand1 = context.Operand1;
            if (operand1.IsValueType)
            {
                InstructionNode def = operand1.Definitions[0];
                var replacements = new List<Tuple<InstructionNode, int>>();
                foreach (var use in operand1.Uses)
                    for (int i = 0; i < use.OperandCount; i++)
                        if (use.GetOperand(i) == operand1)
                            replacements.Add(new Tuple<InstructionNode, int>(use, i));

                foreach (var replace in replacements)
                    replace.Item1.SetOperand(replace.Item2, def.Operand1);

                operand1 = def.Operand1;
                def.Empty();

                if (operand1.IsMemoryAddress)
                {
                    context.SetInstruction(IRInstruction.AddressOf, result, operand1);
                    return;
                }
            }
            context.SetInstruction(IRInstruction.Move, result, operand1);
        }
开发者ID:Profi-Concept,项目名称:MOSA-Project,代码行数:32,代码来源:GetObjectAddress.cs

示例4: Resolve

        /// <summary>
        /// Validates the specified instruction.
        /// </summary>
        /// <param name="ctx">The context.</param>
        /// <param name="compiler">The compiler.</param>
        public override void Resolve(Context ctx, BaseMethodCompiler compiler)
        {
            base.Resolve(ctx, compiler);

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

示例5: Resolve

        /// <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 Resolve(Context ctx, BaseMethodCompiler compiler)
        {
            base.Resolve(ctx, compiler);

            // Simple result is the same type as the unary argument
            ctx.Result = compiler.CreateVirtualRegister(ctx.Operand1.Type);
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:12,代码来源:UnaryArithmeticInstruction.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, BaseMethodCompiler 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.CreateVirtualRegister(Operand.SigTypeFromStackType(result));
        }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:33,代码来源:BinaryLogicInstruction.cs

示例7: Internal

        /// <summary>
        /// Allows quick internal call replacements
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="methodCompiler">The method compiler.</param>
        /// <param name="internalMethod">The internal method to replace with.</param>
        /// <param name="internalClass">The internal class that has the internal method.</param>
        protected void Internal(Context context, BaseMethodCompiler methodCompiler, string internalMethod, string internalClass = "Internal")
        {
            if (context == null || methodCompiler == null || internalMethod == null || internalClass == null)
                throw new ArgumentNullException();

            var type = methodCompiler.TypeSystem.GetTypeByName("Mosa.Runtime", internalClass);
            Debug.Assert(type != null, "Cannot find Mosa.Runtime." + internalClass);

            var method = type.FindMethodByName(internalMethod);
            Debug.Assert(method != null, "Cannot find " + internalMethod + " in " + type.Name);

            Operand callTargetOperand = Operand.CreateSymbolFromMethod(methodCompiler.TypeSystem, method);

            var operands = new Operand[context.OperandCount];

            for (int i = 0; i < context.OperandCount; i++)
                operands[i] = context.GetOperand(i);

            Operand result = context.Result;

            context.SetInstruction(IRInstruction.Call, result, callTargetOperand);

            for (int i = 0; i < operands.Length; i++)
            {
                context.SetOperand(1 + i, operands[i]);
            }

            context.OperandCount = (byte)(1 + operands.Length);
            context.InvokeMethod = method;
        }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:37,代码来源:InternalsBase.cs

示例8: GetRuntimeTypeHandle

 private Operand GetRuntimeTypeHandle(Context context, BaseMethodCompiler methodCompiler)
 {
     var typeDef = Operand.CreateUnmanagedSymbolPointer(methodCompiler.TypeSystem, StringClassTypeDefinitionSymbolName);
     var runtimeTypeHandle = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.GetTypeByName("System", "RuntimeTypeHandle"));
     var before = context.InsertBefore();
     before.SetInstruction(IRInstruction.Move, runtimeTypeHandle, typeDef);
     return runtimeTypeHandle;
 }
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:8,代码来源:InternalAllocateString.cs

示例9: 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, BaseMethodCompiler 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.CreateVirtualRegister(BuiltInSigType.IntPtr);
        }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:15,代码来源:LdlenInstruction.cs

示例10: Resolve

        /// <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 Resolve(Context ctx, BaseMethodCompiler compiler)
        {
            base.Resolve(ctx, compiler);

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

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

示例11: 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, BaseMethodCompiler 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.CreateVirtualRegister(Operand.SigTypeFromStackType(result));
        }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:16,代码来源:ShiftInstruction.cs

示例12: Resolve

        /// <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 Resolve(Context ctx, BaseMethodCompiler compiler)
        {
            base.Resolve(ctx, compiler);

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

            ctx.Result = compiler.CreateVirtualRegister(ctx.Operand1.Type);
        }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:16,代码来源:NotInstruction.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, BaseMethodCompiler 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:pdelprat,项目名称:MOSA-Project,代码行数:16,代码来源:NegInstruction.cs

示例14: Resolve

        /// <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 Resolve(Context ctx, BaseMethodCompiler compiler)
        {
            base.Resolve(ctx, compiler);

            //FIXME: Intent?
            //SigType destType = ctx.Operand1.Type;

            //Debug.Assert(destType is PtrSigType || destType is RefSigType, @"Destination operand not a pointer or reference.");
            //if (!(destType is PtrSigType || destType is RefSigType))
            //    throw new InvalidOperationException(@"Invalid operand.");
        }
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:16,代码来源:StobjInstruction.cs

示例15: Resolve

        /// <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 Resolve(Context ctx, BaseMethodCompiler compiler)
        {
            base.Resolve(ctx, compiler);

            // If we're ldind.i8, fix an IL deficiency that the result may be U8
            if (opcode == OpCode.Ldind_i8 && elementType.Value == MosaTypeCode.I8)
            {
                if (ctx.Operand1.Type.ElementType != null && ctx.Operand1.Type.ElementType.IsU8)
                {
                    ctx.Result = compiler.CreateVirtualRegister(compiler.TypeSystem.BuiltIn.U8);
                }
            }
        }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:18,代码来源:LdobjInstruction.cs


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