Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: pkg/compiler/lib/src/ssa/switch_continue_analysis.dart

Issue 2682553002: Fix lingering switch statement test failures. (Closed)
Patch Set: associateNode Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import 'package:kernel/ast.dart' as ir; 1 import 'package:kernel/ast.dart' as ir;
2 2
3 /// Helper class that traverses a kernel AST subtree to see if it has any 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 4 /// continue statements in the body of any switch cases (having continue
5 /// statements results in a more complex generated code). 5 /// statements results in a more complex generated code).
6 class SwitchContinueAnalysis extends ir.Visitor<bool> { 6 class SwitchContinueAnalysis extends ir.Visitor<bool> {
7 SwitchContinueAnalysis._(); 7 SwitchContinueAnalysis._();
8 8
9 static bool containsContinue(ir.Statement switchCaseBody) { 9 static bool containsContinue(ir.Statement switchCaseBody) {
10 return switchCaseBody.accept(new SwitchContinueAnalysis._()); 10 return switchCaseBody.accept(new SwitchContinueAnalysis._());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 } 50 }
51 } 51 }
52 return false; 52 return false;
53 } 53 }
54 54
55 bool visitSwitchCase(ir.SwitchCase switchCase) { 55 bool visitSwitchCase(ir.SwitchCase switchCase) {
56 return switchCase.body.accept(this); 56 return switchCase.body.accept(this);
57 } 57 }
58 58
59 bool visitIfStatement(ir.IfStatement ifStatement) { 59 bool visitIfStatement(ir.IfStatement ifStatement) {
60 if (ifStatement.then.accept(this)) { 60 return ifStatement.then.accept(this) ||
61 if (ifStatement.otherwise != null) { 61 (ifStatement.otherwise != null && ifStatement.otherwise.accept(this));
62 return ifStatement.otherwise.accept(this);
63 }
64 }
65 return false;
66 } 62 }
67 63
68 bool visitTryCatch(ir.TryCatch tryCatch) { 64 bool visitTryCatch(ir.TryCatch tryCatch) {
69 if (tryCatch.body.accept(this)) { 65 if (tryCatch.body.accept(this)) {
70 for (var catchStatement in tryCatch.catches) { 66 for (var catchStatement in tryCatch.catches) {
71 if (catchStatement.accept(this)) { 67 if (catchStatement.accept(this)) {
72 return true; 68 return true;
73 } 69 }
74 } 70 }
75 } 71 }
(...skipping 30 matching lines...) Expand all
106 node is ir.YieldStatement || 102 node is ir.YieldStatement ||
107 node is ir.VariableDeclaration) { 103 node is ir.VariableDeclaration) {
108 return false; 104 return false;
109 } 105 }
110 throw 'Statement type ${node.runtimeType} not handled in ' 106 throw 'Statement type ${node.runtimeType} not handled in '
111 'SwitchContinueAnalysis'; 107 'SwitchContinueAnalysis';
112 } 108 }
113 109
114 bool defaultNode(ir.Node node) => false; 110 bool defaultNode(ir.Node node) => false;
115 } 111 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698