| 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 '../common.dart'; | 8 import '../common.dart'; |
| 9 import '../common/names.dart'; | 9 import '../common/names.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 '../elements/resolution_types.dart'; | 13 import '../elements/resolution_types.dart'; |
| 14 import '../elements/elements.dart'; | 14 import '../elements/elements.dart'; |
| 15 import '../elements/modelx.dart'; | 15 import '../elements/modelx.dart'; |
| 16 import '../js/js.dart' as js; | 16 import '../js/js.dart' as js; |
| 17 import '../js_backend/backend_helpers.dart'; | 17 import '../js_backend/backend_helpers.dart'; |
| 18 import '../js_backend/js_backend.dart'; | 18 import '../js_backend/js_backend.dart'; |
| 19 import '../kernel/kernel.dart'; | 19 import '../kernel/kernel.dart'; |
| 20 import '../kernel/kernel_debug.dart'; | 20 import '../kernel/kernel_debug.dart'; |
| 21 import '../native/native.dart' as native; | 21 import '../native/native.dart' as native; |
| 22 import '../resolution/tree_elements.dart'; | 22 import '../resolution/tree_elements.dart'; |
| 23 import '../tree/tree.dart' as ast; | 23 import '../tree/tree.dart' as ast; |
| 24 import '../types/masks.dart'; | 24 import '../types/masks.dart'; |
| 25 import '../types/types.dart'; | 25 import '../types/types.dart'; |
| 26 import '../universe/call_structure.dart'; | 26 import '../universe/call_structure.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 'jump_handler.dart' show SwitchCaseJumpHandler; | |
| 31 import 'locals_handler.dart'; | 30 import 'locals_handler.dart'; |
| 32 import 'types.dart'; | 31 import 'types.dart'; |
| 33 | 32 |
| 34 /// A helper class that abstracts all accesses of the AST from Kernel nodes. | 33 /// A helper class that abstracts all accesses of the AST from Kernel nodes. |
| 35 /// | 34 /// |
| 36 /// The goal is to remove all need for the AST from the Kernel SSA builder. | 35 /// The goal is to remove all need for the AST from the Kernel SSA builder. |
| 37 class KernelAstAdapter { | 36 class KernelAstAdapter { |
| 38 final Kernel kernel; | 37 final Kernel kernel; |
| 39 final JavaScriptBackend _backend; | 38 final JavaScriptBackend _backend; |
| 40 final Map<ir.Node, ast.Node> _nodeToAst; | 39 final Map<ir.Node, ast.Node> _nodeToAst; |
| (...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 new CallStructure( | 948 new CallStructure( |
| 950 node.arguments.positional.length + argumentNames.length, | 949 node.arguments.positional.length + argumentNames.length, |
| 951 argumentNames), | 950 argumentNames), |
| 952 arguments); | 951 arguments); |
| 953 } | 952 } |
| 954 | 953 |
| 955 @override | 954 @override |
| 956 ConstantExpression visitStaticGet(ir.StaticGet node) { | 955 ConstantExpression visitStaticGet(ir.StaticGet node) { |
| 957 Element element = astAdapter.getMember(node.target); | 956 Element element = astAdapter.getMember(node.target); |
| 958 if (element.isField) { | 957 if (element.isField) { |
| 959 return new VariableConstantExpression(element); | 958 return new VariableConstantExpression(element as MemberElement); |
| 960 } | 959 } |
| 961 astAdapter.reporter.internalError( | 960 astAdapter.reporter.internalError( |
| 962 CURRENT_ELEMENT_SPANNABLE, "Unexpected constant target: $element."); | 961 CURRENT_ELEMENT_SPANNABLE, "Unexpected constant target: $element."); |
| 963 return null; | 962 return null; |
| 964 } | 963 } |
| 965 | 964 |
| 966 @override | 965 @override |
| 967 ConstantExpression visitStringLiteral(ir.StringLiteral node) { | 966 ConstantExpression visitStringLiteral(ir.StringLiteral node) { |
| 968 return new StringConstantExpression(node.value); | 967 return new StringConstantExpression(node.value); |
| 969 } | 968 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 String get name => null; | 1025 String get name => null; |
| 1027 | 1026 |
| 1028 @override | 1027 @override |
| 1029 int get nestingLevel => 1; | 1028 int get nestingLevel => 1; |
| 1030 | 1029 |
| 1031 @override | 1030 @override |
| 1032 ast.Node get statement => null; | 1031 ast.Node get statement => null; |
| 1033 | 1032 |
| 1034 String toString() => 'Target:$targetStatement'; | 1033 String toString() => 'Target:$targetStatement'; |
| 1035 } | 1034 } |
| OLD | NEW |