| 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:js_runtime/shared/embedded_names.dart'; | 5 import 'package:js_runtime/shared/embedded_names.dart'; |
| 6 import 'package:kernel/ast.dart' as ir; | 6 import 'package:kernel/ast.dart' as ir; |
| 7 | 7 |
| 8 import '../closure.dart'; | 8 import '../closure.dart'; |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../compiler.dart'; | 10 import '../compiler.dart'; |
| 11 import '../constants/expressions.dart'; | 11 import '../constants/expressions.dart'; |
| 12 import '../constants/values.dart'; | 12 import '../constants/values.dart'; |
| 13 import '../common_elements.dart'; | 13 import '../common_elements.dart'; |
| 14 import '../elements/resolution_types.dart'; | 14 import '../elements/resolution_types.dart'; |
| 15 import '../elements/elements.dart'; | 15 import '../elements/elements.dart'; |
| 16 import '../elements/entities.dart'; | 16 import '../elements/entities.dart'; |
| 17 import '../elements/modelx.dart'; | 17 import '../elements/modelx.dart'; |
| 18 import '../js/js.dart' as js; | 18 import '../js/js.dart' as js; |
| 19 import '../js_backend/js_backend.dart'; | 19 import '../js_backend/js_backend.dart'; |
| 20 import '../kernel/element_adapter.dart'; | 20 import '../kernel/element_map.dart'; |
| 21 import '../kernel/kernel.dart'; | 21 import '../kernel/kernel.dart'; |
| 22 import '../native/native.dart' as native; | 22 import '../native/native.dart' as native; |
| 23 import '../resolution/tree_elements.dart'; | 23 import '../resolution/tree_elements.dart'; |
| 24 import '../tree/tree.dart' as ast; | 24 import '../tree/tree.dart' as ast; |
| 25 import '../types/masks.dart'; | 25 import '../types/masks.dart'; |
| 26 import '../types/types.dart'; | 26 import '../types/types.dart'; |
| 27 import '../universe/selector.dart'; | 27 import '../universe/selector.dart'; |
| 28 import '../universe/side_effects.dart'; | 28 import '../universe/side_effects.dart'; |
| 29 import '../world.dart'; | 29 import '../world.dart'; |
| 30 import 'graph_builder.dart'; | 30 import 'graph_builder.dart'; |
| 31 import 'jump_handler.dart' show SwitchCaseJumpHandler; | 31 import 'jump_handler.dart' show SwitchCaseJumpHandler; |
| 32 import 'locals_handler.dart'; | 32 import 'locals_handler.dart'; |
| 33 import 'types.dart'; | 33 import 'types.dart'; |
| 34 | 34 |
| 35 /// A helper class that abstracts all accesses of the AST from Kernel nodes. | 35 /// A helper class that abstracts all accesses of the AST from Kernel nodes. |
| 36 /// | 36 /// |
| 37 /// The goal is to remove all need for the AST from the Kernel SSA builder. | 37 /// The goal is to remove all need for the AST from the Kernel SSA builder. |
| 38 class KernelAstAdapter extends KernelElementAdapterMixin { | 38 class KernelAstAdapter extends KernelToElementMapMixin { |
| 39 final Kernel kernel; | 39 final Kernel kernel; |
| 40 final JavaScriptBackend _backend; | 40 final JavaScriptBackend _backend; |
| 41 final Map<ir.Node, ast.Node> _nodeToAst; | 41 final Map<ir.Node, ast.Node> _nodeToAst; |
| 42 final Map<ir.Node, Element> _nodeToElement; | 42 final Map<ir.Node, Element> _nodeToElement; |
| 43 final Map<ir.VariableDeclaration, SyntheticLocal> _syntheticLocals = | 43 final Map<ir.VariableDeclaration, SyntheticLocal> _syntheticLocals = |
| 44 <ir.VariableDeclaration, SyntheticLocal>{}; | 44 <ir.VariableDeclaration, SyntheticLocal>{}; |
| 45 // TODO(efortuna): In an ideal world the TreeNodes should be some common | 45 // TODO(efortuna): In an ideal world the TreeNodes should be some common |
| 46 // interface we create for both ir.Statements and ir.SwitchCase (the | 46 // interface we create for both ir.Statements and ir.SwitchCase (the |
| 47 // ContinueSwitchStatement's target is a SwitchCase) rather than general | 47 // ContinueSwitchStatement's target is a SwitchCase) rather than general |
| 48 // TreeNode. Talking to Asger about this. | 48 // TreeNode. Talking to Asger about this. |
| (...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 JumpTarget continueTarget = | 832 JumpTarget continueTarget = |
| 833 astAdapter.getJumpTarget(switchCase, isContinueTarget: true); | 833 astAdapter.getJumpTarget(switchCase, isContinueTarget: true); |
| 834 assert(continueTarget is KernelJumpTarget); | 834 assert(continueTarget is KernelJumpTarget); |
| 835 targetIndexMap[continueTarget] = switchIndex; | 835 targetIndexMap[continueTarget] = switchIndex; |
| 836 assert(builder.jumpTargets[continueTarget] == null); | 836 assert(builder.jumpTargets[continueTarget] == null); |
| 837 builder.jumpTargets[continueTarget] = this; | 837 builder.jumpTargets[continueTarget] = this; |
| 838 switchIndex++; | 838 switchIndex++; |
| 839 } | 839 } |
| 840 } | 840 } |
| 841 } | 841 } |
| OLD | NEW |