本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.SyntheticBoundNodeFactory.This方法的典型用法代码示例。如果您正苦于以下问题:C# SyntheticBoundNodeFactory.This方法的具体用法?C# SyntheticBoundNodeFactory.This怎么用?C# SyntheticBoundNodeFactory.This使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.SyntheticBoundNodeFactory
的用法示例。
在下文中一共展示了SyntheticBoundNodeFactory.This方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindMethodBody
//.........这里部分代码省略.........
if (sourceMethod.IsUnsafe && compilation.Options.AllowUnsafe) // Don't cascade
{
diagnostics.Add(ErrorCode.ERR_IllegalInnerUnsafe, sourceMethod.Locations[0]);
}
if (sourceMethod.IsVararg)
{
// error CS1636: __arglist is not allowed in the parameter list of iterators
diagnostics.Add(ErrorCode.ERR_VarargsIterator, sourceMethod.Locations[0]);
}
}
}
else // for [if (blockSyntax != null)]
{
var property = sourceMethod.AssociatedSymbol as SourcePropertySymbol;
if ((object)property != null && property.IsAutoProperty)
{
return MethodBodySynthesizer.ConstructAutoPropertyAccessorBody(sourceMethod);
}
if (sourceMethod.IsPrimaryCtor)
{
body = null;
}
else
{
return null;
}
}
}
else
{
// synthesized methods should return their bound bodies
body = null;
}
// delegates have constructors but not constructor initializers
if (method.MethodKind == MethodKind.Constructor && !method.ContainingType.IsDelegateType())
{
var initializerInvocation = BindConstructorInitializer(method, diagnostics, compilation);
if (initializerInvocation != null)
{
constructorInitializer = new BoundExpressionStatement(initializerInvocation.Syntax, initializerInvocation) { WasCompilerGenerated = true };
Debug.Assert(initializerInvocation.HasAnyErrors || constructorInitializer.IsConstructorInitializer(), "Please keep this bound node in sync with BoundNodeExtensions.IsConstructorInitializer.");
}
}
var statements = ArrayBuilder<BoundStatement>.GetInstance();
if (constructorInitializer != null)
{
statements.Add(constructorInitializer);
}
if ((object)sourceMethod != null && sourceMethod.IsPrimaryCtor && (object)((SourceMemberContainerTypeSymbol)sourceMethod.ContainingType).PrimaryCtor == (object)sourceMethod)
{
Debug.Assert(method.MethodKind == MethodKind.Constructor && !method.ContainingType.IsDelegateType());
Debug.Assert(body == null);
if (sourceMethod.ParameterCount > 0)
{
var factory = new SyntheticBoundNodeFactory(sourceMethod, sourceMethod.SyntaxNode, compilationState, diagnostics);
factory.CurrentMethod = sourceMethod;
foreach (var parameter in sourceMethod.Parameters)
{
FieldSymbol field = parameter.PrimaryConstructorParameterBackingField;
if ((object)field != null)
{
statements.Add(factory.Assignment(factory.Field(factory.This(), field),
factory.Parameter(parameter)));
}
}
}
}
if (body != null)
{
statements.Add(body);
}
CSharpSyntaxNode syntax = body != null ? body.Syntax : method.GetNonNullSyntaxNode();
BoundBlock block;
if (statements.Count == 1 && statements[0].Kind == ((body == null) ? BoundKind.Block : body.Kind))
{
// most common case - we just have a single block for the body.
block = (BoundBlock)statements[0];
statements.Free();
}
else
{
block = new BoundBlock(syntax, default(ImmutableArray<LocalSymbol>), statements.ToImmutableAndFree()) { WasCompilerGenerated = true };
}
return method.MethodKind == MethodKind.Destructor ? MethodBodySynthesizer.ConstructDestructorBody(syntax, method, block) : block;
}
示例2: MethodToStateMachineRewriter
// new:
public MethodToStateMachineRewriter(
SyntheticBoundNodeFactory F,
MethodSymbol originalMethod,
FieldSymbol state,
IReadOnlySet<Symbol> hoistedVariables,
IReadOnlyDictionary<Symbol, CapturedSymbolReplacement> nonReusableLocalProxies,
SynthesizedLocalOrdinalsDispenser synthesizedLocalOrdinals,
VariableSlotAllocator slotAllocatorOpt,
int nextFreeHoistedLocalSlot,
DiagnosticBag diagnostics,
bool useFinalizerBookkeeping)
: base(slotAllocatorOpt, F.CompilationState, diagnostics)
{
Debug.Assert(F != null);
Debug.Assert(originalMethod != null);
Debug.Assert(state != null);
Debug.Assert(nonReusableLocalProxies != null);
Debug.Assert(diagnostics != null);
Debug.Assert(hoistedVariables != null);
Debug.Assert(nextFreeHoistedLocalSlot >= 0);
this.F = F;
this.stateField = state;
this.cachedState = F.SynthesizedLocal(F.SpecialType(SpecialType.System_Int32), syntax: F.Syntax, kind: SynthesizedLocalKind.StateMachineCachedState);
_useFinalizerBookkeeping = useFinalizerBookkeeping;
_hasFinalizerState = useFinalizerBookkeeping;
this.OriginalMethod = originalMethod;
_hoistedVariables = hoistedVariables;
_synthesizedLocalOrdinals = synthesizedLocalOrdinals;
_nextFreeHoistedLocalSlot = nextFreeHoistedLocalSlot;
foreach (var proxy in nonReusableLocalProxies)
{
this.proxies.Add(proxy.Key, proxy.Value);
}
// create cache local for reference type "this" in Release
var thisParameter = originalMethod.ThisParameter;
CapturedSymbolReplacement thisProxy;
if ((object)thisParameter != null &&
thisParameter.Type.IsReferenceType &&
proxies.TryGetValue(thisParameter, out thisProxy) &&
F.Compilation.Options.OptimizationLevel == OptimizationLevel.Release)
{
BoundExpression thisProxyReplacement = thisProxy.Replacement(F.Syntax, frameType => F.This());
this.cachedThis = F.SynthesizedLocal(thisProxyReplacement.Type, syntax: F.Syntax, kind: SynthesizedLocalKind.FrameCache);
}
}