当前位置: 首页>>代码示例>>C#>>正文


C# LocalDeclarationKind类代码示例

本文整理汇总了C#中LocalDeclarationKind的典型用法代码示例。如果您正苦于以下问题:C# LocalDeclarationKind类的具体用法?C# LocalDeclarationKind怎么用?C# LocalDeclarationKind使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LocalDeclarationKind类属于命名空间,在下文中一共展示了LocalDeclarationKind类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的LocalDeclarationKind类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。