| 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 part of native; | 5 part of native; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * This could be an abstract class but we use it as a stub for the dart_backend. | 8 * This could be an abstract class but we use it as a stub for the dart_backend. |
| 9 */ | 9 */ |
| 10 class NativeEnqueuer { | 10 class NativeEnqueuer { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 /// Subclasses of [NativeEnqueuerBase] are constructed by the backend. | 92 /// Subclasses of [NativeEnqueuerBase] are constructed by the backend. |
| 93 NativeEnqueuerBase(this.world, Compiler compiler, this.enableLiveTypeAnalysis) | 93 NativeEnqueuerBase(this.world, Compiler compiler, this.enableLiveTypeAnalysis) |
| 94 : this.compiler = compiler, | 94 : this.compiler = compiler, |
| 95 processedLibraries = compiler.cacheStrategy.newSet(); | 95 processedLibraries = compiler.cacheStrategy.newSet(); |
| 96 | 96 |
| 97 JavaScriptBackend get backend => compiler.backend; | 97 JavaScriptBackend get backend => compiler.backend; |
| 98 Resolution get resolution => compiler.resolution; | 98 Resolution get resolution => compiler.resolution; |
| 99 | 99 |
| 100 DiagnosticReporter get reporter => compiler.reporter; | 100 DiagnosticReporter get reporter => compiler.reporter; |
| 101 CoreTypes get coreTypes => compiler.coreTypes; |
| 101 | 102 |
| 102 void processNativeClasses(Iterable<LibraryElement> libraries) { | 103 void processNativeClasses(Iterable<LibraryElement> libraries) { |
| 103 if (compiler.hasIncrementalSupport) { | 104 if (compiler.hasIncrementalSupport) { |
| 104 // Since [Set.add] returns bool if an element was added, this restricts | 105 // Since [Set.add] returns bool if an element was added, this restricts |
| 105 // [libraries] to ones that haven't already been processed. This saves | 106 // [libraries] to ones that haven't already been processed. This saves |
| 106 // time during incremental compiles. | 107 // time during incremental compiles. |
| 107 libraries = libraries.where(processedLibraries.add); | 108 libraries = libraries.where(processedLibraries.add); |
| 108 } | 109 } |
| 109 libraries.forEach(processNativeClassesInLibrary); | 110 libraries.forEach(processNativeClassesInLibrary); |
| 110 if (backend.isolateHelperLibrary != null) { | 111 if (backend.isolateHelperLibrary != null) { |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 if (matchedTypeConstraints.contains(type)) continue; | 465 if (matchedTypeConstraints.contains(type)) continue; |
| 465 matchedTypeConstraints.add(type); | 466 matchedTypeConstraints.add(type); |
| 466 if (type is SpecialType) { | 467 if (type is SpecialType) { |
| 467 if (type == SpecialType.JsObject) { | 468 if (type == SpecialType.JsObject) { |
| 468 backend.registerInstantiatedType( | 469 backend.registerInstantiatedType( |
| 469 compiler.coreTypes.objectType, world, registry); | 470 compiler.coreTypes.objectType, world, registry); |
| 470 } | 471 } |
| 471 continue; | 472 continue; |
| 472 } | 473 } |
| 473 if (type is InterfaceType) { | 474 if (type is InterfaceType) { |
| 474 if (type.element == compiler.intClass) { | 475 if (type == coreTypes.intType) { |
| 475 backend.registerInstantiatedType(type, world, registry); | 476 backend.registerInstantiatedType(type, world, registry); |
| 476 } else if (type.element == compiler.doubleClass) { | 477 } else if (type == coreTypes.doubleType) { |
| 477 backend.registerInstantiatedType(type, world, registry); | 478 backend.registerInstantiatedType(type, world, registry); |
| 478 } else if (type.element == compiler.numClass) { | 479 } else if (type == coreTypes.numType) { |
| 479 backend.registerInstantiatedType( | 480 backend.registerInstantiatedType( |
| 480 compiler.coreTypes.doubleType, world, registry); | 481 coreTypes.doubleType, world, registry); |
| 481 backend.registerInstantiatedType( | 482 backend.registerInstantiatedType( |
| 482 compiler.coreTypes.intType, world, registry); | 483 coreTypes.intType, world, registry); |
| 483 } else if (type.element == compiler.stringClass) { | 484 } else if (type == coreTypes.stringType) { |
| 484 backend.registerInstantiatedType(type, world, registry); | 485 backend.registerInstantiatedType(type, world, registry); |
| 485 } else if (type.element == compiler.nullClass) { | 486 } else if (type == coreTypes.nullType) { |
| 486 backend.registerInstantiatedType(type, world, registry); | 487 backend.registerInstantiatedType(type, world, registry); |
| 487 } else if (type.element == compiler.boolClass) { | 488 } else if (type == coreTypes.boolType) { |
| 488 backend.registerInstantiatedType(type, world, registry); | 489 backend.registerInstantiatedType(type, world, registry); |
| 489 } else if (compiler.types.isSubtype( | 490 } else if (compiler.types.isSubtype( |
| 490 type, backend.listImplementation.rawType)) { | 491 type, backend.listImplementation.rawType)) { |
| 491 backend.registerInstantiatedType(type, world, registry); | 492 backend.registerInstantiatedType(type, world, registry); |
| 492 } | 493 } |
| 493 } | 494 } |
| 494 assert(type is DartType); | 495 assert(type is DartType); |
| 495 enqueueUnusedClassesMatching( | 496 enqueueUnusedClassesMatching( |
| 496 (nativeClass) => compiler.types.isSubtype(nativeClass.thisType, type), | 497 (nativeClass) => compiler.types.isSubtype(nativeClass.thisType, type), |
| 497 cause, | 498 cause, |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 superclass, | 681 superclass, |
| 681 () => <ClassElement>[]); | 682 () => <ClassElement>[]); |
| 682 directSubtypes.add(cls); | 683 directSubtypes.add(cls); |
| 683 } | 684 } |
| 684 | 685 |
| 685 void logSummary(log(message)) { | 686 void logSummary(log(message)) { |
| 686 log('Compiled ${registeredClasses.length} native classes, ' | 687 log('Compiled ${registeredClasses.length} native classes, ' |
| 687 '${unusedClasses.length} native classes omitted.'); | 688 '${unusedClasses.length} native classes omitted.'); |
| 688 } | 689 } |
| 689 } | 690 } |
| OLD | NEW |