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

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

Issue 169703003: Add prefix constraints for deferred imports. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/warnings.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library deferred_load; 5 library deferred_load;
6 6
7 import 'dart2jslib.dart' show 7 import 'dart2jslib.dart' show
8 Compiler, 8 Compiler,
9 CompilerTask, 9 CompilerTask,
10 Constant, 10 Constant,
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 } 610 }
611 611
612 _assignNamesToOutputUnits(allOutputUnits); 612 _assignNamesToOutputUnits(allOutputUnits);
613 }); 613 });
614 } 614 }
615 615
616 void ensureMetadataResolved(Compiler compiler) { 616 void ensureMetadataResolved(Compiler compiler) {
617 _allDeferredImports[_fakeMainImport] = compiler.mainApp; 617 _allDeferredImports[_fakeMainImport] = compiler.mainApp;
618 bool deferredUsedFromMain = false; 618 bool deferredUsedFromMain = false;
619 var lastDeferred; 619 var lastDeferred;
620 Map<String, List<Import>> prefixImports = new Map<String, List<Import>>();
620 for (LibraryElement library in compiler.libraries.values) { 621 for (LibraryElement library in compiler.libraries.values) {
622 prefixImports.clear();
621 // TODO(sigurdm): Make helper getLibraryImportTags when tags is a List 623 // TODO(sigurdm): Make helper getLibraryImportTags when tags is a List
622 // instead of a Link. 624 // instead of a Link.
623 for (LibraryTag tag in library.tags) { 625 for (LibraryTag tag in library.tags) {
624 if (tag is! Import) continue; 626 if (tag is! Import) continue;
625 Import import = tag; 627 Import import = tag;
626 if (_isImportDeferred(import)) { 628 if (_isImportDeferred(import)) {
629 if (import.prefix == null) {
630 compiler.reportError(
631 import,
632 MessageKind.DEFERRED_LIBRARY_WITHOUT_PREFIX);
633 }
627 splitProgram = true; 634 splitProgram = true;
628 _allDeferredImports[tag] = library.getLibraryFromTag(tag); 635 _allDeferredImports[tag] = library.getLibraryFromTag(tag);
629 lastDeferred = import.metadata.first; 636 lastDeferred = import.metadata.first;
630 if (library == compiler.mainApp) { 637 if (library == compiler.mainApp) {
631 deferredUsedFromMain = true; 638 deferredUsedFromMain = true;
632 } 639 }
633 } 640 }
641 if (import.prefix != null) {
floitsch 2014/02/18 09:45:22 Add comment explaining why simpler approaches woul
642 prefixImports.putIfAbsent(import.prefix.toString(),
643 () => new List<Import>()).add(import);
644 }
645 }
646 for (String prefix in prefixImports.keys) {
647 List<Import> imports = prefixImports[prefix];
648 if (imports.length <= 1) continue;
649 for (Import import in imports) {
650 if (_isImportDeferred(import)) {
651 compiler.reportError(import,
652 MessageKind.DEFERRED_LIBRARY_DUPLICATE_PREFIX);
653 }
654 }
634 } 655 }
635 } 656 }
636 if (splitProgram && !deferredUsedFromMain) { 657 if (splitProgram && !deferredUsedFromMain) {
637 compiler.reportInfo( 658 compiler.reportInfo(
638 lastDeferred, 659 lastDeferred,
639 MessageKind.DEFERRED_LIBRARY_NOT_FROM_MAIN); 660 MessageKind.DEFERRED_LIBRARY_NOT_FROM_MAIN);
640 splitProgram = false; 661 splitProgram = false;
641 } 662 }
642 } 663 }
643 } 664 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/warnings.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698