예제 #1
0
        // IfStatement
        protected internal override bool Walk(IfStatement node)
        {
            BitArray result = new BitArray(_bits.Length, true);
            BitArray save = _bits;

            _bits = new BitArray(_bits.Length);

            foreach (IfStatementTest ist in node.Tests) {
                // Set the initial branch value to bits
                _bits.SetAll(false);
                _bits.Or(save);

                // Flow the test first
                WalkNode(ist.Test);
                // Flow the body
                WalkNode(ist.Body);
                // Intersect
                result.And(_bits);
            }

            // Set the initial branch value to bits
            _bits.SetAll(false);
            _bits.Or(save);

            if (node.ElseStatement != null) {
                // Flow the else_
                WalkNode(node.ElseStatement);
            }

            // Intersect
            result.And(_bits);

            _bits = save;

            // Remember the result
            _bits.SetAll(false);
            _bits.Or(result);
            return false;
        }
 protected override void PostWalk(IfStatement node)
 {
     node.Tests[0].Body = Rewrite(node.Tests[0].Body);
       if (node.ElseStatement != null)
       {
     node.ElseStatement = Rewrite(node.ElseStatement);
       }
 }
예제 #3
0
 // IfStatement
 private void DefaultWalk(IfStatement node)
 {
     if (Walk(node)) {
         foreach (IfStatementTest t in node.Tests) {
             WalkNode(t);
         }
         WalkNode(node.ElseStatement);
     }
     PostWalk(node);
 }