OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
6 | 6 |
7 import '../closure.dart' show LoopClosureScope; | 7 import '../closure.dart' show CapturedLoopScope; |
8 import '../elements/jumps.dart'; | 8 import '../elements/jumps.dart'; |
9 import '../io/source_information.dart'; | 9 import '../io/source_information.dart'; |
10 import '../tree/tree.dart' as ast; | 10 import '../tree/tree.dart' as ast; |
11 | 11 |
12 import 'builder.dart'; | 12 import 'builder.dart'; |
13 import 'builder_kernel.dart'; | 13 import 'builder_kernel.dart'; |
14 import 'graph_builder.dart'; | 14 import 'graph_builder.dart'; |
15 import 'jump_handler.dart'; | 15 import 'jump_handler.dart'; |
16 import 'locals_handler.dart'; | 16 import 'locals_handler.dart'; |
17 import 'nodes.dart'; | 17 import 'nodes.dart'; |
18 | 18 |
19 /// Builds the SSA graph for loop nodes. | 19 /// Builds the SSA graph for loop nodes. |
20 abstract class LoopHandler<T> { | 20 abstract class LoopHandler<T> { |
21 final GraphBuilder builder; | 21 final GraphBuilder builder; |
22 | 22 |
23 LoopHandler(this.builder); | 23 LoopHandler(this.builder); |
24 | 24 |
25 /// Builds a graph for the given [loop] node. | 25 /// Builds a graph for the given [loop] node. |
26 /// | 26 /// |
27 /// For while loops, [initialize] and [update] are null. | 27 /// For while loops, [initialize] and [update] are null. |
28 /// The [condition] function must return a boolean result. | 28 /// The [condition] function must return a boolean result. |
29 /// None of the functions must leave anything on the stack. | 29 /// None of the functions must leave anything on the stack. |
30 void handleLoop( | 30 void handleLoop( |
31 T loop, | 31 T loop, |
32 LoopClosureScope loopClosureInfo, | 32 CapturedLoopScope loopClosureInfo, |
33 JumpTarget jumpTarget, | 33 JumpTarget jumpTarget, |
34 void initialize(), | 34 void initialize(), |
35 HInstruction condition(), | 35 HInstruction condition(), |
36 void update(), | 36 void update(), |
37 void body()) { | 37 void body()) { |
38 // Generate: | 38 // Generate: |
39 // <initializer> | 39 // <initializer> |
40 // loop-entry: | 40 // loop-entry: |
41 // if (!<condition>) goto loop-exit; | 41 // if (!<condition>) goto loop-exit; |
42 // <body> | 42 // <body> |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 HLoopBlockInformation.DO_WHILE_LOOP; | 379 HLoopBlockInformation.DO_WHILE_LOOP; |
380 | 380 |
381 @override | 381 @override |
382 int visitForInStatement(ir.ForInStatement node) => | 382 int visitForInStatement(ir.ForInStatement node) => |
383 HLoopBlockInformation.FOR_IN_LOOP; | 383 HLoopBlockInformation.FOR_IN_LOOP; |
384 | 384 |
385 @override | 385 @override |
386 int visitSwitchStatement(ir.SwitchStatement node) => | 386 int visitSwitchStatement(ir.SwitchStatement node) => |
387 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; | 387 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; |
388 } | 388 } |
OLD | NEW |