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

Side by Side Diff: pkg/compiler/lib/src/deferred_load.dart

Issue 2936233003: Remove Compiler.mainApp and Compiler.mainFunction (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/dump_info.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 'common/tasks.dart' show CompilerTask; 7 import 'common/tasks.dart' show CompilerTask;
8 import 'common.dart'; 8 import 'common.dart';
9 import 'compiler.dart' show Compiler; 9 import 'compiler.dart' show Compiler;
10 import 'constants/expressions.dart' show ConstantExpression; 10 import 'constants/expressions.dart' show ConstantExpression;
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 }); 784 });
785 785
786 // Generate a unique name for each OutputUnit. 786 // Generate a unique name for each OutputUnit.
787 _assignNamesToOutputUnits(allOutputUnits); 787 _assignNamesToOutputUnits(allOutputUnits);
788 })); 788 }));
789 // Notify the impact strategy impacts are no longer needed for deferred 789 // Notify the impact strategy impacts are no longer needed for deferred
790 // load. 790 // load.
791 compiler.impactStrategy.onImpactUsed(IMPACT_USE); 791 compiler.impactStrategy.onImpactUsed(IMPACT_USE);
792 } 792 }
793 793
794 void beforeResolution(Compiler compiler) { 794 void beforeResolution(LibraryEntity mainLibrary) {
795 if (compiler.mainApp == null) return; 795 if (mainLibrary == null) return;
796 // TODO(johnniwinther): Support deferred load for kernel based elements. 796 // TODO(johnniwinther): Support deferred load for kernel based elements.
797 if (compiler.options.loadFromDill) return; 797 if (compiler.options.loadFromDill) return;
798 _allDeferredImports[_fakeMainImport] = compiler.mainApp; 798 _allDeferredImports[_fakeMainImport] = mainLibrary;
799 var lastDeferred; 799 var lastDeferred;
800 // When detecting duplicate prefixes of deferred libraries there are 4 800 // When detecting duplicate prefixes of deferred libraries there are 4
801 // cases of duplicate prefixes: 801 // cases of duplicate prefixes:
802 // 1. 802 // 1.
803 // import "lib.dart" deferred as a; 803 // import "lib.dart" deferred as a;
804 // import "lib2.dart" deferred as a; 804 // import "lib2.dart" deferred as a;
805 // 2. 805 // 2.
806 // import "lib.dart" deferred as a; 806 // import "lib.dart" deferred as a;
807 // import "lib2.dart" as a; 807 // import "lib2.dart" as a;
808 // 3. 808 // 3.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 if (import.isDeferred) { 848 if (import.isDeferred) {
849 _DeferredImport key = new _DeclaredDeferredImport(import); 849 _DeferredImport key = new _DeclaredDeferredImport(import);
850 LibraryElement importedLibrary = import.importedLibrary; 850 LibraryElement importedLibrary = import.importedLibrary;
851 _allDeferredImports[key] = importedLibrary; 851 _allDeferredImports[key] = importedLibrary;
852 852
853 if (prefix == null) { 853 if (prefix == null) {
854 reporter.reportErrorMessage( 854 reporter.reportErrorMessage(
855 import, MessageKind.DEFERRED_LIBRARY_WITHOUT_PREFIX); 855 import, MessageKind.DEFERRED_LIBRARY_WITHOUT_PREFIX);
856 } else { 856 } else {
857 prefixDeferredImport[prefix] = import; 857 prefixDeferredImport[prefix] = import;
858 Uri mainLibraryUri = compiler.mainLibraryUri;
858 _deferredImportDescriptions[key] = 859 _deferredImportDescriptions[key] =
859 new ImportDescription(import, library, compiler); 860 new ImportDescription(import, library, mainLibraryUri);
860 } 861 }
861 isProgramSplit = true; 862 isProgramSplit = true;
862 lastDeferred = import; 863 lastDeferred = import;
863 } 864 }
864 if (prefix != null) { 865 if (prefix != null) {
865 if (previousDeferredImport != null || 866 if (previousDeferredImport != null ||
866 (import.isDeferred && usedPrefixes.contains(prefix))) { 867 (import.isDeferred && usedPrefixes.contains(prefix))) {
867 ImportElement failingImport = (previousDeferredImport != null) 868 ImportElement failingImport = (previousDeferredImport != null)
868 ? previousDeferredImport 869 ? previousDeferredImport
869 : import; 870 : import;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 1025
1025 class ImportDescription { 1026 class ImportDescription {
1026 /// Relative uri to the importing library. 1027 /// Relative uri to the importing library.
1027 final String importingUri; 1028 final String importingUri;
1028 1029
1029 /// The prefix this import is imported as. 1030 /// The prefix this import is imported as.
1030 final String prefix; 1031 final String prefix;
1031 final LibraryElement _importingLibrary; 1032 final LibraryElement _importingLibrary;
1032 1033
1033 ImportDescription( 1034 ImportDescription(
1034 ImportElement import, LibraryElement importingLibrary, Compiler compiler) 1035 ImportElement import, LibraryElement importingLibrary, Uri mainLibraryUri)
1035 : importingUri = uri_extras.relativize(compiler.mainApp.canonicalUri, 1036 : importingUri = uri_extras.relativize(
1036 importingLibrary.canonicalUri, false), 1037 mainLibraryUri, importingLibrary.canonicalUri, false),
1037 prefix = import.prefix.name, 1038 prefix = import.prefix.name,
1038 _importingLibrary = importingLibrary; 1039 _importingLibrary = importingLibrary;
1039 1040
1040 String get importingLibraryName { 1041 String get importingLibraryName {
1041 return _importingLibrary.hasLibraryName 1042 return _importingLibrary.hasLibraryName
1042 ? _importingLibrary.libraryName 1043 ? _importingLibrary.libraryName
1043 : "<unnamed>"; 1044 : "<unnamed>";
1044 } 1045 }
1045 } 1046 }
1046 1047
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 1102
1102 bool operator ==(other) { 1103 bool operator ==(other) {
1103 if (other is! _DeclaredDeferredImport) return false; 1104 if (other is! _DeclaredDeferredImport) return false;
1104 return declaration == other.declaration; 1105 return declaration == other.declaration;
1105 } 1106 }
1106 1107
1107 int get hashCode => declaration.hashCode * 17; 1108 int get hashCode => declaration.hashCode * 17;
1108 1109
1109 String toString() => '$declaration'; 1110 String toString() => '$declaration';
1110 } 1111 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/dump_info.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698