예제 #1
0
        // Compound Statements: if, while, for, try, with, func, class, decorated
        public override bool Walk(IfStatement node) {
            if (node.ElseStatement != null) {
                AddTagIfNecessary(node.ElseStatement, node.ElseIndex);
            }

            return base.Walk(node);
        }
예제 #2
0
파일: Parser.cs 프로젝트: omnimark/PTVS
        // if_stmt: 'if' expression ':' suite ('elif' expression ':' suite)* ['else' ':' suite]
        private IfStatement ParseIfStmt() {
            Eat(TokenKind.KeywordIf);
            var itemWhiteSpace = MakeWhiteSpaceList();
            if (itemWhiteSpace != null) {
                itemWhiteSpace.Add(_tokenWhiteSpace);
            }
            
            var start = GetStart();
            List<IfStatementTest> l = new List<IfStatementTest>();
            l.Add(ParseIfStmtTest());

            while (MaybeEat(TokenKind.KeywordElseIf)) {
                if (itemWhiteSpace != null) {
                    itemWhiteSpace.Add(_tokenWhiteSpace);
                }
                l.Add(ParseIfStmtTest());
            }

            Statement else_ = null;
            string elseWhiteSpace = null;
            if (MaybeEat(TokenKind.KeywordElse)) {
                elseWhiteSpace = _tokenWhiteSpace;
                else_ = ParseSuite();
            }

            IfStatementTest[] tests = l.ToArray();
            IfStatement ret = new IfStatement(tests, else_);
            if (_verbatim) {
                if (elseWhiteSpace != null) {
                    AddPreceedingWhiteSpace(ret, elseWhiteSpace);
                }
                if (itemWhiteSpace != null) {
                    AddListWhiteSpace(ret, itemWhiteSpace.ToArray());
                }
            }
            ret.SetLoc(start, else_ != null ? else_.EndIndex : tests[tests.Length - 1].EndIndex);
            return ret;
        }
예제 #3
0
 public override bool Walk(IfStatement node) {
     return base.Walk(node);
 }
예제 #4
0
        public override bool Walk(IfStatement node) {
            foreach (var test in node.Tests) {
                UpdateLineInfo(test.Test);
                AddBlock();

                if (test.Body != null) {
                    test.Body.Walk(this);
                } else {
                    ReportNotCovered();
                }
            }

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

            AddBlock();

            return false;
        }
예제 #5
0
        public override bool Walk(IfStatement node) {
            UpdateChildRanges(node);
            if (node.Tests != null) {
                foreach (var test in node.Tests) {
                    var isInstanceNames = GetIsInstanceNamesAndExpressions(test.Test);
                    if (isInstanceNames != null) {
                        if (test.Test != null) {
                            test.Test.Walk(this);
                        }

                        if (test.Body != null && !(test.Body is ErrorStatement)) {
                            Debug.Assert(test.Body is SuiteStatement);

                            PushIsInstanceScope(test, isInstanceNames, (SuiteStatement)test.Body);

                            test.Body.Walk(this);
                        }
                    } else {
                        test.Walk(this);
                    }
                }
            }
            if (node.ElseStatement != null) {
                node.ElseStatement.Walk(this);
            }
            return false;
        }
예제 #6
0
            public override bool Walk(IfStatement node) {
                bool allReturn = true;
                for (int i = 0; i < node.Tests.Count; i++) {
                    _raises = Returns = false;
                    node.Tests[i].Body.Walk(this);

                    allReturn &= Returns || _raises;
                }

                _raises = Returns = false;
                if (node.ElseStatement != null) {
                    node.ElseStatement.Walk(this);

                    allReturn &= Returns || _raises;
                } else {
                    allReturn = false;
                }


                Returns = allReturn;
                return false;
            }
예제 #7
0
        // IfStmt
        public 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
                ist.Test.Walk(this);
                // Flow the body
                ist.Body.Walk(this);
                // Intersect
                result.And(_bits);
            }

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

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

            // Intersect
            result.And(_bits);

            _bits = save;

            // Remember the result
            _bits.SetAll(false);
            _bits.Or(result);
            return false;
        }
예제 #8
0
 public override void PostWalk(IfStatement node) { PostWalkWorker(node); }
예제 #9
0
 // IfStatement
 public override bool Walk(IfStatement node) { return ShouldWalkWorker(node); }
예제 #10
0
 public override bool Walk(IfStatement node)
 {
     return(base.Walk(node));
 }