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

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

Issue 717103004: Revert "Emit warning on import of dart:mirrors." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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
OLDNEW
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.library_loader; 5 library dart2js.library_loader;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart2jslib.dart' 8 import 'dart2jslib.dart'
9 show Compiler, 9 show Compiler,
10 CompilerTask, 10 CompilerTask,
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 bool exclude(Element element) => excludedNames.contains(element.name); 242 bool exclude(Element element) => excludedNames.contains(element.name);
243 } 243 }
244 244
245 /** 245 /**
246 * Implementation class for [LibraryLoader]. The distinction between 246 * Implementation class for [LibraryLoader]. The distinction between
247 * [LibraryLoader] and [LibraryLoaderTask] is made to hide internal members from 247 * [LibraryLoader] and [LibraryLoaderTask] is made to hide internal members from
248 * the [LibraryLoader] interface. 248 * the [LibraryLoader] interface.
249 */ 249 */
250 class _LibraryLoaderTask extends CompilerTask implements LibraryLoaderTask { 250 class _LibraryLoaderTask extends CompilerTask implements LibraryLoaderTask {
251 _LibraryLoaderTask(Compiler compiler) : super(compiler); 251 _LibraryLoaderTask(Compiler compiler) : super(compiler);
252
253 String get name => 'LibraryLoader'; 252 String get name => 'LibraryLoader';
254 253
255 final Map<Uri, LibraryElement> libraryCanonicalUriMap = 254 final Map<Uri, LibraryElement> libraryCanonicalUriMap =
256 new Map<Uri, LibraryElement>(); 255 new Map<Uri, LibraryElement>();
257 final Map<Uri, LibraryElement> libraryResourceUriMap = 256 final Map<Uri, LibraryElement> libraryResourceUriMap =
258 new Map<Uri, LibraryElement>(); 257 new Map<Uri, LibraryElement>();
259 final Map<String, LibraryElement> libraryNames = 258 final Map<String, LibraryElement> libraryNames =
260 new Map<String, LibraryElement>(); 259 new Map<String, LibraryElement>();
261 260
262 LibraryDependencyHandler currentHandler; 261 LibraryDependencyHandler currentHandler;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 return measure(() { 335 return measure(() {
337 assert(currentHandler == null); 336 assert(currentHandler == null);
338 // TODO(johnniwinther): Ensure that currentHandler correctly encloses the 337 // TODO(johnniwinther): Ensure that currentHandler correctly encloses the
339 // loading of a library cluster. 338 // loading of a library cluster.
340 currentHandler = new LibraryDependencyHandler(this); 339 currentHandler = new LibraryDependencyHandler(this);
341 return createLibrary(currentHandler, null, resolvedUri) 340 return createLibrary(currentHandler, null, resolvedUri)
342 .then((LibraryElement library) { 341 .then((LibraryElement library) {
343 return compiler.withCurrentElement(library, () { 342 return compiler.withCurrentElement(library, () {
344 return measure(() { 343 return measure(() {
345 currentHandler.computeExports(); 344 currentHandler.computeExports();
346 LoadedLibraries loadedLibraries = 345 Map<Uri, LibraryElement> loadedLibraries = <Uri, LibraryElement>{};
347 new _LoadedLibraries(library, currentHandler.nodeMap); 346 currentHandler.loadedLibraries.forEach(
347 (LibraryElement loadedLibrary) {
348 loadedLibraries[loadedLibrary.canonicalUri] = loadedLibrary;
349 });
348 currentHandler = null; 350 currentHandler = null;
349 return compiler.onLibrariesLoaded(loadedLibraries) 351 return compiler.onLibrariesLoaded(loadedLibraries)
350 .then((_) => library); 352 .then((_) => library);
351 }); 353 });
352 }); 354 });
353 }); 355 });
354 }); 356 });
355 } 357 }
356 358
357 /** 359 /**
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 * fixed-point computation of the import/export scopes. 1025 * fixed-point computation of the import/export scopes.
1024 */ 1026 */
1025 void registerLibraryExports(LibraryElement library) { 1027 void registerLibraryExports(LibraryElement library) {
1026 nodeMap[library].registerInitialExports(); 1028 nodeMap[library].registerInitialExports();
1027 } 1029 }
1028 1030
1029 Future processLibraryTags(LibraryElement library) { 1031 Future processLibraryTags(LibraryElement library) {
1030 return task.processLibraryTags(this, library); 1032 return task.processLibraryTags(this, library);
1031 } 1033 }
1032 } 1034 }
1033
1034 /// Information on the bulk of newly loaded libraries through a call to
1035 /// [LibraryLoader.loadLibrary].
1036 abstract class LoadedLibraries {
1037 /// The uri passed to [LibraryLoader.loadLibrary].
1038 Uri get rootUri;
1039
1040 /// Returns `true` if a library with canonical [uri] was loaded in this bulk.
1041 bool containsLibrary(Uri uri);
1042
1043 /// Returns the library with canonical [uri] that was loaded in this bulk.
1044 LibraryElement getLibrary(Uri uri);
1045
1046 /// Applies all libraries in this bulk to [f].
1047 void forEachLibrary(f(LibraryElement library));
1048
1049 /// Applies all library imports in this bulk to [f].
1050 ///
1051 /// The argument [importChainReversed] to [f] contains the chain of imports
1052 /// uris that lead to importing [library] starting in the canonical uri for
1053 /// [library] and ending in [rootUri].
1054 ///
1055 /// [f] is called once for each chain of imports leading to [library].
1056 void forEachImportChain(f(LibraryElement library,
1057 Link<Uri> importChainReversed));
1058 }
1059
1060 class _LoadedLibraries implements LoadedLibraries {
1061 final LibraryElement rootLibrary;
1062 final Map<Uri, LibraryElement> loadedLibraries = <Uri, LibraryElement>{};
1063 final Map<LibraryElement, LibraryDependencyNode> nodeMap;
1064
1065 _LoadedLibraries(this.rootLibrary, this.nodeMap) {
1066 nodeMap.keys.forEach((LibraryElement loadedLibrary) {
1067 loadedLibraries[loadedLibrary.canonicalUri] = loadedLibrary;
1068 });
1069 }
1070
1071 Uri get rootUri => rootLibrary.canonicalUri;
1072
1073 bool containsLibrary(Uri uri) => loadedLibraries.containsKey(uri);
1074
1075 LibraryElement getLibrary(Uri uri) => loadedLibraries[uri];
1076
1077 void forEachLibrary(f(LibraryElement library)) => nodeMap.keys.forEach(f);
1078
1079 void forEachImportChain(f(LibraryElement library, Link<Uri> importChain)) {
1080 _processImports(rootLibrary, const Link<Uri>(), f);
1081 }
1082
1083 void _processImports(LibraryElement library,
1084 Link<Uri> uris,
1085 f(LibraryElement library, Link<Uri> importChain)) {
1086 Uri uri = library.canonicalUri;
1087 if (uris.contains(uri)) {
1088 // Cyclic import.
1089 return;
1090 }
1091 uris = uris.prepend(uri);
1092 f(library, uris);
1093 LibraryDependencyNode node = nodeMap[library];
1094 // TODO(johnniwinther): Reversing the imports every lookup.
1095 for (ImportLink import in node.imports.reverse()) {
1096 _processImports(import.importedLibrary, uris, f);
1097 }
1098 }
1099 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/js_backend.dart ('k') | pkg/compiler/lib/src/util/uri_extras.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698