コード例 #1
0
        internal override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, StatementSyntax statement, out SemanticModel speculativeModel)
        {
            position = CheckAndAdjustPosition(position);

            var binder = this.GetEnclosingBinder(position);

            if (binder == null)
            {
                speculativeModel = null;
                return(false);
            }

            var methodSymbol = (MethodSymbol)this.MemberSymbol;

            binder = new ExecutableCodeBinder(statement, methodSymbol, binder);

            // local declaration statements need to be wrapped in a block so the local gets seen
            if (!statement.IsKind(SyntaxKind.Block))
            {
                binder = new BlockBinder(binder, new SyntaxList <StatementSyntax>(statement));
            }

            speculativeModel = CreateSpeculative(parentModel, methodSymbol, statement, binder, position);
            return(true);
        }
コード例 #2
0
ファイル: LocalBinderFactory.cs プロジェクト: shashinh/roslyn
        private void VisitPossibleEmbeddedStatement(StatementSyntax statement, Binder enclosing)
        {
            if (statement != null)
            {
                switch (statement.Kind())
                {
                case SyntaxKind.LocalDeclarationStatement:
                case SyntaxKind.LabeledStatement:
                case SyntaxKind.LocalFunctionStatement:
                    // It is an error to have a declaration or a label in an embedded statement,
                    // but we still want to bind it.  We'll pretend that the statement was
                    // inside a block.

                    Debug.Assert((object)_containingMemberOrLambda == enclosing.ContainingMemberOrLambda);
                    var blockBinder = new BlockBinder(enclosing, new SyntaxList <StatementSyntax>(statement));
                    AddToMap(statement, blockBinder);
                    Visit(statement, blockBinder);
                    return;

                default:
                    break;
                }

                Visit(statement, enclosing);
            }
        }
コード例 #3
0
        // Top-level block has an enclosing that is not a BinderContext. All others must (so that variables can be declared).
        public override void VisitBlock(BlockSyntax node)
        {
            var blockBinder = new BlockBinder(this.method, enclosing, node.Statements);

            AddToMap(node, blockBinder);

            // Visit all the statements inside this block
            foreach (StatementSyntax statement in node.Statements)
            {
                Visit(statement, blockBinder);
            }
        }
コード例 #4
0
ファイル: LocalBinderFactory.cs プロジェクト: tmds/roslyn
        // Top-level block has an enclosing that is not a BinderContext. All others must (so that variables can be declared).
        public override void VisitBlock(BlockSyntax node)
        {
            Debug.Assert((object)_containingMemberOrLambda == _enclosing.ContainingMemberOrLambda);
            var blockBinder = new BlockBinder(_enclosing, node);

            AddToMap(node, blockBinder);

            // Visit all the statements inside this block
            foreach (StatementSyntax statement in node.Statements)
            {
                Visit(statement, blockBinder);
            }
        }
コード例 #5
0
        private void VisitPossibleEmbeddedStatement(StatementSyntax statement, Binder enclosing)
        {
            if (statement != null)
            {
                switch (statement.Kind)
                {
                case SyntaxKind.LocalDeclarationStatement:
                case SyntaxKind.LabeledStatement:
                    // It is an error to have a declaration or a label in an embedded statement,
                    // but we still want to bind it.  We'll pretend that the statement was
                    // inside a block.

                    Debug.Assert((object)this.method == enclosing.ContainingMemberOrLambda);
                    var blockBinder = new BlockBinder(enclosing, new SyntaxList <StatementSyntax>(statement));
                    AddToMap(statement, blockBinder);
                    Visit(statement, blockBinder);
                    return;

                case SyntaxKind.Block:
                case SyntaxKind.UsingStatement:
                case SyntaxKind.WhileStatement:
                case SyntaxKind.DoStatement:
                case SyntaxKind.ForStatement:
                case SyntaxKind.ForEachStatement:
                case SyntaxKind.FixedStatement:
                case SyntaxKind.LockStatement:
                case SyntaxKind.SwitchStatement:
                case SyntaxKind.IfStatement:
                    // These statements always have dedicated binders.
                    break;

                default:
                    // Create a binder to introduce a scope for Declaration Expressions, if any.
                    Debug.Assert((object)this.method == enclosing.ContainingMemberOrLambda);
                    enclosing = new EmbeddedStatementBinder(enclosing, statement);
                    AddToMap(statement, enclosing);
                    break;
                }
            }

            Visit(statement, enclosing);
        }
コード例 #6
0
        private void VisitPossibleEmbeddedStatement(StatementSyntax statement, Binder enclosing)
        {
            if (statement != null)
            {
                switch (statement.Kind)
                {
                case SyntaxKind.LocalDeclarationStatement:
                case SyntaxKind.LabeledStatement:
                    // It is an error to have a declaration or a label in an embedded statement,
                    // but we still want to bind it.  We'll pretend that the statement was
                    // inside a block.

                    var blockBinder = new BlockBinder(this.method, enclosing, new SyntaxList <StatementSyntax>(statement));
                    AddToMap(statement, blockBinder);
                    Visit(statement, blockBinder);
                    return;
                }
            }

            Visit(statement, enclosing);
        }
コード例 #7
0
        internal override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, StatementSyntax statement, out SemanticModel speculativeModel)
        {
            position = CheckAndAdjustPosition(position);

            var binder = this.GetEnclosingBinder(position);
            if (binder == null)
            {
                speculativeModel = null;
                return false;
            }

            var methodSymbol = (MethodSymbol)this.MemberSymbol;
            binder = new ExecutableCodeBinder(statement, methodSymbol, binder);

            // local declaration statements need to be wrapped in a block so the local gets seen 
            if (!statement.IsKind(SyntaxKind.Block))
            {
                binder = new BlockBinder(methodSymbol, binder, new SyntaxList<StatementSyntax>(statement));
            }

            speculativeModel = CreateSpeculative(parentModel, methodSymbol, statement, binder, position);
            return true;
        }
コード例 #8
0
        private void VisitPossibleEmbeddedStatement(StatementSyntax statement, Binder enclosing)
        {
            if (statement != null)
            {
                switch (statement.Kind())
                {
                    case SyntaxKind.LocalDeclarationStatement:
                    case SyntaxKind.LabeledStatement:
                        // It is an error to have a declaration or a label in an embedded statement,
                        // but we still want to bind it.  We'll pretend that the statement was
                        // inside a block.

                        Debug.Assert((object)_method == enclosing.ContainingMemberOrLambda);
                        var blockBinder = new BlockBinder(enclosing, new SyntaxList<StatementSyntax>(statement));
                        AddToMap(statement, blockBinder);
                        Visit(statement, blockBinder);
                        return;

                    case SyntaxKind.Block:
                    case SyntaxKind.UsingStatement:
                    case SyntaxKind.WhileStatement:
                    case SyntaxKind.DoStatement:
                    case SyntaxKind.ForStatement:
                    case SyntaxKind.ForEachStatement:
                    case SyntaxKind.FixedStatement:
                    case SyntaxKind.LockStatement:
                    case SyntaxKind.SwitchStatement:
                    case SyntaxKind.IfStatement:
                        // These statements always have dedicated binders.
                        break;

                    default:
                        break;
                }
            }

            Visit(statement, enclosing);
        }
コード例 #9
0
        // Top-level block has an enclosing that is not a BinderContext. All others must (so that variables can be declared).
        public override void VisitBlock(BlockSyntax node)
        {
            Debug.Assert((object)_method == _enclosing.ContainingMemberOrLambda);
            var blockBinder = new BlockBinder(_enclosing, node.Statements);
            AddToMap(node, blockBinder);

            // Visit all the statements inside this block
            foreach (StatementSyntax statement in node.Statements)
            {
                Visit(statement, blockBinder);
            }
        }
コード例 #10
0
ファイル: LocalBinderFactory.cs プロジェクト: CAPCHIK/roslyn
        private void VisitPossibleEmbeddedStatement(StatementSyntax statement, Binder enclosing)
        {
            if (statement != null)
            {
                switch (statement.Kind())
                {
                    case SyntaxKind.LocalDeclarationStatement:
                    case SyntaxKind.LabeledStatement:
                    case SyntaxKind.LocalFunctionStatement:
                        // It is an error to have a declaration or a label in an embedded statement,
                        // but we still want to bind it.  We'll pretend that the statement was
                        // inside a block.

                        Debug.Assert((object)_containingMemberOrLambda == enclosing.ContainingMemberOrLambda);
                        var blockBinder = new BlockBinder(enclosing, new SyntaxList<StatementSyntax>(statement));
                        AddToMap(statement, blockBinder);
                        Visit(statement, blockBinder);
                        return;

                    default:
                        break;
                }

                Visit(statement, enclosing);
            }
        }
コード例 #11
0
ファイル: LocalBinderFactory.cs プロジェクト: riversky/roslyn
        private void VisitPossibleEmbeddedStatement(StatementSyntax statement, Binder enclosing)
        {
            if (statement != null)
            {
                switch (statement.Kind)
                {
                    case SyntaxKind.LocalDeclarationStatement:
                    case SyntaxKind.LabeledStatement:
                        // It is an error to have a declaration or a label in an embedded statement,
                        // but we still want to bind it.  We'll pretend that the statement was
                        // inside a block.

                        var blockBinder = new BlockBinder(this.method, enclosing, new SyntaxList<StatementSyntax>(statement));
                        AddToMap(statement, blockBinder);
                        Visit(statement, blockBinder);
                        return;
                }
            }

            Visit(statement, enclosing);
        }
コード例 #12
0
ファイル: LocalBinderFactory.cs プロジェクト: riversky/roslyn
        // Top-level block has an enclosing that is not a BinderContext. All others must (so that variables can be declared).
        public override void VisitBlock(BlockSyntax node)
        {
            var blockBinder = new BlockBinder(this.method, enclosing, node.Statements);
            AddToMap(node, blockBinder);

            // Visit all the statements inside this block
            foreach (StatementSyntax statement in node.Statements)
            {
                Visit(statement, blockBinder);
            }
        }