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


C# MethodSymbol.IsMetadataVirtual方法代码示例

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


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

示例1: MayUseCallForStructMethod

        /// <summary>
        /// Used to decide if we need to emit 'call' or 'callvirt' for structure method.
        /// It basically checks if the method overrides any other and method's defining type
        /// is not a 'special' or 'special-by-ref' type. 
        /// </summary>
        internal static bool MayUseCallForStructMethod(MethodSymbol method)
        {
            Debug.Assert(method.ContainingType.IsVerifierValue(), "this is not a value type");

            if (!method.IsMetadataVirtual())
            {
                return true;
            }

            var overriddenMethod = method.OverriddenMethod;
            if ((object)overriddenMethod == null || overriddenMethod.IsAbstract)
            {
                return true;
            }

            var containingType = method.ContainingType;
            return containingType.IsIntrinsicType() || containingType.IsRestrictedType();
        }
开发者ID:daking2014,项目名称:roslyn,代码行数:23,代码来源:EmitExpression.cs

示例2: MayUseCallForStructMethod

        /// <summary>
        /// Used to decide if we need to emit 'call' or 'callvirt' for structure method.
        /// It basically checks if the method overrides any other and method's defining type
        /// is not a 'special' or 'special-by-ref' type. 
        /// </summary>
        internal static bool MayUseCallForStructMethod(MethodSymbol method)
        {
            Debug.Assert(method.ContainingType.IsVerifierValue(), "this is not a value type");

            if (!method.IsMetadataVirtual())
            {
                return true;
            }

            var overriddenMethod = method.OverriddenMethod;
            if ((object)overriddenMethod == null || overriddenMethod.IsAbstract)
            {
                return true;
            }

            var containingType = method.ContainingType;
            // overrides in structs that are special types can be caled directly.
            // we can assume that special types will not be removing oiverrides
            return containingType.SpecialType != SpecialType.None;
        }
开发者ID:tvsonar,项目名称:roslyn,代码行数:25,代码来源:EmitExpression.cs

示例3: 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


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