Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/patch_parser.dart |
| diff --git a/sdk/lib/_internal/compiler/implementation/patch_parser.dart b/sdk/lib/_internal/compiler/implementation/patch_parser.dart |
| index 02c4ecc1ffba2b0dfee46119129c3962fba67880..f0129f421168f137c0c82b8b4f30151ac6f8d52e 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/patch_parser.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/patch_parser.dart |
| @@ -114,6 +114,8 @@ |
| library patchparser; |
| +import 'dart:async'; |
| + |
| import "tree/tree.dart" as tree; |
| import "dart2jslib.dart" as leg; // CompilerTask, Compiler. |
| import "apiimpl.dart"; |
| @@ -132,28 +134,30 @@ class PatchParserTask extends leg.CompilerTask { |
| * injections to the library, and returns a list of class |
| * patches. |
| */ |
| - void patchLibrary(leg.LibraryDependencyHandler handler, |
| + Future patchLibrary(leg.LibraryDependencyHandler handler, |
| Uri patchUri, LibraryElement originLibrary) { |
| - |
| - leg.Script script = compiler.readScript(patchUri, null); |
| - var patchLibrary = new LibraryElementX(script, null, originLibrary); |
| - compiler.withCurrentElement(patchLibrary, () { |
| - handler.registerNewLibrary(patchLibrary); |
| - LinkBuilder<tree.LibraryTag> imports = new LinkBuilder<tree.LibraryTag>(); |
| - compiler.withCurrentElement(patchLibrary.entryCompilationUnit, () { |
| - // This patches the elements of the patch library into [library]. |
| - // Injected elements are added directly under the compilation unit. |
| - // Patch elements are stored on the patched functions or classes. |
| - scanLibraryElements(patchLibrary.entryCompilationUnit, imports); |
| + return compiler.readScript(patchUri, null).then((script) { |
| + var patchLibrary = new LibraryElementX(script, null, originLibrary); |
| + compiler.withCurrentElement(patchLibrary, () { |
| + handler.registerNewLibrary(patchLibrary); |
| + LinkBuilder<tree.LibraryTag> imports = new LinkBuilder<tree.LibraryTag>(); |
|
Bob Nystrom
2013/06/26 01:03:24
I'll fix this.
|
| + compiler.withCurrentElement(patchLibrary.entryCompilationUnit, () { |
| + // This patches the elements of the patch library into [library]. |
| + // Injected elements are added directly under the compilation unit. |
| + // Patch elements are stored on the patched functions or classes. |
| + scanLibraryElements(patchLibrary.entryCompilationUnit, imports); |
| + }); |
| + // After scanning declarations, we handle the import tags in the patch. |
| + // TODO(lrn): These imports end up in the original library and are in |
| + // scope for the original methods too. This should be fixed. |
| + compiler.importHelperLibrary(originLibrary); |
| + return Future.forEach(imports.toLink(), (tag) { |
| + return compiler.withCurrentElement(patchLibrary, () { |
| + return compiler.libraryLoader.registerLibraryFromTag( |
| + handler, patchLibrary, tag); |
| + }); |
| + }); |
| }); |
| - // After scanning declarations, we handle the import tags in the patch. |
| - // TODO(lrn): These imports end up in the original library and are in |
| - // scope for the original methods too. This should be fixed. |
| - compiler.importHelperLibrary(originLibrary); |
| - for (tree.LibraryTag tag in imports.toLink()) { |
| - compiler.libraryLoader.registerLibraryFromTag( |
| - handler, patchLibrary, tag); |
| - } |
| }); |
| } |