Esempio n. 1
0
        public override bool Walk(ForStatement node)
        {
            node.Parent = _currentScope;
            if (_currentScope is FunctionDefinition)
                _currentScope.ShouldInterpret = false;

            //PushScope(node);

            if (node.Initialization != null)
                node.Initialization.Walk(this);

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

            if (node.Incrementation != null)
                node.Incrementation.Walk(this);

            PushLoop(node);

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

            PopLoop();

            return false;
        }
Esempio n. 2
0
        private Statement ParseForStatement()
        {
            Eat(TokenKind.KeywordFor);
            var start = GetStart();

            Eat(TokenKind.LeftParenthesis);

            Statement initialization;
            Expression condition;
            Expression incrementation;

            _openParen++;
            try
            {
                if (!PeekToken(TokenKind.Semicolon))
                    initialization = ParseStatement();
                else
                {
                    initialization = null;
                    Eat(TokenKind.Semicolon);
                }

                if (!PeekToken(TokenKind.Semicolon))
                    condition = ParseExpression();
                else
                    condition = null;
                Eat(TokenKind.Semicolon);

                if (!PeekToken(TokenKind.RightParenthesis))
                    incrementation = ParseExpression();
                else
                    incrementation = null;
                Eat(TokenKind.RightParenthesis);
            }
            finally
            {
                _openParen--;
            }

            Statement body;
            try
            {
                _inLoop = true;
                body = ParseBlockOrStatement();
            }
            finally
            {
                _inLoop = false;
            }
            if (body == null)
                return null;

            Statement ret = new ForStatement(initialization, condition, incrementation, body);
            ret.SetLoc(_globalParent, start, GetEnd());

            return ret;
        }
Esempio n. 3
0
 public override void PostWalk(ForStatement node)
 {
     //Debug.Assert(_currentScope == node);
     //PopScope();
 }