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