Esempio n. 1
0
        private DeconstructionVariable BindDeconstructionDeclarationLocals(VariableComponentSyntax node, DiagnosticBag diagnostics)
        {
            switch (node.Kind())
            {
            case SyntaxKind.TypedVariableComponent:
            {
                var component = (TypedVariableComponentSyntax)node;
                return(BindDeconstructionDeclarationLocals(component.Type, component.Designation, diagnostics));
            }

            case SyntaxKind.ParenthesizedVariableComponent:
            {
                var component = (ParenthesizedVariableComponentSyntax)node;
                var builder   = ArrayBuilder <DeconstructionVariable> .GetInstance(component.Variables.Count);

                foreach (var n in component.Variables)
                {
                    builder.Add(BindDeconstructionDeclarationLocals(n, diagnostics));
                }
                return(new DeconstructionVariable(builder, node));
            }

            default:
                throw ExceptionUtilities.UnexpectedValue(node.Kind());
            }
        }
Esempio n. 2
0
        internal void CollectLocalsFromDeconstruction(
            VariableComponentSyntax declaration,
            LocalDeclarationKind kind,
            ArrayBuilder <LocalSymbol> locals,
            SyntaxNode deconstructionStatement,
            Binder enclosingBinderOpt = null)
        {
            switch (declaration.Kind())
            {
            case SyntaxKind.ParenthesizedVariableComponent:
            {
                var component = (ParenthesizedVariableComponentSyntax)declaration;
                foreach (var decl in component.Variables)
                {
                    CollectLocalsFromDeconstruction(decl, kind, locals, deconstructionStatement, enclosingBinderOpt);
                }
                break;
            }

            case SyntaxKind.TypedVariableComponent:
            {
                var component = (TypedVariableComponentSyntax)declaration;
                CollectLocalsFromDeconstruction(component.Designation, component.Type, kind, locals, deconstructionStatement, enclosingBinderOpt);
                break;
            }

            default:
                throw ExceptionUtilities.UnexpectedValue(declaration.Kind());
            }
        }
Esempio n. 3
0
            private void AddVariableExpressions(
                VariableComponentSyntax component,
                IList <string> expressions)
            {
                if (!_includeDeclarations)
                {
                    return;
                }

                switch (component.Kind())
                {
                case SyntaxKind.ParenthesizedVariableComponent:
                {
                    var t = (ParenthesizedVariableComponentSyntax)component;
                    foreach (var v in t.Variables)
                    {
                        AddVariableExpressions(component, expressions);
                    }
                    break;
                }

                case SyntaxKind.TypedVariableComponent:
                {
                    var t = (TypedVariableComponentSyntax)component;
                    AddVariableExpressions(t.Designation, expressions);
                    break;
                }
                }
            }
Esempio n. 4
0
 private DeconstructionVariable BindDeconstructionDeclarationLocals(VariableComponentSyntax node, DiagnosticBag diagnostics)
 {
     switch (node.Kind())
     {
         case SyntaxKind.TypedVariableComponent:
             {
                 var component = (TypedVariableComponentSyntax)node;
                 return BindDeconstructionDeclarationLocals(component.Type, component.Designation, diagnostics);
             }
         case SyntaxKind.ParenthesizedVariableComponent:
             {
                 var component = (ParenthesizedVariableComponentSyntax)node;
                 var builder = ArrayBuilder<DeconstructionVariable>.GetInstance(component.Variables.Count);
                 foreach (var n in component.Variables)
                 {
                     builder.Add(BindDeconstructionDeclarationLocals(n, diagnostics));
                 }
                 return new DeconstructionVariable(builder, node);
             }
         default:
             throw ExceptionUtilities.UnexpectedValue(node.Kind());
     }
 }
            private void AddVariableExpressions(
                VariableComponentSyntax component,
                IList<string> expressions)
            {
                if (!_includeDeclarations) return;

                switch (component.Kind())
                {
                    case SyntaxKind.ParenthesizedVariableComponent:
                        {
                            var t = (ParenthesizedVariableComponentSyntax)component;
                            foreach (var v in t.Variables) AddVariableExpressions(component, expressions);
                            break;
                        }
                    case SyntaxKind.TypedVariableComponent:
                        {
                            var t = (TypedVariableComponentSyntax)component;
                            AddVariableExpressions(t.Designation, expressions);
                            break;
                        }
                }
            }