本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.ExecutableCodeBinder.WithAdditionalFlagsAndContainingMemberOrLambda方法的典型用法代码示例。如果您正苦于以下问题:C# ExecutableCodeBinder.WithAdditionalFlagsAndContainingMemberOrLambda方法的具体用法?C# ExecutableCodeBinder.WithAdditionalFlagsAndContainingMemberOrLambda怎么用?C# ExecutableCodeBinder.WithAdditionalFlagsAndContainingMemberOrLambda使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.ExecutableCodeBinder
的用法示例。
在下文中一共展示了ExecutableCodeBinder.WithAdditionalFlagsAndContainingMemberOrLambda方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindScriptFieldInitializers
/// <summary>
/// In script C#, some field initializers are assignments to fields and others are global
/// statements. There are no restrictions on accessing instance members.
/// </summary>
private static void BindScriptFieldInitializers(
CSharpCompilation compilation,
SynthesizedInteractiveInitializerMethod scriptInitializer,
ImmutableArray<ImmutableArray<FieldOrPropertyInitializer>> initializers,
ArrayBuilder<BoundInitializer> boundInitializers,
DiagnosticBag diagnostics,
out ImportChain firstDebugImports)
{
firstDebugImports = null;
for (int i = 0; i < initializers.Length; i++)
{
ImmutableArray<FieldOrPropertyInitializer> siblingInitializers = initializers[i];
// All sibling initializers share the same parent node and tree so we can reuse the binder
// factory across siblings. Unfortunately, we cannot reuse the binder itself, because
// individual fields might have their own binders (e.g. because of being declared unsafe).
BinderFactory binderFactory = null;
// Label instances must be shared across all global statements.
ScriptLocalScopeBinder.Labels labels = null;
for (int j = 0; j < siblingInitializers.Length; j++)
{
var initializer = siblingInitializers[j];
var fieldSymbol = initializer.FieldOpt;
if ((object)fieldSymbol != null && fieldSymbol.IsConst)
{
// Constants do not need field initializers.
continue;
}
var syntaxRef = initializer.Syntax;
var syntaxTree = syntaxRef.SyntaxTree;
Debug.Assert(syntaxTree.Options.Kind != SourceCodeKind.Regular);
var syntax = (CSharpSyntaxNode)syntaxRef.GetSyntax();
var syntaxRoot = syntaxTree.GetCompilationUnitRoot();
if (binderFactory == null)
{
binderFactory = compilation.GetBinderFactory(syntaxTree);
labels = new ScriptLocalScopeBinder.Labels(scriptInitializer, syntaxRoot);
}
Binder scriptClassBinder = binderFactory.GetBinder(syntax);
Debug.Assert(((NamedTypeSymbol)scriptClassBinder.ContainingMemberOrLambda).IsScriptClass);
if (firstDebugImports == null)
{
firstDebugImports = scriptClassBinder.ImportChain;
}
Binder parentBinder = new ExecutableCodeBinder(
syntaxRoot,
scriptInitializer,
new ScriptLocalScopeBinder(labels, scriptClassBinder));
BoundInitializer boundInitializer;
if ((object)fieldSymbol != null)
{
boundInitializer = BindFieldInitializer(
parentBinder.WithAdditionalFlagsAndContainingMemberOrLambda(BinderFlags.FieldInitializer, fieldSymbol),
fieldSymbol,
(EqualsValueClauseSyntax)syntax,
diagnostics);
}
else
{
boundInitializer = BindGlobalStatement(
parentBinder,
scriptInitializer,
(StatementSyntax)syntax,
diagnostics,
isLast: i == initializers.Length - 1 && j == siblingInitializers.Length - 1);
}
boundInitializers.Add(boundInitializer);
}
}
}