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

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

Issue 10990060: Added support for exports and re-exports. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments Created 8 years, 2 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 5
6 /** 6 /**
7 * If true, print a warning for each method that was resolved, but not 7 * If true, print a warning for each method that was resolved, but not
8 * compiled. 8 * compiled.
9 */ 9 */
10 const bool REPORT_EXCESS_RESOLUTION = false; 10 const bool REPORT_EXCESS_RESOLUTION = false;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } finally { 155 } finally {
156 _currentElement = old; 156 _currentElement = old;
157 } 157 }
158 } 158 }
159 159
160 List<CompilerTask> tasks; 160 List<CompilerTask> tasks;
161 ScannerTask scanner; 161 ScannerTask scanner;
162 DietParserTask dietParser; 162 DietParserTask dietParser;
163 ParserTask parser; 163 ParserTask parser;
164 PatchParserTask patchParser; 164 PatchParserTask patchParser;
165 LibraryLoader libraryLoader;
165 TreeValidatorTask validator; 166 TreeValidatorTask validator;
166 ResolverTask resolver; 167 ResolverTask resolver;
167 closureMapping.ClosureTask closureToClassMapper; 168 closureMapping.ClosureTask closureToClassMapper;
168 TypeCheckerTask checker; 169 TypeCheckerTask checker;
169 ti.TypesTask typesTask; 170 ti.TypesTask typesTask;
170 Backend backend; 171 Backend backend;
171 ConstantHandler constantHandler; 172 ConstantHandler constantHandler;
172 EnqueueTask enqueuer; 173 EnqueueTask enqueuer;
173 174
174 static const SourceString MAIN = const SourceString('main'); 175 static const SourceString MAIN = const SourceString('main');
(...skipping 25 matching lines...) Expand all
200 bool generateSourceMap = true, 201 bool generateSourceMap = true,
201 List<String> strips = const []]) 202 List<String> strips = const []])
202 : libraries = new Map<String, LibraryElement>(), 203 : libraries = new Map<String, LibraryElement>(),
203 progress = new Stopwatch() { 204 progress = new Stopwatch() {
204 progress.start(); 205 progress.start();
205 world = new World(this); 206 world = new World(this);
206 scanner = new ScannerTask(this); 207 scanner = new ScannerTask(this);
207 dietParser = new DietParserTask(this); 208 dietParser = new DietParserTask(this);
208 parser = new ParserTask(this); 209 parser = new ParserTask(this);
209 patchParser = new PatchParserTask(this); 210 patchParser = new PatchParserTask(this);
211 libraryLoader = new LibraryLoaderTask(this);
210 validator = new TreeValidatorTask(this); 212 validator = new TreeValidatorTask(this);
211 resolver = new ResolverTask(this); 213 resolver = new ResolverTask(this);
212 closureToClassMapper = new closureMapping.ClosureTask(this); 214 closureToClassMapper = new closureMapping.ClosureTask(this);
213 checker = new TypeCheckerTask(this); 215 checker = new TypeCheckerTask(this);
214 typesTask = new ti.TypesTask(this); 216 typesTask = new ti.TypesTask(this);
215 backend = emitJavaScript ? 217 backend = emitJavaScript ?
216 new js_backend.JavaScriptBackend(this, generateSourceMap) : 218 new js_backend.JavaScriptBackend(this, generateSourceMap) :
217 new dart_backend.DartBackend(this, strips); 219 new dart_backend.DartBackend(this, strips);
218 constantHandler = new ConstantHandler(this, backend.constantSystem); 220 constantHandler = new ConstantHandler(this, backend.constantSystem);
219 enqueuer = new EnqueueTask(this); 221 enqueuer = new EnqueueTask(this);
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 389
388 initializeSpecialClasses(); 390 initializeSpecialClasses();
389 391
390 functionClass.ensureResolved(this); 392 functionClass.ensureResolved(this);
391 functionApplyMethod = 393 functionApplyMethod =
392 functionClass.lookupLocalMember(const SourceString('apply')); 394 functionClass.lookupLocalMember(const SourceString('apply'));
393 } 395 }
394 396
395 void loadCoreImplLibrary() { 397 void loadCoreImplLibrary() {
396 Uri coreImplUri = new Uri.fromComponents(scheme: 'dart', path: 'coreimpl'); 398 Uri coreImplUri = new Uri.fromComponents(scheme: 'dart', path: 'coreimpl');
397 coreImplLibrary = scanner.loadLibrary(coreImplUri, null, coreImplUri); 399 coreImplLibrary = libraryLoader.loadLibrary(coreImplUri, null, coreImplUri);
398 } 400 }
399 401
400 void importHelperLibrary(LibraryElement library) { 402 void importHelperLibrary(LibraryElement library) {
401 if (jsHelperLibrary !== null) { 403 if (jsHelperLibrary !== null) {
402 scanner.importLibrary(library, jsHelperLibrary, null); 404 libraryLoader.importLibrary(this, library, jsHelperLibrary, null);
403 } 405 }
404 } 406 }
405 407
406 void importCoreLibrary(LibraryElement library) {
407 if (coreLibrary === null) {
408 Uri coreUri = new Uri.fromComponents(scheme: 'dart', path: 'core');
409 coreLibrary = scanner.loadLibrary(coreUri, null, coreUri);
410 }
411 scanner.importLibrary(library,
412 coreLibrary,
413 null,
414 library.entryCompilationUnit);
415 }
416
417 void patchDartLibrary(LibraryElement library, String dartLibraryPath) {
418 if (library.isPatched) return;
419 Uri patchUri = resolvePatchUri(dartLibraryPath);
420 if (patchUri !== null) {
421 patchParser.patchLibrary(patchUri, library);
422 }
423 }
424
425 /** 408 /**
426 * Get an [Uri] pointing to a patch for the dart: library with 409 * Get an [Uri] pointing to a patch for the dart: library with
427 * the given path. Returns null if there is no patch. 410 * the given path. Returns null if there is no patch.
428 */ 411 */
429 abstract Uri resolvePatchUri(String dartLibraryPath); 412 abstract Uri resolvePatchUri(String dartLibraryPath);
430 413
431 /** Define the JS helper functions in the given library. */ 414 /** Define the JS helper functions in the given library. */
432 void addForeignFunctions(LibraryElement library) { 415 void addForeignFunctions(LibraryElement library) {
433 library.addToScope(new ForeignElement( 416 library.addToScope(new ForeignElement(
434 const SourceString('JS'), library), this); 417 const SourceString('JS'), library), this);
(...skipping 23 matching lines...) Expand all
458 findHelper(const SourceString('JavaScriptIndexingBehavior')); 441 findHelper(const SourceString('JavaScriptIndexingBehavior'));
459 if (jsIndexingBehaviorInterface !== null) { 442 if (jsIndexingBehaviorInterface !== null) {
460 library.addToScope(jsIndexingBehaviorInterface, this); 443 library.addToScope(jsIndexingBehaviorInterface, this);
461 } 444 }
462 } 445 }
463 } 446 }
464 447
465 void runCompiler(Uri uri) { 448 void runCompiler(Uri uri) {
466 log('compiling $uri ($BUILD_ID)'); 449 log('compiling $uri ($BUILD_ID)');
467 scanBuiltinLibraries(); 450 scanBuiltinLibraries();
468 mainApp = scanner.loadLibrary(uri, null, uri); 451 mainApp = libraryLoader.loadLibrary(uri, null, uri);
469 libraries.forEach((_, library) { 452 libraries.forEach((_, library) {
470 maybeEnableJSHelper(library); 453 maybeEnableJSHelper(library);
471 }); 454 });
472 final Element main = mainApp.find(MAIN); 455 final Element main = mainApp.find(MAIN);
473 if (main === null) { 456 if (main === null) {
474 reportFatalError('Could not find $MAIN', mainApp); 457 reportFatalError('Could not find $MAIN', mainApp);
475 } else { 458 } else {
476 if (!main.isFunction()) reportFatalError('main is not a function', main); 459 if (!main.isFunction()) reportFatalError('main is not a function', main);
477 FunctionElement mainMethod = main; 460 FunctionElement mainMethod = main;
478 FunctionSignature parameters = mainMethod.computeSignature(this); 461 FunctionSignature parameters = mainMethod.computeSignature(this);
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 * 837 *
855 * [spannable] must be non-null and will be used to provide positional 838 * [spannable] must be non-null and will be used to provide positional
856 * information in the generated error message. 839 * information in the generated error message.
857 */ 840 */
858 bool invariant(Spannable spannable, var condition, {String message: null}) { 841 bool invariant(Spannable spannable, var condition, {String message: null}) {
859 // TODO(johnniwinther): Use [spannable] and [message] to provide better 842 // TODO(johnniwinther): Use [spannable] and [message] to provide better
860 // information on assertion errors. 843 // information on assertion errors.
861 if (condition is Function){ 844 if (condition is Function){
862 condition = condition(); 845 condition = condition();
863 } 846 }
847 if (!condition && message != null) {
848 print('assertion failed: $message');
849 }
864 return spannable != null && condition; 850 return spannable != null && condition;
865 } 851 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698