| 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 * [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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 void checkDuplicatedLibraryName(LibraryElement library) { | 312 void checkDuplicatedLibraryName(LibraryElement library) { |
| 313 LibraryName tag = library.libraryTag; | 313 LibraryName tag = library.libraryTag; |
| 314 if (tag != null) { | 314 if (tag != null) { |
| 315 String name = library.getLibraryOrScriptName(); | 315 String name = library.getLibraryOrScriptName(); |
| 316 LibraryElement existing = | 316 LibraryElement existing = |
| 317 libraryNames.putIfAbsent(name, () => library); | 317 libraryNames.putIfAbsent(name, () => library); |
| 318 if (!identical(existing, library)) { | 318 if (!identical(existing, library)) { |
| 319 Uri uri = library.entryCompilationUnit.script.uri; | 319 Uri uri = library.entryCompilationUnit.script.uri; |
| 320 compiler.reportMessage( | 320 compiler.reportMessage( |
| 321 compiler.spanFromSpannable(tag.name, uri), | 321 compiler.spanFromSpannable(tag.name, uri), |
| 322 MessageKind.DUPLICATED_LIBRARY_NAME.error([name]), | 322 MessageKind.DUPLICATED_LIBRARY_NAME.error({'libraryName': name}), |
| 323 api.Diagnostic.WARNING); | 323 api.Diagnostic.WARNING); |
| 324 Uri existingUri = existing.entryCompilationUnit.script.uri; | 324 Uri existingUri = existing.entryCompilationUnit.script.uri; |
| 325 compiler.reportMessage( | 325 compiler.reportMessage( |
| 326 compiler.spanFromSpannable(existing.libraryTag.name, existingUri), | 326 compiler.spanFromSpannable(existing.libraryTag.name, existingUri), |
| 327 MessageKind.DUPLICATED_LIBRARY_NAME.error([name]), | 327 MessageKind.DUPLICATED_LIBRARY_NAME.error({'libraryName': name}), |
| 328 api.Diagnostic.WARNING); | 328 api.Diagnostic.WARNING); |
| 329 } | 329 } |
| 330 } | 330 } |
| 331 } | 331 } |
| 332 | 332 |
| 333 bool isDartCore(Uri uri) => uri.scheme == "dart" && uri.path == "core"; | 333 bool isDartCore(Uri uri) => uri.scheme == "dart" && uri.path == "core"; |
| 334 | 334 |
| 335 /** | 335 /** |
| 336 * Lazily loads and returns the [LibraryElement] for the dart:core library. | 336 * Lazily loads and returns the [LibraryElement] for the dart:core library. |
| 337 */ | 337 */ |
| (...skipping 29 matching lines...) Expand all Loading... |
| 367 compiler.scanner.scan(unit); | 367 compiler.scanner.scan(unit); |
| 368 if (unit.partTag == null) { | 368 if (unit.partTag == null) { |
| 369 bool wasDiagnosticEmitted = false; | 369 bool wasDiagnosticEmitted = false; |
| 370 compiler.withCurrentElement(library, () { | 370 compiler.withCurrentElement(library, () { |
| 371 wasDiagnosticEmitted = | 371 wasDiagnosticEmitted = |
| 372 compiler.onDeprecatedFeature(part, 'missing part-of tag'); | 372 compiler.onDeprecatedFeature(part, 'missing part-of tag'); |
| 373 }); | 373 }); |
| 374 if (wasDiagnosticEmitted) { | 374 if (wasDiagnosticEmitted) { |
| 375 compiler.reportMessage( | 375 compiler.reportMessage( |
| 376 compiler.spanFromElement(unit), | 376 compiler.spanFromElement(unit), |
| 377 MessageKind.MISSING_PART_OF_TAG.error([]), | 377 MessageKind.MISSING_PART_OF_TAG.error(), |
| 378 api.Diagnostic.INFO); | 378 api.Diagnostic.INFO); |
| 379 } | 379 } |
| 380 } | 380 } |
| 381 }); | 381 }); |
| 382 } | 382 } |
| 383 | 383 |
| 384 /** | 384 /** |
| 385 * Handle an import/export tag by loading the referenced library and | 385 * Handle an import/export tag by loading the referenced library and |
| 386 * registering its dependency in [handler] for the computation of the import/ | 386 * registering its dependency in [handler] for the computation of the import/ |
| 387 * export scope. | 387 * export scope. |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 /** | 669 /** |
| 670 * Adds [element] to the export scope for this node. If the [element] name | 670 * Adds [element] to the export scope for this node. If the [element] name |
| 671 * is a duplicate, an error element is inserted into the export scope. | 671 * is a duplicate, an error element is inserted into the export scope. |
| 672 */ | 672 */ |
| 673 Element addElementToExportScope(Compiler compiler, Element element) { | 673 Element addElementToExportScope(Compiler compiler, Element element) { |
| 674 SourceString name = element.name; | 674 SourceString name = element.name; |
| 675 Element existingElement = exportScope[name]; | 675 Element existingElement = exportScope[name]; |
| 676 if (existingElement != null) { | 676 if (existingElement != null) { |
| 677 if (existingElement.isErroneous()) { | 677 if (existingElement.isErroneous()) { |
| 678 compiler.reportMessage(compiler.spanFromElement(element), | 678 compiler.reportMessage(compiler.spanFromElement(element), |
| 679 MessageKind.DUPLICATE_EXPORT.error([name]), api.Diagnostic.ERROR); | 679 MessageKind.DUPLICATE_EXPORT.error({'name': name}), |
| 680 api.Diagnostic.ERROR); |
| 680 element = existingElement; | 681 element = existingElement; |
| 681 } else if (existingElement.getLibrary() != library) { | 682 } else if (existingElement.getLibrary() != library) { |
| 682 // Declared elements hide exported elements. | 683 // Declared elements hide exported elements. |
| 683 compiler.reportMessage(compiler.spanFromElement(existingElement), | 684 compiler.reportMessage(compiler.spanFromElement(existingElement), |
| 684 MessageKind.DUPLICATE_EXPORT.error([name]), api.Diagnostic.ERROR); | 685 MessageKind.DUPLICATE_EXPORT.error({'name': name}), |
| 686 api.Diagnostic.ERROR); |
| 685 compiler.reportMessage(compiler.spanFromElement(element), | 687 compiler.reportMessage(compiler.spanFromElement(element), |
| 686 MessageKind.DUPLICATE_EXPORT.error([name]), api.Diagnostic.ERROR); | 688 MessageKind.DUPLICATE_EXPORT.error({'name': name}), |
| 689 api.Diagnostic.ERROR); |
| 687 element = exportScope[name] = new ErroneousElementX( | 690 element = exportScope[name] = new ErroneousElementX( |
| 688 MessageKind.DUPLICATE_EXPORT, [name], name, library); | 691 MessageKind.DUPLICATE_EXPORT, {'name': name}, name, library); |
| 689 } | 692 } |
| 690 } else { | 693 } else { |
| 691 exportScope[name] = element; | 694 exportScope[name] = element; |
| 692 } | 695 } |
| 693 return element; | 696 return element; |
| 694 } | 697 } |
| 695 | 698 |
| 696 /** | 699 /** |
| 697 * Propagates the exported [element] to all library nodes that depend upon | 700 * Propagates the exported [element] to all library nodes that depend upon |
| 698 * this node. If the propagation updated any pending exports, [:true:] is | 701 * this node. If the propagation updated any pending exports, [:true:] is |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 } | 831 } |
| 829 | 832 |
| 830 /** | 833 /** |
| 831 * Registers all top-level entities of [library] as starting point for the | 834 * Registers all top-level entities of [library] as starting point for the |
| 832 * fixed-point computation of the import/export scopes. | 835 * fixed-point computation of the import/export scopes. |
| 833 */ | 836 */ |
| 834 void registerLibraryExports(LibraryElement library) { | 837 void registerLibraryExports(LibraryElement library) { |
| 835 nodeMap[library].registerInitialExports(); | 838 nodeMap[library].registerInitialExports(); |
| 836 } | 839 } |
| 837 } | 840 } |
| OLD | NEW |