// 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); }
// 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; }
public override bool Walk(IfStatement node) { return base.Walk(node); }
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; }
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; }
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; }
// 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; }
public override void PostWalk(IfStatement node) { PostWalkWorker(node); }
// IfStatement public override bool Walk(IfStatement node) { return ShouldWalkWorker(node); }
public override bool Walk(IfStatement node) { return(base.Walk(node)); }