Exemplo n.º 1
0
        public override void VisitForStatement(ForStatementSyntax node)
        {
            Debug.Assert((object)_containingMemberOrLambda == _enclosing.ContainingMemberOrLambda);
            Binder binder = new ForLoopBinder(_enclosing, node);

            AddToMap(node, binder);

            VariableDeclarationSyntax declaration = node.Declaration;

            if (declaration != null)
            {
                VisitRankSpecifiers(declaration.Type, binder);

                foreach (VariableDeclaratorSyntax variable in declaration.Variables)
                {
                    Visit(variable, binder);
                }
            }
            else
            {
                foreach (ExpressionSyntax initializer in node.Initializers)
                {
                    Visit(initializer, binder);
                }
            }

            ExpressionSyntax condition = node.Condition;

            if (condition != null)
            {
                binder = new ExpressionVariableBinder(condition, binder);
                AddToMap(condition, binder);
                Visit(condition, binder);
            }

            SeparatedSyntaxList <ExpressionSyntax> incrementors = node.Incrementors;

            if (incrementors.Count > 0)
            {
                var incrementorsBinder = new ExpressionListVariableBinder(incrementors, binder);
                AddToMap(incrementors.First(), incrementorsBinder);
                foreach (ExpressionSyntax incrementor in incrementors)
                {
                    Visit(incrementor, incrementorsBinder);
                }
            }

            VisitPossibleEmbeddedStatement(node.Statement, binder);
        }
Exemplo n.º 2
0
        public override void VisitForStatement(ForStatementSyntax node)
        {
            Debug.Assert((object)_containingMemberOrLambda == _enclosing.ContainingMemberOrLambda);
            Binder binder = new ForLoopBinder(_enclosing, node);
            AddToMap(node, binder);

            var declaration = node.Declaration;
            if (declaration != null)
            {
                foreach (var variable in declaration.Variables)
                {
                    Visit(variable, binder);
                }
            }
            else
            {
                foreach (var initializer in node.Initializers)
                {
                    Visit(initializer, binder);
                } 
            }

            ExpressionSyntax condition = node.Condition;
            if (condition != null)
            {
                binder = new ExpressionVariableBinder(condition, binder);
                AddToMap(condition, binder);
                Visit(condition, binder);
            }

            SeparatedSyntaxList<ExpressionSyntax> incrementors = node.Incrementors;
            if (incrementors.Count > 0)
            {
                var incrementorsBinder = new ExpressionListVariableBinder(incrementors, binder);
                AddToMap(incrementors.First(), incrementorsBinder);
                foreach (var incrementor in incrementors)
                {
                    Visit(incrementor, incrementorsBinder);
                }
            }

            VisitPossibleEmbeddedStatement(node.Statement, binder);
        }