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

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

Issue 206193002: Remove cancel and make crash exit with code 253. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 years, 9 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 * [CompilerTask] for loading libraries and setting up the import/export scopes. 8 * [CompilerTask] for loading libraries and setting up the import/export scopes.
9 * 9 *
10 * The library loader uses four different kinds of URIs in different parts of 10 * The library loader uses four different kinds of URIs in different parts of
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 if (import.uri.dartString.slowToString() == 'dart:core') { 290 if (import.uri.dartString.slowToString() == 'dart:core') {
291 importsDartCore = true; 291 importsDartCore = true;
292 } 292 }
293 libraryDependencies.addLast(import); 293 libraryDependencies.addLast(import);
294 } else if (tag.isExport) { 294 } else if (tag.isExport) {
295 tagState = checkTag(TagState.IMPORT_OR_EXPORT, tag); 295 tagState = checkTag(TagState.IMPORT_OR_EXPORT, tag);
296 libraryDependencies.addLast(tag); 296 libraryDependencies.addLast(tag);
297 } else if (tag.isLibraryName) { 297 } else if (tag.isLibraryName) {
298 tagState = checkTag(TagState.LIBRARY, tag); 298 tagState = checkTag(TagState.LIBRARY, tag);
299 if (library.libraryTag != null) { 299 if (library.libraryTag != null) {
300 compiler.cancel("duplicated library declaration", node: tag); 300 compiler.internalError(tag, "Duplicated library declaration.");
301 } else { 301 } else {
302 library.libraryTag = tag; 302 library.libraryTag = tag;
303 } 303 }
304 } else if (tag.isPart) { 304 } else if (tag.isPart) {
305 Part part = tag; 305 Part part = tag;
306 StringNode uri = part.uri; 306 StringNode uri = part.uri;
307 Uri resolvedUri = base.resolve(uri.dartString.slowToString()); 307 Uri resolvedUri = base.resolve(uri.dartString.slowToString());
308 tagState = checkTag(TagState.SOURCE, part); 308 tagState = checkTag(TagState.SOURCE, part);
309 return scanPart(part, resolvedUri, library); 309 return scanPart(part, resolvedUri, library);
310 } else { 310 } else {
311 compiler.internalError("Unhandled library tag.", node: tag); 311 compiler.internalError(tag, "Unhandled library tag.");
312 } 312 }
313 }); 313 });
314 }).then((_) { 314 }).then((_) {
315 return compiler.withCurrentElement(library, () { 315 return compiler.withCurrentElement(library, () {
316 checkDuplicatedLibraryName(library); 316 checkDuplicatedLibraryName(library);
317 // Apply patch, if any. 317 // Apply patch, if any.
318 if (library.isPlatformLibrary) { 318 if (library.isPlatformLibrary) {
319 return patchDartLibrary(handler, library, library.canonicalUri.path); 319 return patchDartLibrary(handler, library, library.canonicalUri.path);
320 } 320 }
321 }); 321 });
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 } 406 }
407 407
408 /** 408 /**
409 * Handle a part tag in the scope of [library]. The [resolvedUri] given is 409 * Handle a part tag in the scope of [library]. The [resolvedUri] given is
410 * used as is, any URI resolution should be done beforehand. 410 * used as is, any URI resolution should be done beforehand.
411 */ 411 */
412 Future scanPart(Part part, Uri resolvedUri, LibraryElement library) { 412 Future scanPart(Part part, Uri resolvedUri, LibraryElement library) {
413 if (!resolvedUri.isAbsolute) throw new ArgumentError(resolvedUri); 413 if (!resolvedUri.isAbsolute) throw new ArgumentError(resolvedUri);
414 Uri readableUri = compiler.translateResolvedUri(library, resolvedUri, part); 414 Uri readableUri = compiler.translateResolvedUri(library, resolvedUri, part);
415 if (readableUri == null) return new Future.value(); 415 if (readableUri == null) return new Future.value();
416 return compiler.readScript(readableUri, library, part). 416 return compiler.withCurrentElement(library, () {
417 then((Script sourceScript) { 417 return compiler.readScript(part, readableUri).
418 if (sourceScript == null) return; 418 then((Script sourceScript) {
419 if (sourceScript == null) return;
419 420
420 CompilationUnitElement unit = 421 CompilationUnitElement unit =
421 new CompilationUnitElementX(sourceScript, library); 422 new CompilationUnitElementX(sourceScript, library);
422 compiler.withCurrentElement(unit, () { 423 compiler.withCurrentElement(unit, () {
423 compiler.scanner.scan(unit); 424 compiler.scanner.scan(unit);
424 if (unit.partTag == null) { 425 if (unit.partTag == null) {
425 compiler.reportError(unit, MessageKind.MISSING_PART_OF_TAG); 426 compiler.reportError(unit, MessageKind.MISSING_PART_OF_TAG);
426 } 427 }
428 });
427 }); 429 });
428 }); 430 });
429 } 431 }
430 432
431 /** 433 /**
432 * Handle an import/export tag by loading the referenced library and 434 * Handle an import/export tag by loading the referenced library and
433 * registering its dependency in [handler] for the computation of the import/ 435 * registering its dependency in [handler] for the computation of the import/
434 * export scope. 436 * export scope.
435 */ 437 */
436 Future registerLibraryFromTag(LibraryDependencyHandler handler, 438 Future registerLibraryFromTag(LibraryDependencyHandler handler,
437 LibraryElement library, 439 LibraryElement library,
438 LibraryDependency tag) { 440 LibraryDependency tag) {
(...skipping 10 matching lines...) Expand all
449 451
450 /** 452 /**
451 * Create (or reuse) a library element for the library specified by the 453 * Create (or reuse) a library element for the library specified by the
452 * [resolvedUri]. 454 * [resolvedUri].
453 * 455 *
454 * If a new library is created, the [handler] is notified. 456 * If a new library is created, the [handler] is notified.
455 */ 457 */
456 // TODO(johnniwinther): Remove [canonicalUri] and make [resolvedUri] the 458 // TODO(johnniwinther): Remove [canonicalUri] and make [resolvedUri] the
457 // canonical uri when [Compiler.scanBuiltinLibrary] is removed. 459 // canonical uri when [Compiler.scanBuiltinLibrary] is removed.
458 Future<LibraryElement> createLibrary(LibraryDependencyHandler handler, 460 Future<LibraryElement> createLibrary(LibraryDependencyHandler handler,
459 LibraryElement importingLibrary, 461 LibraryElement importingLibrary,
460 Uri resolvedUri, Node node, Uri canonicalUri) { 462 Uri resolvedUri,
463 Node node,
464 Uri canonicalUri) {
461 // TODO(johnniwinther): Create erroneous library elements for missing 465 // TODO(johnniwinther): Create erroneous library elements for missing
462 // libraries. 466 // libraries.
463 Uri readableUri = 467 Uri readableUri =
464 compiler.translateResolvedUri(importingLibrary, resolvedUri, node); 468 compiler.translateResolvedUri(importingLibrary, resolvedUri, node);
465 if (readableUri == null) return new Future.value(); 469 if (readableUri == null) return new Future.value();
466 LibraryElement library; 470 LibraryElement library;
467 if (canonicalUri != null) { 471 if (canonicalUri != null) {
468 library = compiler.libraries[canonicalUri.toString()]; 472 library = compiler.libraries[canonicalUri.toString()];
469 } 473 }
470 if (library != null) { 474 if (library != null) {
471 return new Future.value(library); 475 return new Future.value(library);
472 } 476 }
473 return compiler.readScript(readableUri, importingLibrary, node) 477 return compiler.withCurrentElement(importingLibrary, () {
474 .then((Script script) { 478 return compiler.readScript(node, readableUri)
475 if (script == null) return null; 479 .then((Script script) {
476 LibraryElement element = new LibraryElementX(script, canonicalUri); 480 if (script == null) return null;
477 compiler.withCurrentElement(element, () { 481 LibraryElement element = new LibraryElementX(script, canonicalUri);
478 handler.registerNewLibrary(element); 482 compiler.withCurrentElement(element, () {
479 native.maybeEnableNative(compiler, element); 483 handler.registerNewLibrary(element);
480 if (canonicalUri != null) { 484 native.maybeEnableNative(compiler, element);
481 compiler.libraries[canonicalUri.toString()] = element; 485 if (canonicalUri != null) {
482 } 486 compiler.libraries[canonicalUri.toString()] = element;
483 compiler.scanner.scanLibrary(element); 487 }
488 compiler.scanner.scanLibrary(element);
489 });
490 return processLibraryTags(handler, element).then((_) {
491 compiler.withCurrentElement(element, () {
492 handler.registerLibraryExports(element);
493 onLibraryLoadedCallbacks.add(
494 () => compiler.onLibraryLoaded(element, resolvedUri));
495 });
496 return element;
497 });
484 }); 498 });
485 return processLibraryTags(handler, element).then((_) { 499 });
486 compiler.withCurrentElement(element, () {
487 handler.registerLibraryExports(element);
488 onLibraryLoadedCallbacks.add(
489 () => compiler.onLibraryLoaded(element, resolvedUri));
490 });
491 return element;
492 });
493 });
494 } 500 }
495 501
496 // TODO(johnniwinther): Remove this method when 'js_helper' is handled by 502 // TODO(johnniwinther): Remove this method when 'js_helper' is handled by
497 // [LibraryLoaderTask]. 503 // [LibraryLoaderTask].
498 void importLibrary(LibraryElement importingLibrary, 504 void importLibrary(LibraryElement importingLibrary,
499 LibraryElement importedLibrary, 505 LibraryElement importedLibrary,
500 Import tag) { 506 Import tag) {
501 new ImportLink(tag, importedLibrary).importLibrary(compiler, 507 new ImportLink(tag, importedLibrary).importLibrary(compiler,
502 importingLibrary); 508 importingLibrary);
503 } 509 }
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 } 926 }
921 927
922 /** 928 /**
923 * Registers all top-level entities of [library] as starting point for the 929 * Registers all top-level entities of [library] as starting point for the
924 * fixed-point computation of the import/export scopes. 930 * fixed-point computation of the import/export scopes.
925 */ 931 */
926 void registerLibraryExports(LibraryElement library) { 932 void registerLibraryExports(LibraryElement library) {
927 nodeMap[library].registerInitialExports(); 933 nodeMap[library].registerInitialExports();
928 } 934 }
929 } 935 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698