Chromium Code Reviews| Index: pkg/compiler/lib/src/library_loader.dart |
| diff --git a/pkg/compiler/lib/src/library_loader.dart b/pkg/compiler/lib/src/library_loader.dart |
| index 9919cee4c203dbe5fd6988af572494e34bfd513b..7c3c701942381e7c6b12bcdfe1f1703891f7793c 100644 |
| --- a/pkg/compiler/lib/src/library_loader.dart |
| +++ b/pkg/compiler/lib/src/library_loader.dart |
| @@ -155,6 +155,13 @@ abstract class LibraryLoaderTask implements CompilerTask { |
| /// Asynchronous version of [reset]. |
| Future resetAsync(Future<bool> reuseLibrary(LibraryElement library)); |
| + |
| + /// Similar to [resetAsync] but [reuseLibrary] maps all libraries to a list |
| + /// of libraries that can be reused. |
| + Future<Null> resetLibraries( |
| + Future<Iterable<LibraryElement>> reuseLibraries( |
|
Johnni Winther
2015/11/19 10:04:31
Maybe typedef this to make it more readable.
ahe
2015/11/19 11:20:56
I find typedefs less readable, but if you prefer a
Johnni Winther
2015/11/19 11:25:37
In this case where the signature is too long, I do
ahe
2015/11/19 11:33:13
OK. Calling it *Function helps a bit.
ahe
2016/01/08 10:25:23
Done.
|
| + Iterable<LibraryElement> libraries)); |
| + |
| } |
| /// Handle for creating synthesized/patch libraries during library loading. |
| @@ -324,12 +331,32 @@ class _LibraryLoaderTask extends CompilerTask implements LibraryLoaderTask { |
| () => libraryCanonicalUriMap.values.map(wrapper).toList()); |
| return Future.wait(reusedLibrariesFuture).then( |
| - (List<LibraryElement> reusedLibraries) { |
| + (Iterable<LibraryElement> reusedLibraries) { |
| resetImplementation(reusedLibraries.where((e) => e != null)); |
| }); |
| }); |
| } |
| + Future<Null> resetLibraries( |
| + Future<Iterable<LibraryElement>> reuseLibraries( |
| + Iterable<LibraryElement> libraries)) { |
| + assert(currentHandler == null); |
| + return compiler.reuseLibraryTask.measure(() { |
| + return new Future<Iterable<LibraryElement>>(() { |
| + // Wrap in Future to shield against errors in user code. |
| + return reuseLibraries(libraryCanonicalUriMap.values); |
| + }).catchError((exception, StackTrace trace) { |
| + compiler.diagnoseCrashInUserCode( |
| + 'Uncaught exception in reuseLibraries', exception, trace); |
| + throw exception; // Async rethrow. |
| + }).then((Iterable<LibraryElement> reusedLibraries) { |
| + measure(() { |
| + resetImplementation(reusedLibraries); |
| + }); |
| + }); |
| + }); |
| + } |
| + |
| /// Insert [library] in the internal maps. Used for compiler reuse. |
| void mapLibrary(LibraryElement library) { |
| libraryCanonicalUriMap[library.canonicalUri] = library; |