Exemplo n.º 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);
 }
Exemplo n.º 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, "}");
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 5
0
 //
 // Nodes that may take a long time to execute
 //
 protected internal override bool Walk(LoopStatement node) {
     _hasLoops = true;
     return false;
 }
Exemplo n.º 6
0
 protected internal override void PostWalk(LoopStatement node)
 {
     _nesting--;
 }
Exemplo n.º 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);
        }
Exemplo n.º 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;
        }
Exemplo n.º 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);
 }
Exemplo n.º 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;
 }
Exemplo n.º 11
0
 protected internal override void PostWalk(LoopStatement node)
 {
     _nesting--;
 }
Exemplo n.º 12
0
 //
 // Nodes that may take a long time to execute
 //
 protected internal override bool Walk(LoopStatement node)
 {
     _hasLoops = true;
     return(false);
 }