Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 Queue; | 5 import 'dart:collection' show Queue; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/backend_api.dart' show ForeignResolver; | 8 import '../common/backend_api.dart' show ForeignResolver; |
| 9 import '../common/resolution.dart' show Resolution; | 9 import '../common/resolution.dart' show Resolution; |
| 10 import '../compiler.dart' show Compiler; | 10 import '../compiler.dart' show Compiler; |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 430 int unusedBefore = _unusedClasses.length; | 430 int unusedBefore = _unusedClasses.length; |
| 431 Set<ClassElement> matchingClasses = new Set<ClassElement>(); | 431 Set<ClassElement> matchingClasses = new Set<ClassElement>(); |
| 432 for (var type in behavior.typesInstantiated) { | 432 for (var type in behavior.typesInstantiated) { |
| 433 if (type is SpecialType) { | 433 if (type is SpecialType) { |
| 434 if (type == SpecialType.JsObject) { | 434 if (type == SpecialType.JsObject) { |
| 435 registerInstantiation(compiler.commonElements.objectType); | 435 registerInstantiation(compiler.commonElements.objectType); |
| 436 } | 436 } |
| 437 continue; | 437 continue; |
| 438 } | 438 } |
| 439 if (type is ResolutionInterfaceType) { | 439 if (type is ResolutionInterfaceType) { |
| 440 if (type == commonElements.intType) { | 440 if (type == commonElements.intType) { |
|
Siggi Cherem (dart-lang)
2017/01/27 16:49:06
(optional) while we are here, minor readability ni
Johnni Winther
2017/01/30 10:00:12
Done.
| |
| 441 registerInstantiation(type); | 441 registerInstantiation(type); |
| 442 } else if (type == commonElements.doubleType) { | 442 } else if (type == commonElements.doubleType) { |
| 443 registerInstantiation(type); | 443 registerInstantiation(type); |
| 444 } else if (type == commonElements.numType) { | 444 } else if (type == commonElements.numType) { |
| 445 registerInstantiation(commonElements.doubleType); | 445 registerInstantiation(commonElements.doubleType); |
| 446 registerInstantiation(commonElements.intType); | 446 registerInstantiation(commonElements.intType); |
| 447 } else if (type == commonElements.stringType) { | 447 } else if (type == commonElements.stringType) { |
| 448 registerInstantiation(type); | 448 registerInstantiation(type); |
| 449 } else if (type == commonElements.nullType) { | 449 } else if (type == commonElements.nullType) { |
| 450 registerInstantiation(type); | 450 registerInstantiation(type); |
| 451 } else if (type == commonElements.boolType) { | 451 } else if (type == commonElements.boolType) { |
| 452 registerInstantiation(type); | 452 registerInstantiation(type); |
| 453 } else if (compiler.types.isSubtype( | 453 } else if (type.asInstanceOf(backend.backendClasses.listClass) != |
|
Siggi Cherem (dart-lang)
2017/01/27 16:49:06
any reason why use `asInstanceOf` and not keep `is
Johnni Winther
2017/01/30 10:00:12
[asInstanceOf] is sufficient here but not below --
| |
| 454 type, backend.backendClasses.listImplementation.rawType)) { | 454 null) { |
| 455 registerInstantiation(type); | 455 registerInstantiation(type); |
| 456 } | 456 } |
| 457 // TODO(johnniwinther): Improve spec string precision to handle type | 457 // TODO(johnniwinther): Improve spec string precision to handle type |
| 458 // arguments and implements relations that preserve generics. Currently | 458 // arguments and implements relations that preserve generics. Currently |
| 459 // we cannot distinguish between `List`, `List<dynamic>`, and | 459 // we cannot distinguish between `List`, `List<dynamic>`, and |
| 460 // `List<int>` and take all to mean `List<E>`; in effect not including | 460 // `List<int>` and take all to mean `List<E>`; in effect not including |
| 461 // any native subclasses of generic classes. | 461 // any native subclasses of generic classes. |
| 462 // TODO(johnniwinther,sra): Find and replace uses of `List` with the | 462 // TODO(johnniwinther,sra): Find and replace uses of `List` with the |
| 463 // actual implementation classes such as `JSArray` et al. | 463 // actual implementation classes such as `JSArray` et al. |
| 464 matchingClasses | 464 matchingClasses |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 654 List<ClassEntity> directSubtypes = | 654 List<ClassEntity> directSubtypes = |
| 655 emitter.directSubtypes.putIfAbsent(superclass, () => <ClassEntity>[]); | 655 emitter.directSubtypes.putIfAbsent(superclass, () => <ClassEntity>[]); |
| 656 directSubtypes.add(cls); | 656 directSubtypes.add(cls); |
| 657 } | 657 } |
| 658 | 658 |
| 659 void logSummary(log(message)) { | 659 void logSummary(log(message)) { |
| 660 log('Compiled ${_registeredClasses.length} native classes, ' | 660 log('Compiled ${_registeredClasses.length} native classes, ' |
| 661 '${_unusedClasses.length} native classes omitted.'); | 661 '${_unusedClasses.length} native classes omitted.'); |
| 662 } | 662 } |
| 663 } | 663 } |
| OLD | NEW |