OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library dev_compiler.src.codegen.js_codegen; | 5 library dev_compiler.src.codegen.js_codegen; |
6 | 6 |
7 import 'dart:collection' show HashSet, HashMap; | 7 import 'dart:collection' show HashSet, HashMap; |
8 import 'dart:io' show Directory, File; | 8 import 'dart:io' show Directory, File; |
9 | 9 |
10 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; | 10 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; |
(...skipping 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1726 return _visitGet(node.prefix, node.identifier); | 1726 return _visitGet(node.prefix, node.identifier); |
1727 } | 1727 } |
1728 } | 1728 } |
1729 | 1729 |
1730 @override | 1730 @override |
1731 visitPropertyAccess(PropertyAccess node) => | 1731 visitPropertyAccess(PropertyAccess node) => |
1732 _visitGet(_getTarget(node), node.propertyName); | 1732 _visitGet(_getTarget(node), node.propertyName); |
1733 | 1733 |
1734 /// Shared code for [PrefixedIdentifier] and [PropertyAccess]. | 1734 /// Shared code for [PrefixedIdentifier] and [PropertyAccess]. |
1735 _visitGet(Expression target, SimpleIdentifier name) { | 1735 _visitGet(Expression target, SimpleIdentifier name) { |
1736 if (rules.isDynamicTarget(target)) { | 1736 if (rules.isDynamicGet(target, name.name)) { |
1737 return js.call( | 1737 return js.call( |
1738 'dart.dload(#, #)', [_visit(target), js.string(name.name, "'")]); | 1738 'dart.dload(#, #)', [_visit(target), js.string(name.name, "'")]); |
1739 } else { | 1739 } else { |
1740 var e = name.staticElement; | 1740 var e = name.staticElement; |
1741 return js.call('#.#', [ | 1741 return js.call('#.#', [ |
1742 _visit(target), | 1742 _visit(target), |
1743 _jsMemberName(name.name, isStatic: e is ExecutableElement && e.isStatic) | 1743 _jsMemberName(name.name, isStatic: e is ExecutableElement && e.isStatic) |
1744 ]); | 1744 ]); |
1745 } | 1745 } |
1746 } | 1746 } |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2384 | 2384 |
2385 // TODO(jmesserly): in many cases marking the end will be unncessary. | 2385 // TODO(jmesserly): in many cases marking the end will be unncessary. |
2386 printer.mark(_location(node.end)); | 2386 printer.mark(_location(node.end)); |
2387 } | 2387 } |
2388 | 2388 |
2389 String _getIdentifier(AstNode node) { | 2389 String _getIdentifier(AstNode node) { |
2390 if (node is SimpleIdentifier) return node.name; | 2390 if (node is SimpleIdentifier) return node.name; |
2391 return null; | 2391 return null; |
2392 } | 2392 } |
2393 } | 2393 } |
OLD | NEW |