| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 if (compiler.hasIncrementalSupport) { | 132 if (compiler.hasIncrementalSupport) { |
| 133 // Since [Set.add] returns bool if an element was added, this restricts | 133 // Since [Set.add] returns bool if an element was added, this restricts |
| 134 // [libraries] to ones that haven't already been processed. This saves | 134 // [libraries] to ones that haven't already been processed. This saves |
| 135 // time during incremental compiles. | 135 // time during incremental compiles. |
| 136 libraries = libraries.where(processedLibraries.add); | 136 libraries = libraries.where(processedLibraries.add); |
| 137 } | 137 } |
| 138 libraries.forEach(processNativeClassesInLibrary); | 138 libraries.forEach(processNativeClassesInLibrary); |
| 139 if (backend.isolateHelperLibrary != null) { | 139 if (backend.isolateHelperLibrary != null) { |
| 140 processNativeClassesInLibrary(backend.isolateHelperLibrary); | 140 processNativeClassesInLibrary(backend.isolateHelperLibrary); |
| 141 } | 141 } |
| 142 libraries.forEach(processJsInteropAnnotationsInLibrary); |
| 142 processSubclassesOfNativeClasses(libraries); | 143 processSubclassesOfNativeClasses(libraries); |
| 143 if (!enableLiveTypeAnalysis) { | 144 if (!enableLiveTypeAnalysis) { |
| 144 nativeClasses.forEach((c) => enqueueClass(c, 'forced')); | 145 nativeClasses.forEach((c) => enqueueClass(c, 'forced')); |
| 145 flushQueue(); | 146 flushQueue(); |
| 146 } | 147 } |
| 147 } | 148 } |
| 148 | 149 |
| 150 void processJsInteropAnnotationsInLibrary(LibraryElement library) { |
| 151 checkJsInteropAnnotation(compiler, library); |
| 152 library.implementation.forEachLocalMember((Element element) { |
| 153 checkJsInteropAnnotation(compiler, element); |
| 154 }); |
| 155 } |
| 156 |
| 149 void processNativeClassesInLibrary(LibraryElement library) { | 157 void processNativeClassesInLibrary(LibraryElement library) { |
| 150 // Use implementation to ensure the inclusion of injected members. | 158 // Use implementation to ensure the inclusion of injected members. |
| 151 library.implementation.forEachLocalMember((Element element) { | 159 library.implementation.forEachLocalMember((Element element) { |
| 152 if (element.isClass && element.isNative) { | 160 if (element.isClass && element.isNative) { |
| 153 processNativeClass(element); | 161 processNativeClass(element); |
| 154 } | 162 } |
| 155 }); | 163 }); |
| 156 } | 164 } |
| 157 | 165 |
| 158 void processNativeClass(ClassElement classElement) { | 166 void processNativeClass(ClassElement classElement) { |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 class NativeResolutionEnqueuer extends NativeEnqueuerBase { | 609 class NativeResolutionEnqueuer extends NativeEnqueuerBase { |
| 602 | 610 |
| 603 Map<String, ClassElement> tagOwner = new Map<String, ClassElement>(); | 611 Map<String, ClassElement> tagOwner = new Map<String, ClassElement>(); |
| 604 | 612 |
| 605 NativeResolutionEnqueuer(Enqueuer world, Compiler compiler) | 613 NativeResolutionEnqueuer(Enqueuer world, Compiler compiler) |
| 606 : super(world, compiler, compiler.enableNativeLiveTypeAnalysis); | 614 : super(world, compiler, compiler.enableNativeLiveTypeAnalysis); |
| 607 | 615 |
| 608 void processNativeClass(ClassElement classElement) { | 616 void processNativeClass(ClassElement classElement) { |
| 609 super.processNativeClass(classElement); | 617 super.processNativeClass(classElement); |
| 610 | 618 |
| 619 // Js Interop interfaces do not have tags. |
| 620 if (classElement.isJsInterop) return; |
| 611 // Since we map from dispatch tags to classes, a dispatch tag must be used | 621 // Since we map from dispatch tags to classes, a dispatch tag must be used |
| 612 // on only one native class. | 622 // on only one native class. |
| 613 for (String tag in nativeTagsOfClass(classElement)) { | 623 for (String tag in nativeTagsOfClass(classElement)) { |
| 614 ClassElement owner = tagOwner[tag]; | 624 ClassElement owner = tagOwner[tag]; |
| 615 if (owner != null) { | 625 if (owner != null) { |
| 616 if (owner != classElement) { | 626 if (owner != classElement) { |
| 617 compiler.internalError( | 627 compiler.internalError( |
| 618 classElement, "Tag '$tag' already in use by '${owner.name}'"); | 628 classElement, "Tag '$tag' already in use by '${owner.name}'"); |
| 619 } | 629 } |
| 620 } else { | 630 } else { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 superclass, | 698 superclass, |
| 689 () => <ClassElement>[]); | 699 () => <ClassElement>[]); |
| 690 directSubtypes.add(cls); | 700 directSubtypes.add(cls); |
| 691 } | 701 } |
| 692 | 702 |
| 693 void logSummary(log(message)) { | 703 void logSummary(log(message)) { |
| 694 log('Compiled ${registeredClasses.length} native classes, ' | 704 log('Compiled ${registeredClasses.length} native classes, ' |
| 695 '${unusedClasses.length} native classes omitted.'); | 705 '${unusedClasses.length} native classes omitted.'); |
| 696 } | 706 } |
| 697 } | 707 } |
| OLD | NEW |