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 '../constants/expressions.dart'; | 8 import '../constants/expressions.dart'; |
9 import '../common.dart'; | 9 import '../common.dart'; |
10 import '../common/names.dart'; | 10 import '../common/names.dart'; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 Element result = _nodeToElement[node]; | 85 Element result = _nodeToElement[node]; |
86 assert(invariant(CURRENT_ELEMENT_SPANNABLE, result != null, | 86 assert(invariant(CURRENT_ELEMENT_SPANNABLE, result != null, |
87 message: "No element found for $node.")); | 87 message: "No element found for $node.")); |
88 return result; | 88 return result; |
89 } | 89 } |
90 | 90 |
91 MemberElement getMember(ir.Node node) => getElement(node).declaration; | 91 MemberElement getMember(ir.Node node) => getElement(node).declaration; |
92 | 92 |
93 MethodElement getMethod(ir.Node node) => getElement(node).declaration; | 93 MethodElement getMethod(ir.Node node) => getElement(node).declaration; |
94 | 94 |
| 95 FieldElement getField(ir.Node node) => getElement(node).declaration; |
| 96 |
95 ClassElement getClass(ir.Node node) => getElement(node).declaration; | 97 ClassElement getClass(ir.Node node) => getElement(node).declaration; |
96 | 98 |
97 ast.Node getNode(ir.Node node) { | 99 ast.Node getNode(ir.Node node) { |
98 ast.Node result = _nodeToAst[node]; | 100 ast.Node result = _nodeToAst[node]; |
99 assert(invariant(CURRENT_ELEMENT_SPANNABLE, result != null, | 101 assert(invariant(CURRENT_ELEMENT_SPANNABLE, result != null, |
100 message: "No node found for $node")); | 102 message: "No node found for $node")); |
101 return result; | 103 return result; |
102 } | 104 } |
103 | 105 |
104 Local getLocal(ir.VariableDeclaration variable) { | 106 Local getLocal(ir.VariableDeclaration variable) { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 281 |
280 bool isIntercepted(ir.Node node) { | 282 bool isIntercepted(ir.Node node) { |
281 Selector selector = getSelector(node); | 283 Selector selector = getSelector(node); |
282 return _backend.isInterceptedSelector(selector); | 284 return _backend.isInterceptedSelector(selector); |
283 } | 285 } |
284 | 286 |
285 bool isInterceptedSelector(Selector selector) { | 287 bool isInterceptedSelector(Selector selector) { |
286 return _backend.isInterceptedSelector(selector); | 288 return _backend.isInterceptedSelector(selector); |
287 } | 289 } |
288 | 290 |
| 291 // Is the member a lazy initialized static or top-level member? |
| 292 bool isLazyStatic(ir.Member member) { |
| 293 if (member is ir.Field) { |
| 294 FieldElement field = _nodeToElement[member]; |
| 295 return field.constant == null; |
| 296 } |
| 297 return false; |
| 298 } |
| 299 |
289 LibraryElement get jsHelperLibrary => _backend.helpers.jsHelperLibrary; | 300 LibraryElement get jsHelperLibrary => _backend.helpers.jsHelperLibrary; |
290 | 301 |
291 JumpTarget getTargetDefinition(ir.Node node) => | 302 JumpTarget getTargetDefinition(ir.Node node) => |
292 elements.getTargetDefinition(getNode(node)); | 303 elements.getTargetDefinition(getNode(node)); |
293 | 304 |
294 ir.Class get mapLiteralClass => | 305 ir.Class get mapLiteralClass => |
295 kernel.classes[_backend.helpers.mapLiteralClass]; | 306 kernel.classes[_backend.helpers.mapLiteralClass]; |
296 | 307 |
297 ir.Procedure get mapLiteralConstructor => | 308 ir.Procedure get mapLiteralConstructor => |
298 kernel.functions[_backend.helpers.mapLiteralConstructor]; | 309 kernel.functions[_backend.helpers.mapLiteralConstructor]; |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 astAdapter.reporter.internalError( | 775 astAdapter.reporter.internalError( |
765 CURRENT_ELEMENT_SPANNABLE, "Unexpected constant target: $element."); | 776 CURRENT_ELEMENT_SPANNABLE, "Unexpected constant target: $element."); |
766 return null; | 777 return null; |
767 } | 778 } |
768 | 779 |
769 @override | 780 @override |
770 ConstantExpression visitStringLiteral(ir.StringLiteral node) { | 781 ConstantExpression visitStringLiteral(ir.StringLiteral node) { |
771 return new StringConstantExpression(node.value); | 782 return new StringConstantExpression(node.value); |
772 } | 783 } |
773 } | 784 } |
OLD | NEW |