| 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 import 'dart:collection' show HashMap, HashSet; | 5 import 'dart:collection' show HashMap, HashSet; |
| 6 import 'dart:math' show min, max; | 6 import 'dart:math' show min, max; |
| 7 | 7 |
| 8 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; | 8 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType; | 10 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType; |
| (...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 | 818 |
| 819 return _statement(result); | 819 return _statement(result); |
| 820 } | 820 } |
| 821 | 821 |
| 822 /// Wraps a possibly generic class in its type arguments. | 822 /// Wraps a possibly generic class in its type arguments. |
| 823 JS.Statement _defineClassTypeArguments(TypeDefiningElement element, | 823 JS.Statement _defineClassTypeArguments(TypeDefiningElement element, |
| 824 List<TypeParameterElement> formals, JS.Statement body) { | 824 List<TypeParameterElement> formals, JS.Statement body) { |
| 825 assert(formals.isNotEmpty); | 825 assert(formals.isNotEmpty); |
| 826 var genericCall = js.call('dart.generic((#) => { #; return #; })', | 826 var genericCall = js.call('dart.generic((#) => { #; return #; })', |
| 827 [_emitTypeFormals(formals), body, element.name]); | 827 [_emitTypeFormals(formals), body, element.name]); |
| 828 if (element.type.isDartAsyncFuture) { | 828 if (element.library.isDartAsync && |
| 829 (element.name == "Future" || element.name == "_Future")) { |
| 829 genericCall = js.call('dart.flattenFutures(#)', [genericCall]); | 830 genericCall = js.call('dart.flattenFutures(#)', [genericCall]); |
| 830 } | 831 } |
| 831 var genericDef = js.statement( | 832 var genericDef = js.statement( |
| 832 '# = #;', [_emitTopLevelName(element, suffix: r'$'), genericCall]); | 833 '# = #;', [_emitTopLevelName(element, suffix: r'$'), genericCall]); |
| 833 var dynType = fillDynamicTypeArgs(element.type); | 834 var dynType = fillDynamicTypeArgs(element.type); |
| 834 var genericInst = _emitType(dynType, lowerGeneric: true); | 835 var genericInst = _emitType(dynType, lowerGeneric: true); |
| 835 return js.statement( | 836 return js.statement( |
| 836 '{ #; # = #; }', [genericDef, _emitTopLevelName(element), genericInst]); | 837 '{ #; # = #; }', [genericDef, _emitTopLevelName(element), genericInst]); |
| 837 } | 838 } |
| 838 | 839 |
| (...skipping 3696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4535 } | 4536 } |
| 4536 | 4537 |
| 4537 bool isLibraryPrefix(Expression node) => | 4538 bool isLibraryPrefix(Expression node) => |
| 4538 node is SimpleIdentifier && node.staticElement is PrefixElement; | 4539 node is SimpleIdentifier && node.staticElement is PrefixElement; |
| 4539 | 4540 |
| 4540 LibraryElement _getLibrary(AnalysisContext c, String uri) => | 4541 LibraryElement _getLibrary(AnalysisContext c, String uri) => |
| 4541 c.computeLibraryElement(c.sourceFactory.forUri(uri)); | 4542 c.computeLibraryElement(c.sourceFactory.forUri(uri)); |
| 4542 | 4543 |
| 4543 bool _isDartRuntime(LibraryElement l) => | 4544 bool _isDartRuntime(LibraryElement l) => |
| 4544 l.isInSdk && l.source.uri.toString() == 'dart:_runtime'; | 4545 l.isInSdk && l.source.uri.toString() == 'dart:_runtime'; |
| OLD | NEW |