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

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

Issue 10689038: Revert "First step towards having patch files for generic libraries." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 | « lib/compiler/implementation/apiimpl.dart ('k') | 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..5fa27f9cb26bb7146a299d4a3f84346da284928b 100644
--- a/lib/compiler/implementation/compiler.dart
+++ b/lib/compiler/implementation/compiler.dart
@@ -507,76 +507,8 @@ class Compiler implements DiagnosticListener {
assertMethod = coreLibrary.find(const SourceString('assert'));
initializeSpecialClasses();
-
- patchDartLibrary(coreLibrary, 'core');
- patchDartLibrary(coreImplLibrary, 'coreimpl');
- }
-
- void patchDartLibrary(LibraryElement library, String dartLibraryPath) {
- if (library.isPatched) return;
- Uri patchUri = resolvePatchUri(dartLibraryPath);
- if (patchUri !== null) {
- // TODO(lrn): Use a different parser to allow for "patch" annotations.
- // For now just assume everything in the patch library is a patch
- // function.
- LibraryElement patchLibrary = scanner.loadLibrary(patchUri, null);
- applyLibraryPatch(library, patchLibrary);
- }
- }
-
- void applyLibraryPatch(LibraryElement library, LibraryElement patch) {
- Link<Element> patches = patch.topLevelElements;
- while (!patches.isEmpty()) {
- Element patchElement = patches.head;
- Element originalElement = library.elements[patchElement.name];
- if (originalElement !== null) {
- // Assume that we are patching if the original exists.
- if (originalElement is! FunctionElement) {
- // TODO(lrn): Handle class declarations too.
- internalError("Can only patch functions", element: originalElement);
- }
- // TODO(lrn): Abort if the original isn't marked external, when
- // that is added to the language.
- if (patchElement is! FunctionElement ||
- !patchSignatureMatches(originalElement, patchElement)) {
- internalError("Can only patch functions with matching signatures",
- element: originalElement);
- }
- applyFunctionPatch(originalElement, patchElement);
- } else {
- // TODO(lrn): Allow adding private elements to the original library.
- }
- patches = patches.tail;
- }
- library.patch = patch;
}
- bool patchSignatureMatches(FunctionElement original, FunctionElement patch) {
- // TODO(lrn): Check that patches actually match the signature of
- // the function it's patching.
- return true;
- }
-
- void applyFunctionPatch(FunctionElement element,
- FunctionElement patchElement) {
- // Don't just assign the patch field. This also updates the cachedNode.
- if (element.isPatched) {
- internalError("Trying to patch a function more than once.",
- element: element);
- }
- if (element.cachedNode !== null) {
- internalError("Trying to patch an already compiled function.",
- element: element);
- }
- element.setPatch(patchElement);
- }
-
- /**
- * Get an [Uri] pointing to a patch for the dart: library with
- * the given path. Returns null if there is no patch.
- */
- abstract Uri resolvePatchUri(String dartLibraryPath);
-
/** Define the JS helper functions in the given library. */
void addForeignFunctions(LibraryElement library) {
library.define(new ForeignElement(
« no previous file with comments | « lib/compiler/implementation/apiimpl.dart ('k') | lib/compiler/implementation/elements/elements.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698