Пример #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());
            }
        }
Пример #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());
            }
        }
Пример #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;
                }
                }
            }
Пример #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());
     }
 }
Пример #5
0
 internal BoundDeconstructionAssignmentOperator BindDeconstructionDeclaration(CSharpSyntaxNode node, VariableComponentSyntax declaration, ExpressionSyntax right, DiagnosticBag diagnostics, BoundDeconstructValuePlaceholder rightPlaceholder = null)
 {
     DeconstructionVariable locals = BindDeconstructionDeclarationLocals(declaration, diagnostics);
     Debug.Assert(locals.HasNestedVariables);
     var result = BindDeconstructionAssignment(node, right, locals.NestedVariables, diagnostics, isDeclaration: true, rhsPlaceholder: rightPlaceholder);
     FreeDeconstructionVariables(locals.NestedVariables);
     return result;
 }
Пример #6
0
        internal BoundDeconstructionAssignmentOperator BindDeconstructionDeclaration(CSharpSyntaxNode node, VariableComponentSyntax declaration, ExpressionSyntax right, DiagnosticBag diagnostics, BoundDeconstructValuePlaceholder rightPlaceholder = null)
        {
            DeconstructionVariable locals = BindDeconstructionDeclarationLocals(declaration, diagnostics);

            Debug.Assert(locals.HasNestedVariables);
            var result = BindDeconstructionAssignment(node, right, locals.NestedVariables, diagnostics, isDeclaration: true, rhsPlaceholder: rightPlaceholder);

            FreeDeconstructionVariables(locals.NestedVariables);
            return(result);
        }
            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;
                        }
                }
            }