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

Side by Side Diff: pkg/compiler/lib/src/tree_ir/optimization/loop_rewriter.dart

Issue 1859343004: dartfmt pkg/compiler (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library tree_ir.optimization.loop_rewriter; 5 library tree_ir.optimization.loop_rewriter;
6 6
7 import 'optimization.dart' show Pass; 7 import 'optimization.dart' show Pass;
8 import '../tree_ir_nodes.dart'; 8 import '../tree_ir_nodes.dart';
9 9
10 /// Rewrites [WhileTrue] statements into [For] statements. 10 /// Rewrites [WhileTrue] statements into [For] statements.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 /// ==> 66 /// ==>
67 /// L: 67 /// L:
68 /// for (; condition; updates, x = E) { 68 /// for (; condition; updates, x = E) {
69 /// S [ continue L ] 69 /// S [ continue L ]
70 /// } 70 /// }
71 /// 71 ///
72 /// The decision to only pull in assignments is a heuristic to balance 72 /// The decision to only pull in assignments is a heuristic to balance
73 /// readability and stack trace usability versus the modest code size 73 /// readability and stack trace usability versus the modest code size
74 /// reduction one might get by aggressively moving expressions into the 74 /// reduction one might get by aggressively moving expressions into the
75 /// updates. 75 /// updates.
76 class LoopRewriter extends RecursiveTransformer 76 class LoopRewriter extends RecursiveTransformer implements Pass {
77 implements Pass {
78 String get passName => 'Loop rewriter'; 77 String get passName => 'Loop rewriter';
79 78
80 Set<Label> usedContinueLabels = new Set<Label>(); 79 Set<Label> usedContinueLabels = new Set<Label>();
81 80
82 /// Maps loop labels to a list, if that loop can accept update expressions. 81 /// Maps loop labels to a list, if that loop can accept update expressions.
83 /// The list will then be populated while traversing the body of that loop. 82 /// The list will then be populated while traversing the body of that loop.
84 /// If a loop is not in the map, update expressions cannot be hoisted there. 83 /// If a loop is not in the map, update expressions cannot be hoisted there.
85 Map<Label, List<Expression>> updateExpressions = <Label, List<Expression>>{}; 84 Map<Label, List<Expression>> updateExpressions = <Label, List<Expression>>{};
86 85
87 void rewrite(FunctionDefinition root) { 86 void rewrite(FunctionDefinition root) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } else { 186 } else {
188 return next; 187 return next;
189 } 188 }
190 } 189 }
191 } 190 }
192 // The expression statements could not be pulled into a loop update. 191 // The expression statements could not be pulled into a loop update.
193 node.next = next; 192 node.next = next;
194 return statements.first; 193 return statements.first;
195 } 194 }
196 } 195 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698