OLD | NEW |
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 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 Set<String> usedImportNames = new Set<String>(); | 525 Set<String> usedImportNames = new Set<String>(); |
526 | 526 |
527 // Finds the first argument to the [DeferredLibrary] annotation | 527 // Finds the first argument to the [DeferredLibrary] annotation |
528 void computeImportDeferName(Import import) { | 528 void computeImportDeferName(Import import) { |
529 String result; | 529 String result; |
530 if (import == _fakeMainImport) { | 530 if (import == _fakeMainImport) { |
531 result = "main"; | 531 result = "main"; |
532 } else if (import.isDeferred) { | 532 } else if (import.isDeferred) { |
533 result = import.prefix.toString(); | 533 result = import.prefix.toString(); |
534 } else { | 534 } else { |
535 Link<MetadataAnnotation> metadatas = import.metadata; | 535 List<MetadataAnnotation> metadatas = import.metadata; |
536 assert(metadatas != null); | 536 assert(metadatas != null); |
537 for (MetadataAnnotation metadata in metadatas) { | 537 for (MetadataAnnotation metadata in metadatas) { |
538 metadata.ensureResolved(compiler); | 538 metadata.ensureResolved(compiler); |
539 ConstantValue value = | 539 ConstantValue value = |
540 compiler.constants.getConstantValue(metadata.constant); | 540 compiler.constants.getConstantValue(metadata.constant); |
541 Element element = value.getType(compiler.coreTypes).element; | 541 Element element = value.getType(compiler.coreTypes).element; |
542 if (element == deferredLibraryClass) { | 542 if (element == deferredLibraryClass) { |
543 ConstructedConstantValue constant = value; | 543 ConstructedConstantValue constant = value; |
544 StringConstantValue s = constant.fields.values.single; | 544 StringConstantValue s = constant.fields.values.single; |
545 result = s.primitiveValue.slowToString(); | 545 result = s.primitiveValue.slowToString(); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 compiler.withCurrentElement(library, () { | 716 compiler.withCurrentElement(library, () { |
717 prefixDeferredImport.clear(); | 717 prefixDeferredImport.clear(); |
718 usedPrefixes.clear(); | 718 usedPrefixes.clear(); |
719 // TODO(sigurdm): Make helper getLibraryImportTags when tags is a List | 719 // TODO(sigurdm): Make helper getLibraryImportTags when tags is a List |
720 // instead of a Link. | 720 // instead of a Link. |
721 for (LibraryTag tag in library.tags) { | 721 for (LibraryTag tag in library.tags) { |
722 if (tag is! Import) continue; | 722 if (tag is! Import) continue; |
723 Import import = tag; | 723 Import import = tag; |
724 | 724 |
725 /// Give an error if the old annotation-based syntax has been used. | 725 /// Give an error if the old annotation-based syntax has been used. |
726 Link<MetadataAnnotation> metadataList = import.metadata; | 726 List<MetadataAnnotation> metadataList = import.metadata; |
727 if (metadataList != null) { | 727 if (metadataList != null) { |
728 for (MetadataAnnotation metadata in metadataList) { | 728 for (MetadataAnnotation metadata in metadataList) { |
729 metadata.ensureResolved(compiler); | 729 metadata.ensureResolved(compiler); |
730 ConstantValue value = | 730 ConstantValue value = |
731 compiler.constants.getConstantValue(metadata.constant); | 731 compiler.constants.getConstantValue(metadata.constant); |
732 Element element = value.getType(compiler.coreTypes).element; | 732 Element element = value.getType(compiler.coreTypes).element; |
733 if (element == deferredLibraryClass) { | 733 if (element == deferredLibraryClass) { |
734 compiler.reportError( | 734 compiler.reportError( |
735 import, MessageKind.DEFERRED_OLD_SYNTAX); | 735 import, MessageKind.DEFERRED_OLD_SYNTAX); |
736 } | 736 } |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 _importingLibrary = importingLibrary; | 884 _importingLibrary = importingLibrary; |
885 | 885 |
886 String get importingLibraryName { | 886 String get importingLibraryName { |
887 String libraryName = _importingLibrary.getLibraryName(); | 887 String libraryName = _importingLibrary.getLibraryName(); |
888 return libraryName == "" | 888 return libraryName == "" |
889 ? "<unnamed>" | 889 ? "<unnamed>" |
890 : libraryName; | 890 : libraryName; |
891 } | 891 } |
892 | 892 |
893 } | 893 } |
OLD | NEW |