本文整理汇总了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();
}
示例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;
}
示例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);
}