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


C# MethodSymbol.GetConstructedLeastOverriddenMethod方法代码示例

本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol.GetConstructedLeastOverriddenMethod方法的典型用法代码示例。如果您正苦于以下问题:C# MethodSymbol.GetConstructedLeastOverriddenMethod方法的具体用法?C# MethodSymbol.GetConstructedLeastOverriddenMethod怎么用?C# MethodSymbol.GetConstructedLeastOverriddenMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol的用法示例。


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

示例1: EmitDelegateCreation

        private void EmitDelegateCreation(BoundExpression node, BoundExpression receiver, bool isExtensionMethod, MethodSymbol method, TypeSymbol delegateType, bool used)
        {
            var isStatic = receiver == null || (!isExtensionMethod && method.IsStatic);
            if (!used)
            {
                if (!isStatic)
                {
                    EmitExpression(receiver, false);
                }

                return;
            }

            // emit the receiver
            if (isStatic)
            {
                builder.EmitNullConstant();
            }
            else
            {
                EmitExpression(receiver, true);
                if (!receiver.Type.IsVerifierReference())
                {
                    EmitBox(receiver.Type, receiver.Syntax);
                }
            }

            // emit method pointer

            // Metadata Spec (II.14.6):
            //   Delegates shall be declared sealed.
            //   The Invoke method shall be virtual.
            if (method.IsMetadataVirtual() && !method.ContainingType.IsDelegateType() && !receiver.SuppressVirtualCalls)
            {
                // NOTE: method.IsMetadataVirtual -> receiver != null
                builder.EmitOpCode(ILOpCode.Dup);
                builder.EmitOpCode(ILOpCode.Ldvirtftn);

                //  substitute the method with original virtual method
                method = method.GetConstructedLeastOverriddenMethod(this.method.ContainingType);
            }
            else
            {
                builder.EmitOpCode(ILOpCode.Ldftn);
            }

            EmitSymbolToken(method, node.Syntax, null);

            // call delegate constructor
            builder.EmitOpCode(ILOpCode.Newobj, -1); // pop 2 args and push delegate object

            var ctor = DelegateConstructor(node.Syntax, delegateType);
            if ((object)ctor != null) EmitSymbolToken(ctor, node.Syntax, null);
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:54,代码来源:EmitConversion.cs

示例2: MethodInfo

 public BoundExpression MethodInfo(MethodSymbol method)
 {
     var originalMethod = method.GetConstructedLeastOverriddenMethod(this.CompilationState.Type);
     return new BoundMethodInfo(
         Syntax,
         originalMethod,
         GetMethodFromHandleMethod(originalMethod.ContainingType),
         WellKnownType(Microsoft.CodeAnalysis.WellKnownType.System_Reflection_MethodInfo)) { WasCompilerGenerated = true };
 }
开发者ID:afrog33k,项目名称:csnative,代码行数:9,代码来源:SyntheticBoundNodeFactory.cs

示例3: MethodInfo

        public BoundExpression MethodInfo(MethodSymbol method)
        {
            // The least overridden virtual method is only called for value type receivers
            // in special circumstances. These circumstances are exactly the checks performed by
            // MayUseCallForStructMethod (which is also used by the emitter when determining
            // whether or not to call a method with a value type receiver directly).
            if (!method.ContainingType.IsValueType || !Microsoft.CodeAnalysis.CSharp.CodeGen.CodeGenerator.MayUseCallForStructMethod(method))
            {
                method = method.GetConstructedLeastOverriddenMethod(this.CompilationState.Type);
            }

            return new BoundMethodInfo(
                Syntax,
                method,
                GetMethodFromHandleMethod(method.ContainingType),
                WellKnownType(Microsoft.CodeAnalysis.WellKnownType.System_Reflection_MethodInfo))
            { WasCompilerGenerated = true };
        }
开发者ID:,项目名称:,代码行数:18,代码来源:


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