コード例 #1
0
        public override bool Walk(ForNode node)
        {
            if (node != null)
            {
                if (node.Initializer != null)
                {
                    // if the variable portion of the for-in statement is a lexical
                    // declaration, then we will create the block node for its body right now
                    // and add the declaration. This will prevent the body from both creating
                    // a new lexical scope and from deleting an empty one.
                    var lexDeclaration = node.Initializer as LexicalDeclaration;
                    if (lexDeclaration != null)
                    {
                        // create the scope on the block
                        SetScope(
                            node,
                            new BlockScope(node, CurrentLexicalScope, _errorSink)
                        {
                            IsInWithScope = m_withDepth > 0
                        }
                            );
                        m_lexicalStack.Push(GetScope(node));
                    }
                }

                try
                {
                    if (node.Initializer != null)
                    {
                        node.Initializer.Walk(this);
                    }

                    if (node.Condition != null)
                    {
                        node.Condition.Walk(this);
                    }

                    if (node.Body != null)
                    {
                        node.Body.Walk(this);
                    }

                    if (node.Incrementer != null)
                    {
                        node.Incrementer.Walk(this);
                    }
                }
                finally
                {
                    if (GetScope(node) != null)
                    {
                        Debug.Assert(CurrentLexicalScope == GetScope(node));
                        m_lexicalStack.Pop();
                    }
                }
            }
            return(false);
        }
コード例 #2
0
        public override bool Walk(ForNode node) {
            ReplaceControlFlowWhiteSpace(node, "for".Length);

            if (node.Initializer != null) {
                ReplacePreceedingWhiteSpace(
                    node.Initializer.GetStartIndex(_tree.LocationResolver),
                    _options.SpaceAfterOpeningAndBeforeClosingNonEmptyParenthesis ? " " : "",
                    _openParen
                );

                node.Initializer.Walk(this);
            }

            if (node.Condition != null) {
                ReplacePreceedingWhiteSpace(
                    node.Condition.GetStartIndex(_tree.LocationResolver),
                    _options.SpaceAfterSemiColonInFor ? " " : "",
                    _semicolon
                );

                node.Condition.Walk(this);
            }
            if (node.Incrementer != null) {
                ReplacePreceedingWhiteSpace(node.Incrementer.GetStartIndex(_tree.LocationResolver), _options.SpaceAfterSemiColonInFor ? " " : "", _semicolon);
                node.Incrementer.Walk(this);

                ReplaceFollowingWhiteSpace(
                    node.Incrementer.GetEndIndex(_tree.LocationResolver),
                    _options.SpaceAfterOpeningAndBeforeClosingNonEmptyParenthesis ? " " : ""
                );
            }

            if (node.HeaderEnd != -1) {
                WalkFlowControlBlockWithOptionalParens(node.Body, node.HeaderEnd, false);
            }
            return false;
        }
コード例 #3
0
 public override bool Walk(ForNode node) {
     UpdateChildRanges(node);
     return base.Walk(node);
 }
コード例 #4
0
 public override bool Walk(ForNode node) { AddNode(node); return true; }
コード例 #5
0
        public override bool Walk(ForNode node)
        {
            if (node != null)
            {
                if (node.Initializer != null)
                {
                    // if the variable portion of the for-in statement is a lexical
                    // declaration, then we will create the block node for its body right now
                    // and add the declaration. This will prevent the body from both creating
                    // a new lexical scope and from deleting an empty one.
                    var lexDeclaration = node.Initializer as LexicalDeclaration;
                    if (lexDeclaration != null)
                    {
                        // create the scope on the block
                        SetScope(
                            node,
                            new BlockScope(node, CurrentLexicalScope, _errorSink)
                            {
                                IsInWithScope = m_withDepth > 0
                            }
                        );
                        m_lexicalStack.Push(GetScope(node));
                    }
                }

                try
                {
                    if (node.Initializer != null)
                    {
                        node.Initializer.Walk(this);
                    }

                    if (node.Condition != null)
                    {
                        node.Condition.Walk(this);
                    }

                    if (node.Body != null)
                    {
                        node.Body.Walk(this);
                    }

                    if (node.Incrementer != null)
                    {
                        node.Incrementer.Walk(this);
                    }
                }
                finally
                {
                    if (GetScope(node) != null)
                    {
                        Debug.Assert(CurrentLexicalScope == GetScope(node));
                        m_lexicalStack.Pop();
                    }
                }
            }
            return false;
        }
コード例 #6
0
 public override bool Walk(ForNode node) {
     if (CheckBlock(node.Body)) {
         Span = GetTargetStatement(node).GetSpan(_tree.LocationResolver);
         return false;
     }
     return base.Walk(node);
 }