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