| 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 library dart2js.compiler_base; | 5 library dart2js.compiler_base; |
| 6 | 6 |
| 7 import 'dart:async' show EventSink, Future; | 7 import 'dart:async' show EventSink, Future; |
| 8 | 8 |
| 9 import '../compiler_new.dart' as api; | 9 import '../compiler_new.dart' as api; |
| 10 import 'closure.dart' as closureMapping show ClosureTask; | 10 import 'closure.dart' as closureMapping show ClosureTask; |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 /// This method is called when all new libraries loaded through | 377 /// This method is called when all new libraries loaded through |
| 378 /// [LibraryLoader.loadLibrary] has been loaded and their imports/exports | 378 /// [LibraryLoader.loadLibrary] has been loaded and their imports/exports |
| 379 /// have been computed. | 379 /// have been computed. |
| 380 /// | 380 /// |
| 381 /// [loadedLibraries] contains the newly loaded libraries. | 381 /// [loadedLibraries] contains the newly loaded libraries. |
| 382 /// | 382 /// |
| 383 /// The method returns a [Future] allowing for the loading of additional | 383 /// The method returns a [Future] allowing for the loading of additional |
| 384 /// libraries. | 384 /// libraries. |
| 385 LoadedLibraries processLoadedLibraries(LoadedLibraries loadedLibraries) { | 385 LoadedLibraries processLoadedLibraries(LoadedLibraries loadedLibraries) { |
| 386 loadedLibraries.forEachLibrary((LibraryElement library) { | 386 loadedLibraries.forEachLibrary((LibraryElement library) { |
| 387 _commonElements.registerCommonLibraries(library); | |
| 388 backend.setAnnotations(library); | 387 backend.setAnnotations(library); |
| 389 }); | 388 }); |
| 390 | 389 |
| 391 for (Uri uri in resolvedUriTranslator.disallowedLibraryUris) { | 390 for (Uri uri in resolvedUriTranslator.disallowedLibraryUris) { |
| 392 if (loadedLibraries.containsLibrary(uri)) { | 391 if (loadedLibraries.containsLibrary(uri)) { |
| 393 Set<String> importChains = computeImportChainsFor(loadedLibraries, uri); | 392 Set<String> importChains = computeImportChainsFor(loadedLibraries, uri); |
| 394 reporter.reportInfo( | 393 reporter.reportInfo( |
| 395 NO_LOCATION_SPANNABLE, MessageKind.DISALLOWED_LIBRARY_IMPORT, { | 394 NO_LOCATION_SPANNABLE, MessageKind.DISALLOWED_LIBRARY_IMPORT, { |
| 396 'uri': uri, | 395 'uri': uri, |
| 397 'importChain': importChains | 396 'importChain': importChains |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 int warnings = 0; | 1086 int warnings = 0; |
| 1088 int hints = 0; | 1087 int hints = 0; |
| 1089 } | 1088 } |
| 1090 | 1089 |
| 1091 class _CompilerCommonElements extends CommonElementsMixin { | 1090 class _CompilerCommonElements extends CommonElementsMixin { |
| 1092 final Resolution resolution; | 1091 final Resolution resolution; |
| 1093 final DiagnosticReporter reporter; | 1092 final DiagnosticReporter reporter; |
| 1094 | 1093 |
| 1095 final ElementEnvironment environment; | 1094 final ElementEnvironment environment; |
| 1096 | 1095 |
| 1097 LibraryElement coreLibrary; | |
| 1098 LibraryElement asyncLibrary; | |
| 1099 LibraryElement mirrorsLibrary; | |
| 1100 LibraryElement typedDataLibrary; | |
| 1101 | |
| 1102 _CompilerCommonElements(this.environment, this.resolution, this.reporter); | 1096 _CompilerCommonElements(this.environment, this.resolution, this.reporter); |
| 1103 | 1097 |
| 1104 @override | 1098 @override |
| 1105 ResolutionDynamicType get dynamicType => const ResolutionDynamicType(); | 1099 ResolutionDynamicType get dynamicType => const ResolutionDynamicType(); |
| 1106 | 1100 |
| 1107 void registerCommonLibraries(LibraryElement library) { | 1101 LibraryEntity _coreLibrary; |
| 1108 Uri uri = library.canonicalUri; | 1102 LibraryEntity get coreLibrary => |
| 1109 if (uri == Uris.dart_core) { | 1103 _coreLibrary ??= environment.lookupLibrary(Uris.dart_core); |
| 1110 coreLibrary = library; | 1104 |
| 1111 } else if (uri == Uris.dart_async) { | 1105 LibraryEntity _typedDataLibrary; |
| 1112 asyncLibrary = library; | 1106 LibraryEntity get typedDataLibrary => _typedDataLibrary ??= |
| 1113 } else if (uri == Uris.dart__native_typed_data) { | 1107 environment.lookupLibrary(Uris.dart__native_typed_data); |
| 1114 typedDataLibrary = library; | 1108 |
| 1115 } else if (uri == Uris.dart_mirrors) { | 1109 LibraryEntity _mirrorsLibrary; |
| 1116 mirrorsLibrary = library; | 1110 LibraryEntity get mirrorsLibrary => |
| 1117 } | 1111 _mirrorsLibrary ??= environment.lookupLibrary(Uris.dart_mirrors); |
| 1118 } | 1112 |
| 1113 LibraryEntity _asyncLibrary; |
| 1114 LibraryEntity get asyncLibrary => |
| 1115 _asyncLibrary ??= environment.lookupLibrary(Uris.dart_async); |
| 1119 | 1116 |
| 1120 @override | 1117 @override |
| 1121 MemberElement findLibraryMember(LibraryElement library, String name, | 1118 MemberElement findLibraryMember(LibraryElement library, String name, |
| 1122 {bool setter: false, bool required: true}) { | 1119 {bool setter: false, bool required: true}) { |
| 1123 Element member = _findLibraryMember(library, name, required: required); | 1120 Element member = _findLibraryMember(library, name, required: required); |
| 1124 if (member != null && member.isAbstractField) { | 1121 if (member != null && member.isAbstractField) { |
| 1125 AbstractFieldElement abstractField = member; | 1122 AbstractFieldElement abstractField = member; |
| 1126 if (setter) { | 1123 if (setter) { |
| 1127 member = abstractField.setter; | 1124 member = abstractField.setter; |
| 1128 } else { | 1125 } else { |
| (...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2040 if (library != null && library.isSynthesized) { | 2037 if (library != null && library.isSynthesized) { |
| 2041 return null; | 2038 return null; |
| 2042 } | 2039 } |
| 2043 if (library == null && required) { | 2040 if (library == null && required) { |
| 2044 throw new SpannableAssertionFailure( | 2041 throw new SpannableAssertionFailure( |
| 2045 library, "The library '${uri}' was not found."); | 2042 library, "The library '${uri}' was not found."); |
| 2046 } | 2043 } |
| 2047 return library; | 2044 return library; |
| 2048 } | 2045 } |
| 2049 } | 2046 } |
| OLD | NEW |