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 LoopClosureScope; |
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 'kernel_ast_adapter.dart'; | |
17 import 'locals_handler.dart'; | 16 import 'locals_handler.dart'; |
18 import 'nodes.dart'; | 17 import 'nodes.dart'; |
19 | 18 |
20 /// Builds the SSA graph for loop nodes. | 19 /// Builds the SSA graph for loop nodes. |
21 abstract class LoopHandler<T> { | 20 abstract class LoopHandler<T> { |
22 final GraphBuilder builder; | 21 final GraphBuilder builder; |
23 | 22 |
24 LoopHandler(this.builder); | 23 LoopHandler(this.builder); |
25 | 24 |
26 /// Builds a graph for the given [loop] node. | 25 /// Builds a graph for the given [loop] node. |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 int visitSyncForIn(ast.SyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; | 339 int visitSyncForIn(ast.SyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; |
341 int visitSwitchStatement(ast.SwitchStatement node) => | 340 int visitSwitchStatement(ast.SwitchStatement node) => |
342 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; | 341 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; |
343 } | 342 } |
344 | 343 |
345 // TODO(het): Since kernel simplifies loop breaks and continues, we should | 344 // TODO(het): Since kernel simplifies loop breaks and continues, we should |
346 // rewrite the loop handler from scratch to account for the simplified structure | 345 // rewrite the loop handler from scratch to account for the simplified structure |
347 class KernelLoopHandler extends LoopHandler<ir.TreeNode> { | 346 class KernelLoopHandler extends LoopHandler<ir.TreeNode> { |
348 final KernelSsaGraphBuilder builder; | 347 final KernelSsaGraphBuilder builder; |
349 | 348 |
350 KernelAstAdapter get astAdapter => builder.astAdapter; | |
351 | |
352 KernelLoopHandler(KernelSsaGraphBuilder builder) | 349 KernelLoopHandler(KernelSsaGraphBuilder builder) |
353 : this.builder = builder, | 350 : this.builder = builder, |
354 super(builder); | 351 super(builder); |
355 | 352 |
356 @override | 353 @override |
357 JumpHandler createJumpHandler(ir.TreeNode node, JumpTarget jumpTarget, | 354 JumpHandler createJumpHandler(ir.TreeNode node, JumpTarget jumpTarget, |
358 {bool isLoopJump}) => | 355 {bool isLoopJump}) => |
359 builder.createJumpHandler(node, jumpTarget, isLoopJump: isLoopJump); | 356 builder.createJumpHandler(node, jumpTarget, isLoopJump: isLoopJump); |
360 | 357 |
361 @override | 358 @override |
(...skipping 20 matching lines...) Expand all Loading... |
382 HLoopBlockInformation.DO_WHILE_LOOP; | 379 HLoopBlockInformation.DO_WHILE_LOOP; |
383 | 380 |
384 @override | 381 @override |
385 int visitForInStatement(ir.ForInStatement node) => | 382 int visitForInStatement(ir.ForInStatement node) => |
386 HLoopBlockInformation.FOR_IN_LOOP; | 383 HLoopBlockInformation.FOR_IN_LOOP; |
387 | 384 |
388 @override | 385 @override |
389 int visitSwitchStatement(ir.SwitchStatement node) => | 386 int visitSwitchStatement(ir.SwitchStatement node) => |
390 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; | 387 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; |
391 } | 388 } |
OLD | NEW |