Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(863)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/compiler.dart

Issue 23258002: Load builtin helper libraries on demand. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 ClassElement defaultSuperclass(ClassElement element) => compiler.objectClass; 199 ClassElement defaultSuperclass(ClassElement element) => compiler.objectClass;
200 200
201 bool isDefaultNoSuchMethodImplementation(Element element) { 201 bool isDefaultNoSuchMethodImplementation(Element element) {
202 assert(element.name == Compiler.NO_SUCH_METHOD); 202 assert(element.name == Compiler.NO_SUCH_METHOD);
203 ClassElement classElement = element.getEnclosingClass(); 203 ClassElement classElement = element.getEnclosingClass();
204 return classElement == compiler.objectClass; 204 return classElement == compiler.objectClass;
205 } 205 }
206 206
207 void registerStaticUse(Element element, Enqueuer enqueuer) {} 207 void registerStaticUse(Element element, Enqueuer enqueuer) {}
208 208
209 void onLibraryScanned(LibraryElement library, Uri uri) {} 209 void onLibraryLoaded(LibraryElement library, Uri uri) {}
210 210
211 void registerMetadataInstantiatedType(DartType type, TreeElements elements) {} 211 void registerMetadataInstantiatedType(DartType type, TreeElements elements) {}
212 void registerMetadataStaticUse(Element element) {} 212 void registerMetadataStaticUse(Element element) {}
213 void registerMetadataGetOfStaticFunction(FunctionElement element) {} 213 void registerMetadataGetOfStaticFunction(FunctionElement element) {}
214 214
215 /// Called by [MirrorUsageAnalyzerTask] after it has merged all @MirrorsUsed 215 /// Called by [MirrorUsageAnalyzerTask] after it has merged all @MirrorsUsed
216 /// annotations. The arguments corresponds to the unions of the corresponding 216 /// annotations. The arguments corresponds to the unions of the corresponding
217 /// fields of the annotations. 217 /// fields of the annotations.
218 void registerMirrorUsage(Set<String> symbols, 218 void registerMirrorUsage(Set<String> symbols,
219 Set<Element> targets, 219 Set<Element> targets,
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 } 697 }
698 return !compilationFailed; 698 return !compilationFailed;
699 } 699 }
700 700
701 bool hasIsolateSupport() => isolateLibrary != null; 701 bool hasIsolateSupport() => isolateLibrary != null;
702 702
703 /** 703 /**
704 * This method is called before [library] import and export scopes have been 704 * This method is called before [library] import and export scopes have been
705 * set up. 705 * set up.
706 */ 706 */
707 void onLibraryScanned(LibraryElement library, Uri uri) { 707 void onLibraryLoaded(LibraryElement library, Uri uri) {
708 if (dynamicClass != null) { 708 if (dynamicClass != null) {
709 // When loading the built-in libraries, dynamicClass is null. We 709 // When loading the built-in libraries, dynamicClass is null. We
710 // take advantage of this as core imports js_helper and sees [dynamic] 710 // take advantage of this as core imports js_helper and sees [dynamic]
711 // this way. 711 // this way.
712 withCurrentElement(dynamicClass, () { 712 withCurrentElement(dynamicClass, () {
713 library.addToScope(dynamicClass, this); 713 library.addToScope(dynamicClass, this);
714 }); 714 });
715 } 715 }
716 if (uri == new Uri(scheme: 'dart', path: 'mirrors')) { 716 if (uri == new Uri(scheme: 'dart', path: 'mirrors')) {
717 mirrorsLibrary = library; 717 mirrorsLibrary = library;
718 mirrorSystemClass = 718 mirrorSystemClass =
719 findRequiredElement(library, const SourceString('MirrorSystem')); 719 findRequiredElement(library, const SourceString('MirrorSystem'));
720 mirrorsUsedClass = 720 mirrorsUsedClass =
721 findRequiredElement(library, const SourceString('MirrorsUsed')); 721 findRequiredElement(library, const SourceString('MirrorsUsed'));
722 } else if (uri == new Uri(scheme: 'dart', path: '_collection-dev')) { 722 } else if (uri == new Uri(scheme: 'dart', path: '_collection-dev')) {
723 symbolImplementationClass = 723 symbolImplementationClass =
724 findRequiredElement(library, const SourceString('Symbol')); 724 findRequiredElement(library, const SourceString('Symbol'));
725 } else if (uri == new Uri(scheme: 'dart', path: 'async')) { 725 } else if (uri == new Uri(scheme: 'dart', path: 'async')) {
726 deferredLibraryClass = 726 deferredLibraryClass =
727 findRequiredElement(library, const SourceString('DeferredLibrary')); 727 findRequiredElement(library, const SourceString('DeferredLibrary'));
728 } 728 }
ngeoffray 2013/08/15 19:13:02 Nit: Keep the else/if syntax.
zarah 2013/08/28 10:20:13 Done.
729 backend.onLibraryScanned(library, uri); 729
730 if (isolateHelperLibrary == null
731 && (uri == new Uri(scheme: 'dart', path: '_isolate_helper'))) {
732 isolateHelperLibrary = scanBuiltinLibrary('_isolate_helper');
733 } else if (foreignLibrary == null
734 && (uri == new Uri(scheme: 'dart', path: '_foreign_helper'))) {
ngeoffray 2013/08/15 19:13:02 Nit: '&&' at the same indentation as foreignLibrar
zarah 2013/08/28 10:20:13 Done.
735 foreignLibrary = scanBuiltinLibrary('_foreign_helper');
736 }
737 backend.onLibraryLoaded(library, uri);
730 } 738 }
731 739
732 Element findRequiredElement(LibraryElement library, SourceString name) { 740 Element findRequiredElement(LibraryElement library, SourceString name) {
733 var element = library.find(name); 741 var element = library.find(name);
734 if (element == null) { 742 if (element == null) {
735 internalErrorOnElement( 743 internalErrorOnElement(
736 library, 744 library,
737 'The library "${library.canonicalUri}" does not contain required ' 745 'The library "${library.canonicalUri}" does not contain required '
738 'element: ${name.slowToString()}'); 746 'element: ${name.slowToString()}');
739 } 747 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 Element get filledListConstructor { 835 Element get filledListConstructor {
828 if (_filledListConstructor != null) return _filledListConstructor; 836 if (_filledListConstructor != null) return _filledListConstructor;
829 Selector callConstructor = new Selector.callConstructor( 837 Selector callConstructor = new Selector.callConstructor(
830 const SourceString("filled"), listClass.getLibrary()); 838 const SourceString("filled"), listClass.getLibrary());
831 return _filledListConstructor = 839 return _filledListConstructor =
832 listClass.lookupConstructor(callConstructor); 840 listClass.lookupConstructor(callConstructor);
833 } 841 }
834 842
835 void scanBuiltinLibraries() { 843 void scanBuiltinLibraries() {
836 jsHelperLibrary = scanBuiltinLibrary('_js_helper'); 844 jsHelperLibrary = scanBuiltinLibrary('_js_helper');
837 interceptorsLibrary = scanBuiltinLibrary('_interceptors'); 845 interceptorsLibrary = scanBuiltinLibrary('_interceptors');
ngeoffray 2013/08/15 19:13:02 What about those two? Do you plan on moving them?
zarah 2013/08/28 10:20:13 The jsHelperLibrary is used just below and the int
838 foreignLibrary = scanBuiltinLibrary('_foreign_helper');
839 isolateHelperLibrary = scanBuiltinLibrary('_isolate_helper');
840
841 assertMethod = jsHelperLibrary.find(const SourceString('assertHelper')); 846 assertMethod = jsHelperLibrary.find(const SourceString('assertHelper'));
842 identicalFunction = coreLibrary.find(const SourceString('identical')); 847 identicalFunction = coreLibrary.find(const SourceString('identical'));
843 848
844 initializeSpecialClasses(); 849 initializeSpecialClasses();
845 850
846 functionClass.ensureResolved(this); 851 functionClass.ensureResolved(this);
847 functionApplyMethod = 852 functionApplyMethod =
848 functionClass.lookupLocalMember(const SourceString('apply')); 853 functionClass.lookupLocalMember(const SourceString('apply'));
849 jsInvocationMirrorClass.ensureResolved(this); 854 jsInvocationMirrorClass.ensureResolved(this);
850 invokeOnMethod = jsInvocationMirrorClass.lookupLocalMember(INVOKE_ON); 855 invokeOnMethod = jsInvocationMirrorClass.lookupLocalMember(INVOKE_ON);
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 1480
1476 void close() {} 1481 void close() {}
1477 1482
1478 toString() => name; 1483 toString() => name;
1479 1484
1480 /// Convenience method for getting an [api.CompilerOutputProvider]. 1485 /// Convenience method for getting an [api.CompilerOutputProvider].
1481 static NullSink outputProvider(String name, String extension) { 1486 static NullSink outputProvider(String name, String extension) {
1482 return new NullSink('$name.$extension'); 1487 return new NullSink('$name.$extension');
1483 } 1488 }
1484 } 1489 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698