Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 import 'package:kernel/ast.dart' as ir; | |
| 2 | |
| 3 /// Helper class that traverses a kernel AST subtree to see if it has any | |
| 4 /// continue statements in the body of any switch cases (having continue | |
| 5 /// statements results in a more complex generated code). | |
| 6 class ContinueVisitor extends ir.Visitor { | |
|
sra1
2017/01/14 03:18:22
Perhaps call is something more specific, e.g. Swit
Emily Fortuna
2017/01/17 23:33:09
Done.
| |
| 7 bool containsContinue; | |
| 8 | |
| 9 ContinueVisitor(ir.Statement switchCaseBody) { | |
| 10 containsContinue = false; | |
| 11 switchCaseBody.accept(this); | |
| 12 } | |
|
sra1
2017/01/14 03:18:23
If there are new statements, will this do the righ
Emily Fortuna
2017/01/17 23:33:09
Done.
| |
| 13 | |
| 14 void visitContinueSwitchStatement(ir.ContinueSwitchStatement continueStmt) { | |
| 15 containsContinue = true; | |
|
sra1
2017/01/14 03:18:23
Do we want to know if it targets a specific switch
Emily Fortuna
2017/01/17 23:33:09
added TODO
| |
| 16 } | |
| 17 | |
| 18 void visitBlock(ir.Block block) { | |
| 19 for (ir.Statement statement in block.statements) { | |
| 20 statement.accept(this); | |
| 21 } | |
| 22 } | |
| 23 | |
| 24 void visitLabeledStatement(ir.LabeledStatement statement) { | |
| 25 statement.body.accept(this); | |
| 26 } | |
| 27 | |
| 28 void visitDoStatement(ir.DoStatement doStatement) { | |
| 29 doStatement.body.accept(this); | |
| 30 } | |
| 31 | |
| 32 void visitForStatement(ir.ForStatement forStatement) { | |
| 33 forStatement.body.accept(this); | |
| 34 } | |
| 35 | |
| 36 void visitForInStatement(ir.ForInStatement forInStatement) { | |
| 37 forInStatement.body.accept(this); | |
| 38 } | |
| 39 | |
| 40 void visitSwitchStatement(ir.SwitchStatement switchStatement) { | |
| 41 for (var switchCase in switchStatement.cases) { | |
| 42 switchCase.accept(this); | |
| 43 } | |
| 44 } | |
| 45 | |
| 46 void visitSwitchCase(ir.SwitchCase switchCase) { | |
| 47 switchCase.body.accept(this); | |
| 48 } | |
| 49 | |
| 50 void visitIfStatement(ir.IfStatement ifStatement) { | |
| 51 ifStatement.then.accept(this); | |
| 52 ifStatement.otherwise?.accept(this); | |
| 53 } | |
| 54 | |
| 55 void visitTryCatch(ir.TryCatch tryCatch) { | |
| 56 tryCatch.body.accept(this); | |
| 57 for (var catchStatement in tryCatch.catches) { | |
| 58 catchStatement.accept(this); | |
| 59 } | |
| 60 } | |
| 61 | |
| 62 void visitCatch(ir.Catch catchStatement) { | |
| 63 catchStatement.body.accept(this); | |
| 64 } | |
| 65 | |
| 66 void visitTryFinally(ir.TryFinally tryFinally) { | |
| 67 tryFinally.body.accept(this); | |
| 68 tryFinally.finalizer.accept(this); | |
| 69 } | |
| 70 | |
| 71 void visitFunctionDeclaration(ir.FunctionDeclaration declaration) { | |
| 72 declaration.function.accept(this); | |
| 73 } | |
| 74 | |
| 75 void visitFunctionNode(ir.FunctionNode node) { | |
| 76 node.body.accept(this); | |
| 77 } | |
| 78 } | |
| OLD | NEW |