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

Unified Diff: lib/compiler/implementation/compiler.dart

Issue 10694067: Make patch file import declarations apply to the patched library too. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comment. Fix typo. Created 8 years, 6 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/compiler/implementation/elements/elements.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/compiler.dart
diff --git a/lib/compiler/implementation/compiler.dart b/lib/compiler/implementation/compiler.dart
index c0f70bac3a7f6ac3fc4c11034453cb956806460c..3665544da58429146181abb7611439757bcfd848 100644
--- a/lib/compiler/implementation/compiler.dart
+++ b/lib/compiler/implementation/compiler.dart
@@ -269,7 +269,11 @@ class Compiler implements DiagnosticListener {
// do not have enough stack space.
throw;
} catch (var ex) {
- unhandledExceptionOnElement(element);
+ try {
+ unhandledExceptionOnElement(element);
+ } catch (var doubleFault) {
+ // Ignoring exceptions in exception handling.
+ }
throw;
} finally {
_currentElement = old;
@@ -525,6 +529,10 @@ class Compiler implements DiagnosticListener {
}
void applyLibraryPatch(LibraryElement library, LibraryElement patch) {
+ // We allow foreign functions in patched libraries.
+ addForeignFunctions(library); // Is safe even if already added.
+
+ // Copy/patch top-level elements.
Link<Element> patches = patch.topLevelElements;
while (!patches.isEmpty()) {
Element patchElement = patches.head;
@@ -548,7 +556,29 @@ class Compiler implements DiagnosticListener {
}
patches = patches.tail;
}
+
+ // Copy imports.
+ Map<String, LibraryElement> delayedPatches = <LibraryElement>{};
+ Uri base = patch.script.uri;
+ for (ScriptTag tag in patch.tags.reverse()) {
+ if (tag.isImport()) {
+ StringNode argument = tag.argument;
+ Uri resolved = base.resolve(argument.dartString.slowToString());
+ LibraryElement importedLibrary =
+ scanner.loadLibrary(resolved, argument);
+ scanner.importLibrary(library, importedLibrary, tag, patch);
+ if (resolved.scheme == "dart") {
+ delayedPatches[resolved.path] = importedLibrary;
+ }
+ }
+ }
+ // Mark library as already patched.
library.patch = patch;
+ // We patch imported libraries after marking the current library as patched,
+ // to avoid problems with cyclic dependencies.
+ delayedPatches.forEach((String path, LibraryElement importedLibrary) {
+ patchDartLibrary(importedLibrary, path);
+ });
}
bool patchSignatureMatches(FunctionElement original, FunctionElement patch) {
« no previous file with comments | « no previous file | lib/compiler/implementation/elements/elements.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698