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

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

Issue 1332223005: Handle deferred import without prefix. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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 | « no previous file | no next file » | 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/backend_api.dart' show 7 import 'common/backend_api.dart' show
8 Backend; 8 Backend;
9 import 'common/tasks.dart' show 9 import 'common/tasks.dart' show
10 CompilerTask; 10 CompilerTask;
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 /// A node in the deferred import graph defined by a deferred import directive. 902 /// A node in the deferred import graph defined by a deferred import directive.
903 class _DeclaredDeferredImport implements _DeferredImport { 903 class _DeclaredDeferredImport implements _DeferredImport {
904 final ImportElement declaration; 904 final ImportElement declaration;
905 905
906 _DeclaredDeferredImport(this.declaration); 906 _DeclaredDeferredImport(this.declaration);
907 907
908 @override 908 @override
909 String computeImportDeferName(Compiler compiler) { 909 String computeImportDeferName(Compiler compiler) {
910 String result; 910 String result;
911 if (declaration.isDeferred) { 911 if (declaration.isDeferred) {
912 result = declaration.prefix.name; 912 if (declaration.prefix != null) {
913 result = declaration.prefix.name;
914 } else {
915 // This happens when the deferred import isn't declared with a prefix.
916 assert(compiler.compilationFailed);
917 result = '';
918 }
913 } else { 919 } else {
914 // Finds the first argument to the [DeferredLibrary] annotation 920 // Finds the first argument to the [DeferredLibrary] annotation
915 List<MetadataAnnotation> metadatas = declaration.metadata; 921 List<MetadataAnnotation> metadatas = declaration.metadata;
916 assert(metadatas != null); 922 assert(metadatas != null);
917 for (MetadataAnnotation metadata in metadatas) { 923 for (MetadataAnnotation metadata in metadatas) {
918 metadata.ensureResolved(compiler); 924 metadata.ensureResolved(compiler);
919 ConstantValue value = 925 ConstantValue value =
920 compiler.constants.getConstantValue(metadata.constant); 926 compiler.constants.getConstantValue(metadata.constant);
921 Element element = value.getType(compiler.coreTypes).element; 927 Element element = value.getType(compiler.coreTypes).element;
922 if (element == compiler.deferredLibraryClass) { 928 if (element == compiler.deferredLibraryClass) {
923 ConstructedConstantValue constant = value; 929 ConstructedConstantValue constant = value;
924 StringConstantValue s = constant.fields.values.single; 930 StringConstantValue s = constant.fields.values.single;
925 result = s.primitiveValue.slowToString(); 931 result = s.primitiveValue.slowToString();
926 break; 932 break;
927 } 933 }
928 } 934 }
929 } 935 }
930 assert(result != null); 936 assert(result != null);
931 return result; 937 return result;
932 } 938 }
933 939
934 bool operator ==(other) { 940 bool operator ==(other) {
935 if (other is! _DeclaredDeferredImport) return false; 941 if (other is! _DeclaredDeferredImport) return false;
936 return declaration == other.declaration; 942 return declaration == other.declaration;
937 } 943 }
938 944
939 int get hashCode => declaration.hashCode * 17; 945 int get hashCode => declaration.hashCode * 17;
940 } 946 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698