Example #1
0
 // LoopStatement
 private void DefaultWalk(LoopStatement node)
 {
     if (Walk(node))
     {
         WalkNode(node.Test);
         WalkNode(node.Increment);
         WalkNode(node.Body);
         WalkNode(node.ElseStatement);
     }
     PostWalk(node);
 }
Example #2
0
 // LoopStatement
 private void Dump(LoopStatement node)
 {
     Out(".for (; ");
     WalkNode(node.Test);
     Out("; ");
     WalkNode(node.Increment);
     Out(") {", Flow.NewLine);
     Indent();
     WalkNode(node.Body);
     Dedent();
     Out(Flow.NewLine, "}");
 }
Example #3
0
        // LoopStatement
        private Statement Rewrite(LoopStatement node)
        {
            Expression test  = RewriteExpressionFreeTemps(node.Test);
            Expression incr  = RewriteExpressionFreeTemps(node.Increment);
            Statement  body  = RewriteStatement(node.Body);
            Statement  @else = RewriteStatement(node.ElseStatement);

            if (((object)test != (object)node.Test) ||
                ((object)incr != (object)node.Increment) ||
                ((object)body != (object)node.Body) ||
                ((object)@else != (object)node.ElseStatement))
            {
                return(Ast.Loop(node.Span, node.Header, test, incr, body, @else));
            }
            else
            {
                return(node);
            }
        }
Example #4
0
        // LoopStatement
        protected internal override bool Walk(LoopStatement node)
        {
            // Expression is executed always at least once
            if (node.Test != null)
            {
                WalkNode(node.Test);
            }

            // Beyond this point, either body will be executed (test succeeded),
            // or else is getting executed (test failed). There is no guarantee
            // that both will be executed, though.
            BitArray opte = new BitArray(_bits);
            BitArray exit = new BitArray(_bits.Length, true);

            PushStatement(exit);
            WalkNode(node.Body);
            WalkNode(node.Increment);
            PopStatement();

            _bits.And(exit);

            if (node.ElseStatement != null)
            {
                // Flow the else
                BitArray save = _bits;
                _bits = opte;
                WalkNode(node.ElseStatement);
                // Restore the bits
                _bits = save;
            }

            // Intersect
            _bits.And(opte);

            return(false);
        }
 //
 // Nodes that may take a long time to execute
 //
 protected internal override bool Walk(LoopStatement node) {
     _hasLoops = true;
     return false;
 }
Example #6
0
 protected internal override void PostWalk(LoopStatement node)
 {
     _nesting--;
 }
Example #7
0
        // Keep track of nested loops, only loop flow control
        // statements outside of nested loops concern us

        protected internal override bool Walk(LoopStatement node)
        {
            _nesting++;
            return(true);
        }
Example #8
0
        // LoopStatement
        protected internal override bool Walk(LoopStatement node)
        {
            // Expression is executed always at least once
            if (node.Test != null) {
                WalkNode(node.Test);
            }

            // Beyond this point, either body will be executed (test succeeded),
            // or else is getting executed (test failed). There is no guarantee
            // that both will be executed, though.
            BitArray opte = new BitArray(_bits);
            BitArray exit = new BitArray(_bits.Length, true);

            PushStatement(exit);
            WalkNode(node.Body);
            WalkNode(node.Increment);
            PopStatement();

            _bits.And(exit);

            if (node.ElseStatement != null) {
                // Flow the else
                BitArray save = _bits;
                _bits = opte;
                WalkNode(node.ElseStatement);
                // Restore the bits
                _bits = save;
            }

            // Intersect
            _bits.And(opte);

            return false;
        }
Example #9
0
 // LoopStatement
 private void DefaultWalk(LoopStatement node)
 {
     if (Walk(node)) {
         WalkNode(node.Test);
         WalkNode(node.Increment);
         WalkNode(node.Body);
         WalkNode(node.ElseStatement);
     }
     PostWalk(node);
 }
Example #10
0
 // Keep track of nested loops, only loop flow control
 // statements outside of nested loops concern us
 protected internal override bool Walk(LoopStatement node)
 {
     _nesting++;
     return true;
 }
Example #11
0
 protected internal override void PostWalk(LoopStatement node)
 {
     _nesting--;
 }
 //
 // Nodes that may take a long time to execute
 //
 protected internal override bool Walk(LoopStatement node)
 {
     _hasLoops = true;
     return(false);
 }