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

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

Issue 10824347: Make top-level patch injections be compilation unit under library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Offline discussed changes. Created 8 years, 4 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 | « lib/compiler/implementation/apiimpl.dart ('k') | lib/compiler/implementation/diagnostic_listener.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 bf51eb7a1c4a8ee12d839c316677aecbf2256d27..789d80926f404cd8c4ce6a38ce444ba1a79b1163 100644
--- a/lib/compiler/implementation/compiler.dart
+++ b/lib/compiler/implementation/compiler.dart
@@ -358,51 +358,33 @@ class Compiler implements DiagnosticListener {
initializeSpecialClasses();
- patchDartLibrary(coreLibrary, 'core');
- patchDartLibrary(coreImplLibrary, 'coreimpl');
+ //patchDartLibrary(coreLibrary, 'core');
+ //patchDartLibrary(coreImplLibrary, 'coreimpl');
}
void patchDartLibrary(LibraryElement library, String dartLibraryPath) {
+ print("[Patching; $library ($dartLibraryPath)");
if (library.isPatched) return;
Uri patchUri = resolvePatchUri(dartLibraryPath);
if (patchUri !== null) {
- LibraryElement patchLibrary =
- patchParser.loadPatchLibrary(patchUri);
+ print("[... loading patch ...]");
+ patchParser.patchLibrary(patchUri, library);
// We allow foreign functions in patched libraries.
addForeignFunctions(library); // Is safe even if already added.
- applyLibraryPatch(library, patchLibrary);
+ // TODO(lrn): Make this lazy.
+ applyClassPatches(library);
}
}
- void applyLibraryPatch(LibraryElement original, LibraryElement patch) {
- Link<Element> patches = patch.localMembers;
- applyContainerPatch(original, patches);
-
- // Copy imports from patch to original library.
- Map<String, LibraryElement> delayedPatches = <LibraryElement>{};
- Uri patchBase = patch.uri;
- for (ScriptTag tag in patch.tags.reverse()) {
- if (tag.isImport()) {
- StringNode argument = tag.argument;
- Uri resolved = patchBase.resolve(argument.dartString.slowToString());
- LibraryElement importedLibrary =
- scanner.loadLibrary(resolved, argument);
- scanner.importLibrary(original, importedLibrary, tag,
- patch.entryCompilationUnit);
- if (resolved.scheme == "dart") {
- delayedPatches[resolved.path] = importedLibrary;
+ void applyClassPatches(LibraryElement library) {
+ for (Element element in library.localMembers) {
+ if (element.isClass()) {
+ ClassElement classElement = element;
+ if (classElement.isPatched) {
+ applyClassPatch(classElement, classElement.patch);
}
}
}
-
- // Mark library as already patched.
- original.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);
- });
}
void applyContainerPatch(ScopeContainerElement original,
@@ -571,7 +553,7 @@ class Compiler implements DiagnosticListener {
void runCompiler(Uri uri) {
scanBuiltinLibraries();
- mainApp = scanner.loadLibrary(uri, null);
+ mainApp = scanner.loadLibrary(uri, null, uri);
final Element main = mainApp.find(MAIN);
if (main === null) {
reportFatalError('Could not find $MAIN', mainApp);
« no previous file with comments | « lib/compiler/implementation/apiimpl.dart ('k') | lib/compiler/implementation/diagnostic_listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698