本文整理汇总了C#中LocalDeclarationKind类的典型用法代码示例。如果您正苦于以下问题:C# LocalDeclarationKind类的具体用法?C# LocalDeclarationKind怎么用?C# LocalDeclarationKind使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LocalDeclarationKind类属于命名空间,在下文中一共展示了LocalDeclarationKind类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CollectLocalsFromDeconstruction
internal void CollectLocalsFromDeconstruction(
ExpressionSyntax declaration,
LocalDeclarationKind kind,
ArrayBuilder<LocalSymbol> locals,
SyntaxNode deconstructionStatement,
Binder enclosingBinderOpt = null)
{
switch (declaration.Kind())
{
case SyntaxKind.TupleExpression:
{
var tuple = (TupleExpressionSyntax)declaration;
foreach (var arg in tuple.Arguments)
{
CollectLocalsFromDeconstruction(arg.Expression, kind, locals, deconstructionStatement, enclosingBinderOpt);
}
break;
}
case SyntaxKind.DeclarationExpression:
{
var declarationExpression = (DeclarationExpressionSyntax)declaration;
CollectLocalsFromDeconstruction(
declarationExpression.Designation, declarationExpression.Type,
kind, locals, deconstructionStatement, enclosingBinderOpt);
break;
}
case SyntaxKind.IdentifierName:
break;
default:
throw ExceptionUtilities.UnexpectedValue(declaration.Kind());
}
}
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:33,代码来源:ForEachLoopBinder.cs
示例2: CollectLocalsFromDeconstruction
internal void CollectLocalsFromDeconstruction(
ExpressionSyntax declaration,
LocalDeclarationKind kind,
ArrayBuilder<LocalSymbol> locals,
SyntaxNode deconstructionStatement,
Binder enclosingBinderOpt = null)
{
switch (declaration.Kind())
{
case SyntaxKind.TupleExpression:
{
var tuple = (TupleExpressionSyntax)declaration;
foreach (var arg in tuple.Arguments)
{
CollectLocalsFromDeconstruction(arg.Expression, kind, locals, deconstructionStatement, enclosingBinderOpt);
}
break;
}
case SyntaxKind.DeclarationExpression:
{
var declarationExpression = (DeclarationExpressionSyntax)declaration;
CollectLocalsFromDeconstruction(
declarationExpression.Designation, declarationExpression.Type,
kind, locals, deconstructionStatement, enclosingBinderOpt);
break;
}
case SyntaxKind.IdentifierName:
break;
default:
// In broken code, we can have an arbitrary expression here. Collect its expression variables.
ExpressionVariableFinder.FindExpressionVariables(this, locals, declaration);
break;
}
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:35,代码来源:ForEachLoopBinder.cs
示例3: EELocalSymbol
public EELocalSymbol(
MethodSymbol method,
ImmutableArray<Location> locations,
string nameOpt,
int ordinal,
LocalDeclarationKind declarationKind,
TypeSymbol type,
RefKind refKind,
bool isPinned,
bool isCompilerGenerated,
bool canScheduleToStack)
{
Debug.Assert(method != null);
Debug.Assert(ordinal >= -1);
Debug.Assert(!locations.IsDefault);
Debug.Assert(type != null);
_method = method;
_locations = locations;
_nameOpt = nameOpt;
_ordinal = ordinal;
_declarationKind = declarationKind;
_type = type;
_refKind = refKind;
_isPinned = isPinned;
_isCompilerGenerated = isCompilerGenerated;
_canScheduleToStack = canScheduleToStack;
}
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:28,代码来源:EELocalSymbol.cs
示例4: MakePossibleOutVarLocalWithoutInitializer
public static SourceLocalSymbol MakePossibleOutVarLocalWithoutInitializer(
Symbol containingSymbol,
Binder binder,
TypeSyntax typeSyntax,
SyntaxToken identifierToken,
CSharpSyntaxNode scopeSegmentRoot,
LocalDeclarationKind declarationKind)
{
Debug.Assert(declarationKind != LocalDeclarationKind.ForEachIterationVariable);
return new PossibleOutVarLocalWithoutInitializer(containingSymbol, binder, typeSyntax, identifierToken, scopeSegmentRoot, declarationKind);
}
开发者ID:EkardNT,项目名称:Roslyn,代码行数:11,代码来源:SourceLocalSymbol.cs
示例5: MakeLocalWithInitializer
public static SourceLocalSymbol MakeLocalWithInitializer(
Symbol containingSymbol,
Binder binder,
TypeSyntax typeSyntax,
SyntaxToken identifierToken,
EqualsValueClauseSyntax initializer,
LocalDeclarationKind declarationKind)
{
Debug.Assert(declarationKind != LocalDeclarationKind.ForEachIterationVariable);
return new LocalWithInitializer(containingSymbol, binder, typeSyntax, identifierToken, initializer, declarationKind);
}
开发者ID:EkardNT,项目名称:Roslyn,代码行数:11,代码来源:SourceLocalSymbol.cs
示例6: MakeLocal
public static SourceLocalSymbol MakeLocal(
MethodSymbol containingMethod,
Binder binder,
TypeSyntax typeSyntax,
SyntaxToken identifierToken,
EqualsValueClauseSyntax initializer,
LocalDeclarationKind declarationKind)
{
Debug.Assert(declarationKind != LocalDeclarationKind.ForEach);
return new SourceLocalSymbol(containingMethod, binder, typeSyntax, identifierToken, initializer, null, declarationKind);
}
开发者ID:riversky,项目名称:roslyn,代码行数:11,代码来源:SourceLocalSymbol.cs
示例7: SourceLocalSymbol
private SourceLocalSymbol(
Symbol containingSymbol,
Binder binder,
TypeSyntax typeSyntax,
SyntaxToken identifierToken,
LocalDeclarationKind declarationKind)
{
Debug.Assert(identifierToken.Kind() != SyntaxKind.None);
Debug.Assert(declarationKind != LocalDeclarationKind.None);
this.binder = binder;
_containingSymbol = containingSymbol;
_identifierToken = identifierToken;
_typeSyntax = typeSyntax;
_declarationKind = declarationKind;
// create this eagerly as it will always be needed for the EnsureSingleDefinition
_locations = ImmutableArray.Create<Location>(identifierToken.GetLocation());
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:19,代码来源:SourceLocalSymbol.cs
示例8: SourceLocalSymbol
private SourceLocalSymbol(
Symbol containingSymbol,
Binder scopeBinder,
bool allowRefKind,
TypeSyntax typeSyntax,
SyntaxToken identifierToken,
LocalDeclarationKind declarationKind)
{
Debug.Assert(identifierToken.Kind() != SyntaxKind.None);
Debug.Assert(declarationKind != LocalDeclarationKind.None);
Debug.Assert(scopeBinder != null);
this._scopeBinder = scopeBinder;
this._containingSymbol = containingSymbol;
this._identifierToken = identifierToken;
this._typeSyntax = allowRefKind ? typeSyntax.SkipRef(out this._refKind) : typeSyntax;
this._declarationKind = declarationKind;
// create this eagerly as it will always be needed for the EnsureSingleDefinition
_locations = ImmutableArray.Create<Location>(identifierToken.GetLocation());
}
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:21,代码来源:SourceLocalSymbol.cs
示例9: SourceLocalSymbol
private SourceLocalSymbol(
MethodSymbol containingMethod,
Binder binder,
TypeSyntax typeSyntax,
SyntaxToken identifierToken,
EqualsValueClauseSyntax initializer,
ExpressionSyntax collection,
LocalDeclarationKind declarationKind)
{
Debug.Assert(identifierToken.CSharpKind() != SyntaxKind.None);
Debug.Assert(declarationKind != LocalDeclarationKind.CompilerGenerated);
this.binder = binder;
this.containingMethod = containingMethod;
this.identifierToken = identifierToken;
this.typeSyntax = typeSyntax;
this.initializer = initializer;
this.collection = collection;
this.declarationKind = declarationKind;
// create this eagerly as it will always be needed for the EnsureSingleDefinition
this.locations = ImmutableArray.Create<Location>(identifierToken.GetLocation());
}
开发者ID:riversky,项目名称:roslyn,代码行数:23,代码来源:SourceLocalSymbol.cs
示例10: SynthesizedLocal
internal SynthesizedLocal(
MethodSymbol containingMethod,
TypeSymbol type,
string name = null,
CSharpSyntaxNode syntax = null,
bool isPinned = false,
RefKind refKind = RefKind.None,
LocalDeclarationKind declarationKind = LocalDeclarationKind.CompilerGenerated,
TempKind tempKind = TempKind.None)
{
this.containingMethod = containingMethod;
Debug.Assert(type.SpecialType != SpecialType.System_Void);
Debug.Assert((tempKind == TempKind.None) == (syntax == null));
#if NAME_TEMPS
if (string.IsNullOrEmpty(name)) name = "temp_" + Interlocked.Increment(ref nextDebugTempNumber);
#endif
this.name = name;
this.type = type;
this.syntax = syntax;
this.isPinned = isPinned;
this.declarationKind = declarationKind;
this.refKind = refKind;
this.tempKind = tempKind;
}
开发者ID:riversky,项目名称:roslyn,代码行数:24,代码来源:SynthesizedLocal.cs
示例11: LocalSymbolWithEnclosingContext
public LocalSymbolWithEnclosingContext(
Symbol containingSymbol,
Binder scopeBinder,
Binder nodeBinder,
TypeSyntax typeSyntax,
SyntaxToken identifierToken,
LocalDeclarationKind declarationKind,
SyntaxNode nodeToBind,
SyntaxNode forbiddenZone)
: base(containingSymbol, scopeBinder, false, typeSyntax, identifierToken, declarationKind)
{
Debug.Assert(
nodeToBind.Kind() == SyntaxKind.CasePatternSwitchLabel ||
nodeToBind.Kind() == SyntaxKind.ArgumentList && nodeToBind.Parent is ConstructorInitializerSyntax ||
nodeToBind.Kind() == SyntaxKind.VariableDeclarator ||
nodeToBind is ExpressionSyntax);
this._nodeBinder = nodeBinder;
this._nodeToBind = nodeToBind;
this._forbiddenZone = forbiddenZone;
}
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:20,代码来源:SourceLocalSymbol.cs
示例12: DeconstructionLocalSymbol
public DeconstructionLocalSymbol(
Symbol containingSymbol,
Binder scopeBinder,
Binder nodeBinder,
TypeSyntax typeSyntax,
SyntaxToken identifierToken,
LocalDeclarationKind declarationKind,
SyntaxNode deconstruction)
: base(containingSymbol, scopeBinder, false, typeSyntax, identifierToken, declarationKind)
{
Debug.Assert(deconstruction.Kind() == SyntaxKind.SimpleAssignmentExpression || deconstruction.Kind() == SyntaxKind.ForEachVariableStatement);
_deconstruction = deconstruction;
_nodeBinder = nodeBinder;
}
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:15,代码来源:SourceLocalSymbol.cs
示例13: MakeLocal
public static SourceLocalSymbol MakeLocal(
Symbol containingSymbol,
Binder binder,
TypeSyntax typeSyntax,
SyntaxToken identifierToken,
LocalDeclarationKind declarationKind)
{
Debug.Assert(declarationKind != LocalDeclarationKind.ForEachIterationVariable);
return new SourceLocalSymbol(containingSymbol, binder, typeSyntax, identifierToken, declarationKind);
}
开发者ID:EkardNT,项目名称:Roslyn,代码行数:10,代码来源:SourceLocalSymbol.cs
示例14: MakeLocal
/// <summary>
/// Make a local variable symbol which can be inferred (if necessary) by binding its initializing expression.
/// </summary>
/// <param name="containingSymbol"></param>
/// <param name="scopeBinder">
/// Binder that owns the scope for the local, the one that returns it in its <see cref="Binder.Locals"/> array.
/// </param>
/// <param name="allowRefKind"></param>
/// <param name="typeSyntax"></param>
/// <param name="identifierToken"></param>
/// <param name="declarationKind"></param>
/// <param name="initializer"></param>
/// <param name="initializerBinderOpt">
/// Binder that should be used to bind initializer, if different from the <paramref name="scopeBinder"/>.
/// </param>
/// <returns></returns>
public static SourceLocalSymbol MakeLocal(
Symbol containingSymbol,
Binder scopeBinder,
bool allowRefKind,
TypeSyntax typeSyntax,
SyntaxToken identifierToken,
LocalDeclarationKind declarationKind,
EqualsValueClauseSyntax initializer = null,
Binder initializerBinderOpt = null)
{
Debug.Assert(declarationKind != LocalDeclarationKind.ForEachIterationVariable);
return (initializer != null)
? new LocalWithInitializer(containingSymbol, scopeBinder, typeSyntax, identifierToken, initializer, initializerBinderOpt ?? scopeBinder, declarationKind)
: new SourceLocalSymbol(containingSymbol, scopeBinder, allowRefKind, typeSyntax, identifierToken, declarationKind);
}
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:31,代码来源:SourceLocalSymbol.cs
示例15: VerifyModelForDeconstruction
private static void VerifyModelForDeconstruction(SemanticModel model, SingleVariableDesignationSyntax decl, LocalDeclarationKind kind, params IdentifierNameSyntax[] references)
{
var symbol = model.GetDeclaredSymbol(decl);
Assert.Equal(decl.Identifier.ValueText, symbol.Name);
Assert.Equal(kind, ((LocalSymbol)symbol).DeclarationKind);
Assert.Same(symbol, model.GetDeclaredSymbol((SyntaxNode)decl));
Assert.Same(symbol, model.LookupSymbols(decl.SpanStart, name: decl.Identifier.ValueText).Single());
Assert.True(model.LookupNames(decl.SpanStart).Contains(decl.Identifier.ValueText));
var local = (SourceLocalSymbol)symbol;
var typeSyntax = GetTypeSyntax(decl);
if (local.IsVar && local.Type.IsErrorType())
{
Assert.Null(model.GetSymbolInfo(typeSyntax).Symbol);
}
else
{
if (typeSyntax != null)
{
Assert.Equal(local.Type, model.GetSymbolInfo(typeSyntax).Symbol);
}
}
foreach (var reference in references)
{
Assert.Same(symbol, model.GetSymbolInfo(reference).Symbol);
Assert.Same(symbol, model.LookupSymbols(reference.SpanStart, name: decl.Identifier.ValueText).Single());
Assert.True(model.LookupNames(reference.SpanStart).Contains(decl.Identifier.ValueText));
Assert.Equal(local.Type, model.GetTypeInfo(reference).Type);
}
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:31,代码来源:CodeGenDeconstructTests.cs
示例16: PossibleOutVarLocalWithoutInitializer
public PossibleOutVarLocalWithoutInitializer(
Symbol containingSymbol,
Binder binder,
TypeSyntax typeSyntax,
SyntaxToken identifierToken,
CSharpSyntaxNode scopeSegmentRoot,
LocalDeclarationKind declarationKind) :
base(containingSymbol, binder, typeSyntax, identifierToken, declarationKind)
{
Debug.Assert(identifierToken.Parent.CSharpKind() == SyntaxKind.VariableDeclarator && ((VariableDeclaratorSyntax)identifierToken.Parent).Identifier == identifierToken);
Debug.Assert(identifierToken.Parent.Parent.CSharpKind() == SyntaxKind.DeclarationExpression);
if (scopeSegmentRoot == null)
{
throw ExceptionUtilities.Unreachable;
}
this.scopeSegmentRoot = scopeSegmentRoot;
}
开发者ID:EkardNT,项目名称:Roslyn,代码行数:19,代码来源:SourceLocalSymbol.cs
示例17: PossibleOutVarLocalSymbol
public PossibleOutVarLocalSymbol(
Symbol containingSymbol,
Binder binder,
RefKind refKind,
TypeSyntax typeSyntax,
SyntaxToken identifierToken,
LocalDeclarationKind declarationKind)
: base(containingSymbol, binder, refKind, typeSyntax, identifierToken, declarationKind)
{
#if DEBUG
ArgumentSyntax argument;
Debug.Assert(ArgumentSyntax.IsIdentifierOfOutVariableDeclaration(identifierToken, out argument));
Debug.Assert(argument.Parent.Parent is ConstructorInitializerSyntax ?
binder.ScopeDesignator == argument.Parent :
binder.ScopeDesignator.Contains(argument.Parent.Parent));
#endif
}
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:17,代码来源:SourceLocalSymbol.cs
示例18: PossiblyImplicitlyTypedDeconstructionLocalSymbol
public PossiblyImplicitlyTypedDeconstructionLocalSymbol(
Symbol containingSymbol,
Binder binder,
TypeSyntax typeSyntax,
SyntaxToken identifierToken,
LocalDeclarationKind declarationKind)
: base(containingSymbol, binder, RefKind.None, typeSyntax, identifierToken, declarationKind)
{
SyntaxNode parent;
Debug.Assert(SyntaxFacts.IsDeconstructionIdentifier(identifierToken, out parent) &&
parent != null &&
parent.Kind() == SyntaxKind.DeconstructionDeclarationStatement ||
parent.Kind() == SyntaxKind.ForStatement ||
parent.Kind() == SyntaxKind.ForEachComponentStatement);
}
开发者ID:Shiney,项目名称:roslyn,代码行数:15,代码来源:SourceLocalSymbol.cs
示例19: MakeLocal
public static SourceLocalSymbol MakeLocal(
Symbol containingSymbol,
Binder binder,
RefKind refKind,
TypeSyntax typeSyntax,
SyntaxToken identifierToken,
LocalDeclarationKind declarationKind,
EqualsValueClauseSyntax initializer = null)
{
Debug.Assert(declarationKind != LocalDeclarationKind.ForEachIterationVariable);
if (initializer == null)
{
DeclarationExpressionSyntax declarationExpression;
if (identifierToken.IsIdentifierOfOutVariableDeclaration(out declarationExpression))
{
if (declarationExpression.Type().IsVar)
{
return new PossiblyImplicitlyTypedOutVarLocalSymbol(containingSymbol, binder, refKind, typeSyntax, identifierToken, declarationKind);
}
}
return new SourceLocalSymbol(containingSymbol, binder, refKind, typeSyntax, identifierToken, declarationKind);
}
return new LocalWithInitializer(containingSymbol, binder, refKind, typeSyntax, identifierToken, initializer, declarationKind);
}
开发者ID:Shiney,项目名称:roslyn,代码行数:26,代码来源:SourceLocalSymbol.cs
示例20: BindVariableDeclaration
protected BoundLocalDeclaration BindVariableDeclaration(
SourceLocalSymbol localSymbol,
LocalDeclarationKind kind,
bool isVar,
VariableDeclaratorSyntax declarator,
TypeSyntax typeSyntax,
TypeSymbol declTypeOpt,
AliasSymbol aliasOpt,
DiagnosticBag diagnostics,
CSharpSyntaxNode associatedSyntaxNode = null)
{
Debug.Assert(declarator != null);
Debug.Assert((object)declTypeOpt != null || isVar);
Debug.Assert(typeSyntax != null);
var localDiagnostics = DiagnosticBag.GetInstance();
// if we are not given desired syntax, we use declarator
associatedSyntaxNode = associatedSyntaxNode ?? declarator;
bool hasErrors = false;
BoundExpression initializerOpt;
// Check for variable declaration errors.
hasErrors |= this.ValidateDeclarationNameConflictsInScope(localSymbol, localDiagnostics);
EqualsValueClauseSyntax equalsValueClauseSyntax = declarator.Initializer;
if (isVar)
{
aliasOpt = null;
var binder = new ImplicitlyTypedLocalBinder(this, localSymbol);
initializerOpt = binder.BindInferredVariableInitializer(localDiagnostics, equalsValueClauseSyntax, declarator);
// If we got a good result then swap the inferred type for the "var"
if ((object)initializerOpt?.Type != null)
{
declTypeOpt = initializerOpt.Type;
if (declTypeOpt.SpecialType == SpecialType.System_Void)
{
Error(localDiagnostics, ErrorCode.ERR_ImplicitlyTypedVariableAssignedBadValue, declarator, declTypeOpt);
declTypeOpt = CreateErrorType("var");
hasErrors = true;
}
if (!declTypeOpt.IsErrorType())
{
if (declTypeOpt.IsStatic)
{
Error(localDiagnostics, ErrorCode.ERR_VarDeclIsStaticClass, typeSyntax, initializerOpt.Type);
hasErrors = true;
}
}
}
else
{
declTypeOpt = CreateErrorType("var");
hasErrors = true;
}
}
else
{
if (ReferenceEquals(equalsValueClauseSyntax, null))
{
initializerOpt = null;
}
else
{
// Basically inlined BindVariableInitializer, but with conversion optional.
initializerOpt = BindPossibleArrayInitializer(equalsValueClauseSyntax.Value, declTypeOpt, localDiagnostics);
if (kind != LocalDeclarationKind.FixedVariable)
{
// If this is for a fixed statement, we'll do our own conversion since there are some special cases.
initializerOpt = GenerateConversionForAssignment(declTypeOpt, initializerOpt, localDiagnostics);
}
}
}
Debug.Assert((object)declTypeOpt != null);
if (kind == LocalDeclarationKind.FixedVariable)
{
// NOTE: this is an error, but it won't prevent further binding.
if (isVar)
{
if (!hasErrors)
{
Error(localDiagnostics, ErrorCode.ERR_ImplicitlyTypedLocalCannotBeFixed, declarator);
hasErrors = true;
}
}
if (!declTypeOpt.IsPointerType())
{
if (!hasErrors)
{
Error(localDiagnostics, ErrorCode.ERR_BadFixedInitType, declarator);
hasErrors = true;
}
//.........这里部分代码省略.........
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:101,代码来源:Binder_Statements.cs
注:本文中的LocalDeclarationKind类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论