| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 dart2js; | 5 part of dart2js; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * If true, print a warning for each method that was resolved, but not | 8 * If true, print a warning for each method that was resolved, but not |
| 9 * compiled. | 9 * compiled. |
| 10 */ | 10 */ |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 ClassElement defaultSuperclass(ClassElement element) => compiler.objectClass; | 238 ClassElement defaultSuperclass(ClassElement element) => compiler.objectClass; |
| 239 | 239 |
| 240 bool isDefaultNoSuchMethodImplementation(Element element) { | 240 bool isDefaultNoSuchMethodImplementation(Element element) { |
| 241 assert(element.name == Compiler.NO_SUCH_METHOD); | 241 assert(element.name == Compiler.NO_SUCH_METHOD); |
| 242 ClassElement classElement = element.getEnclosingClass(); | 242 ClassElement classElement = element.getEnclosingClass(); |
| 243 return classElement == compiler.objectClass; | 243 return classElement == compiler.objectClass; |
| 244 } | 244 } |
| 245 | 245 |
| 246 void registerStaticUse(Element element, Enqueuer enqueuer) {} | 246 void registerStaticUse(Element element, Enqueuer enqueuer) {} |
| 247 | 247 |
| 248 void onLibraryScanned(LibraryElement library, Uri uri) {} | 248 void onLibraryLoaded(LibraryElement library, Uri uri) {} |
| 249 | 249 |
| 250 void registerMetadataInstantiatedType(DartType type, TreeElements elements) {} | 250 void registerMetadataInstantiatedType(DartType type, TreeElements elements) {} |
| 251 void registerMetadataStaticUse(Element element) {} | 251 void registerMetadataStaticUse(Element element) {} |
| 252 void registerMetadataGetOfStaticFunction(FunctionElement element) {} | 252 void registerMetadataGetOfStaticFunction(FunctionElement element) {} |
| 253 | 253 |
| 254 /// Called by [MirrorUsageAnalyzerTask] after it has merged all @MirrorsUsed | 254 /// Called by [MirrorUsageAnalyzerTask] after it has merged all @MirrorsUsed |
| 255 /// annotations. The arguments corresponds to the unions of the corresponding | 255 /// annotations. The arguments corresponds to the unions of the corresponding |
| 256 /// fields of the annotations. | 256 /// fields of the annotations. |
| 257 void registerMirrorUsage(Set<String> symbols, | 257 void registerMirrorUsage(Set<String> symbols, |
| 258 Set<Element> targets, | 258 Set<Element> targets, |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 } | 747 } |
| 748 return !compilationFailed; | 748 return !compilationFailed; |
| 749 } | 749 } |
| 750 | 750 |
| 751 bool hasIsolateSupport() => isolateLibrary != null; | 751 bool hasIsolateSupport() => isolateLibrary != null; |
| 752 | 752 |
| 753 /** | 753 /** |
| 754 * This method is called before [library] import and export scopes have been | 754 * This method is called before [library] import and export scopes have been |
| 755 * set up. | 755 * set up. |
| 756 */ | 756 */ |
| 757 void onLibraryScanned(LibraryElement library, Uri uri) { | 757 void onLibraryLoaded(LibraryElement library, Uri uri) { |
| 758 if (dynamicClass != null) { | 758 if (dynamicClass != null) { |
| 759 // When loading the built-in libraries, dynamicClass is null. We | 759 // When loading the built-in libraries, dynamicClass is null. We |
| 760 // take advantage of this as core imports js_helper and sees [dynamic] | 760 // take advantage of this as core imports js_helper and sees [dynamic] |
| 761 // this way. | 761 // this way. |
| 762 withCurrentElement(dynamicClass, () { | 762 withCurrentElement(dynamicClass, () { |
| 763 library.addToScope(dynamicClass, this); | 763 library.addToScope(dynamicClass, this); |
| 764 }); | 764 }); |
| 765 } | 765 } |
| 766 if (uri == new Uri(scheme: 'dart', path: 'mirrors')) { | 766 if (uri == new Uri(scheme: 'dart', path: 'mirrors')) { |
| 767 mirrorsLibrary = library; | 767 mirrorsLibrary = library; |
| 768 mirrorSystemClass = | 768 mirrorSystemClass = |
| 769 findRequiredElement(library, const SourceString('MirrorSystem')); | 769 findRequiredElement(library, const SourceString('MirrorSystem')); |
| 770 mirrorsUsedClass = | 770 mirrorsUsedClass = |
| 771 findRequiredElement(library, const SourceString('MirrorsUsed')); | 771 findRequiredElement(library, const SourceString('MirrorsUsed')); |
| 772 } else if (uri == new Uri(scheme: 'dart', path: '_collection-dev')) { | 772 } else if (uri == new Uri(scheme: 'dart', path: '_collection-dev')) { |
| 773 symbolImplementationClass = | 773 symbolImplementationClass = |
| 774 findRequiredElement(library, const SourceString('Symbol')); | 774 findRequiredElement(library, const SourceString('Symbol')); |
| 775 } else if (uri == new Uri(scheme: 'dart', path: 'async')) { | 775 } else if (uri == new Uri(scheme: 'dart', path: 'async')) { |
| 776 deferredLibraryClass = | 776 deferredLibraryClass = |
| 777 findRequiredElement(library, const SourceString('DeferredLibrary')); | 777 findRequiredElement(library, const SourceString('DeferredLibrary')); |
| 778 } else if (isolateHelperLibrary == null |
| 779 && (uri == new Uri(scheme: 'dart', path: '_isolate_helper'))) { |
| 780 isolateHelperLibrary = scanBuiltinLibrary('_isolate_helper'); |
| 781 } else if (foreignLibrary == null |
| 782 && (uri == new Uri(scheme: 'dart', path: '_foreign_helper'))) { |
| 783 foreignLibrary = scanBuiltinLibrary('_foreign_helper'); |
| 778 } | 784 } |
| 779 backend.onLibraryScanned(library, uri); | 785 backend.onLibraryLoaded(library, uri); |
| 780 } | 786 } |
| 781 | 787 |
| 782 Element findRequiredElement(LibraryElement library, SourceString name) { | 788 Element findRequiredElement(LibraryElement library, SourceString name) { |
| 783 var element = library.find(name); | 789 var element = library.find(name); |
| 784 if (element == null) { | 790 if (element == null) { |
| 785 internalErrorOnElement( | 791 internalErrorOnElement( |
| 786 library, | 792 library, |
| 787 'The library "${library.canonicalUri}" does not contain required ' | 793 'The library "${library.canonicalUri}" does not contain required ' |
| 788 'element: ${name.slowToString()}'); | 794 'element: ${name.slowToString()}'); |
| 789 } | 795 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 878 if (_filledListConstructor != null) return _filledListConstructor; | 884 if (_filledListConstructor != null) return _filledListConstructor; |
| 879 Selector callConstructor = new Selector.callConstructor( | 885 Selector callConstructor = new Selector.callConstructor( |
| 880 const SourceString("filled"), listClass.getLibrary()); | 886 const SourceString("filled"), listClass.getLibrary()); |
| 881 return _filledListConstructor = | 887 return _filledListConstructor = |
| 882 listClass.lookupConstructor(callConstructor); | 888 listClass.lookupConstructor(callConstructor); |
| 883 } | 889 } |
| 884 | 890 |
| 885 void scanBuiltinLibraries() { | 891 void scanBuiltinLibraries() { |
| 886 jsHelperLibrary = scanBuiltinLibrary('_js_helper'); | 892 jsHelperLibrary = scanBuiltinLibrary('_js_helper'); |
| 887 interceptorsLibrary = scanBuiltinLibrary('_interceptors'); | 893 interceptorsLibrary = scanBuiltinLibrary('_interceptors'); |
| 888 foreignLibrary = scanBuiltinLibrary('_foreign_helper'); | |
| 889 isolateHelperLibrary = scanBuiltinLibrary('_isolate_helper'); | |
| 890 | |
| 891 assertMethod = jsHelperLibrary.find(const SourceString('assertHelper')); | 894 assertMethod = jsHelperLibrary.find(const SourceString('assertHelper')); |
| 892 identicalFunction = coreLibrary.find(const SourceString('identical')); | 895 identicalFunction = coreLibrary.find(const SourceString('identical')); |
| 893 | 896 |
| 894 initializeSpecialClasses(); | 897 initializeSpecialClasses(); |
| 895 | 898 |
| 896 functionClass.ensureResolved(this); | 899 functionClass.ensureResolved(this); |
| 897 functionApplyMethod = | 900 functionApplyMethod = |
| 898 functionClass.lookupLocalMember(const SourceString('apply')); | 901 functionClass.lookupLocalMember(const SourceString('apply')); |
| 899 jsInvocationMirrorClass.ensureResolved(this); | 902 jsInvocationMirrorClass.ensureResolved(this); |
| 900 invokeOnMethod = jsInvocationMirrorClass.lookupLocalMember(INVOKE_ON); | 903 invokeOnMethod = jsInvocationMirrorClass.lookupLocalMember(INVOKE_ON); |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 | 1528 |
| 1526 void close() {} | 1529 void close() {} |
| 1527 | 1530 |
| 1528 toString() => name; | 1531 toString() => name; |
| 1529 | 1532 |
| 1530 /// Convenience method for getting an [api.CompilerOutputProvider]. | 1533 /// Convenience method for getting an [api.CompilerOutputProvider]. |
| 1531 static NullSink outputProvider(String name, String extension) { | 1534 static NullSink outputProvider(String name, String extension) { |
| 1532 return new NullSink('$name.$extension'); | 1535 return new NullSink('$name.$extension'); |
| 1533 } | 1536 } |
| 1534 } | 1537 } |
| OLD | NEW |