| 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 | 2 |
| 3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
| 4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 import 'dart:collection' show HashMap, HashSet; | 6 import 'dart:collection' show HashMap, HashSet; |
| 7 import 'dart:math' show min, max; | 7 import 'dart:math' show min, max; |
| 8 | 8 |
| 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; | 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; |
| 10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| (...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1307 // Therefore, dart:core Object gets the one real `constructor` and | 1307 // Therefore, dart:core Object gets the one real `constructor` and |
| 1308 // immediately bounces to the `new() { ... }` initializer, letting us | 1308 // immediately bounces to the `new() { ... }` initializer, letting us |
| 1309 // bypass the ES6 restrictions. | 1309 // bypass the ES6 restrictions. |
| 1310 // | 1310 // |
| 1311 // TODO(jmesserly): we'll need to rethink this. | 1311 // TODO(jmesserly): we'll need to rethink this. |
| 1312 // See <https://github.com/dart-lang/dev_compiler/issues/51>. | 1312 // See <https://github.com/dart-lang/dev_compiler/issues/51>. |
| 1313 // This level of indirection will hurt performance. | 1313 // This level of indirection will hurt performance. |
| 1314 jsMethods.add(new JS.Method( | 1314 jsMethods.add(new JS.Method( |
| 1315 _propertyName('constructor'), | 1315 _propertyName('constructor'), |
| 1316 js.call('function(...args) { return this.new.apply(this, args); }') | 1316 js.call('function(...args) { return this.new.apply(this, args); }') |
| 1317 as JS.Fun)); | 1317 as JS.Fun)); |
| 1318 } else if (ctors.isEmpty) { | 1318 } else if (ctors.isEmpty) { |
| 1319 jsMethods.add(_emitImplicitConstructor(node, fields, virtualFields)); | 1319 jsMethods.add(_emitImplicitConstructor(node, fields, virtualFields)); |
| 1320 } | 1320 } |
| 1321 | 1321 |
| 1322 bool hasJsPeer = findAnnotation(element, isJsPeerInterface) != null; | 1322 bool hasJsPeer = findAnnotation(element, isJsPeerInterface) != null; |
| 1323 | 1323 |
| 1324 bool hasIterator = false; | 1324 bool hasIterator = false; |
| 1325 for (var m in node.members) { | 1325 for (var m in node.members) { |
| 1326 if (m is ConstructorDeclaration) { | 1326 if (m is ConstructorDeclaration) { |
| 1327 jsMethods | 1327 jsMethods |
| (...skipping 2632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3960 Element target, List<VariableDeclaration> fields) { | 3960 Element target, List<VariableDeclaration> fields) { |
| 3961 var methods = []; | 3961 var methods = []; |
| 3962 for (var node in fields) { | 3962 for (var node in fields) { |
| 3963 var name = node.name.name; | 3963 var name = node.name.name; |
| 3964 var element = node.element; | 3964 var element = node.element; |
| 3965 var access = _emitMemberName(name, isStatic: true); | 3965 var access = _emitMemberName(name, isStatic: true); |
| 3966 methods.add(annotate( | 3966 methods.add(annotate( |
| 3967 new JS.Method( | 3967 new JS.Method( |
| 3968 access, | 3968 access, |
| 3969 js.call('function() { return #; }', _visitInitializer(node)) | 3969 js.call('function() { return #; }', _visitInitializer(node)) |
| 3970 as JS.Fun, | 3970 as JS.Fun, |
| 3971 isGetter: true), | 3971 isGetter: true), |
| 3972 node, | 3972 node, |
| 3973 _findAccessor(element, getter: true))); | 3973 _findAccessor(element, getter: true))); |
| 3974 | 3974 |
| 3975 // TODO(jmesserly): currently uses a dummy setter to indicate writable. | 3975 // TODO(jmesserly): currently uses a dummy setter to indicate writable. |
| 3976 if (!node.isFinal && !node.isConst) { | 3976 if (!node.isFinal && !node.isConst) { |
| 3977 methods.add(annotate( | 3977 methods.add(annotate( |
| 3978 new JS.Method(access, js.call('function(_) {}') as JS.Fun, | 3978 new JS.Method(access, js.call('function(_) {}') as JS.Fun, |
| 3979 isSetter: true), | 3979 isSetter: true), |
| 3980 node, | 3980 node, |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4520 _bindValue(scope, 'o', _getTarget(prop), context: context), | 4520 _bindValue(scope, 'o', _getTarget(prop), context: context), |
| 4521 prop.operator, | 4521 prop.operator, |
| 4522 prop.propertyName); | 4522 prop.propertyName); |
| 4523 } else if (expr is PrefixedIdentifier) { | 4523 } else if (expr is PrefixedIdentifier) { |
| 4524 PrefixedIdentifier ident = expr; | 4524 PrefixedIdentifier ident = expr; |
| 4525 if (isLibraryPrefix(ident.prefix)) { | 4525 if (isLibraryPrefix(ident.prefix)) { |
| 4526 return expr; | 4526 return expr; |
| 4527 } | 4527 } |
| 4528 result = new PrefixedIdentifier( | 4528 result = new PrefixedIdentifier( |
| 4529 _bindValue(scope, 'o', ident.prefix, context: context) | 4529 _bindValue(scope, 'o', ident.prefix, context: context) |
| 4530 as SimpleIdentifier, | 4530 as SimpleIdentifier, |
| 4531 ident.period, | 4531 ident.period, |
| 4532 ident.identifier); | 4532 ident.identifier); |
| 4533 } else { | 4533 } else { |
| 4534 return expr as SimpleIdentifier; | 4534 return expr as SimpleIdentifier; |
| 4535 } | 4535 } |
| 4536 result.staticType = expr.staticType; | 4536 result.staticType = expr.staticType; |
| 4537 setIsDynamicInvoke(result, isDynamicInvoke(expr)); | 4537 setIsDynamicInvoke(result, isDynamicInvoke(expr)); |
| 4538 return result; | 4538 return result; |
| 4539 } | 4539 } |
| 4540 | 4540 |
| (...skipping 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5765 var targetIdentifier = target as SimpleIdentifier; | 5765 var targetIdentifier = target as SimpleIdentifier; |
| 5766 | 5766 |
| 5767 if (targetIdentifier.staticElement is! PrefixElement) return false; | 5767 if (targetIdentifier.staticElement is! PrefixElement) return false; |
| 5768 var prefix = targetIdentifier.staticElement as PrefixElement; | 5768 var prefix = targetIdentifier.staticElement as PrefixElement; |
| 5769 | 5769 |
| 5770 // The library the prefix is referring to must come from a deferred import. | 5770 // The library the prefix is referring to must come from a deferred import. |
| 5771 var containingLibrary = (target.root as CompilationUnit).element.library; | 5771 var containingLibrary = (target.root as CompilationUnit).element.library; |
| 5772 var imports = containingLibrary.getImportsWithPrefix(prefix); | 5772 var imports = containingLibrary.getImportsWithPrefix(prefix); |
| 5773 return imports.length == 1 && imports[0].isDeferred; | 5773 return imports.length == 1 && imports[0].isDeferred; |
| 5774 } | 5774 } |
| OLD | NEW |