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

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

Issue 10830117: Port the remaining of dart:core to the unified corelib. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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
Index: lib/compiler/implementation/compiler.dart
diff --git a/lib/compiler/implementation/compiler.dart b/lib/compiler/implementation/compiler.dart
index ca6ca2ba8cb60374a28e6029a5089e9d50e33292..d0df099c5c53f9a4d48f057a4359492b864c4c42 100644
--- a/lib/compiler/implementation/compiler.dart
+++ b/lib/compiler/implementation/compiler.dart
@@ -571,7 +571,7 @@ class Compiler implements DiagnosticListener {
AbstractFieldElement originalField = originalElement;
if (patchField.getter !== null) {
if (originalField === null || originalField.getter === null) {
- original.addGetterOrSetter(clonePatch(patchField.getter),
+ original.addGetterOrSetter(clonePatch(patchField.getter, original),
originalField,
this);
if (originalField === null && patchField.setter !== null) {
@@ -584,7 +584,7 @@ class Compiler implements DiagnosticListener {
}
if (patchField.setter !== null) {
if (originalField === null || originalField.setter === null) {
- original.addGetterOrSetter(clonePatch(patchField.setter),
+ original.addGetterOrSetter(clonePatch(patchField.setter, original),
originalField,
this);
} else {
@@ -596,7 +596,7 @@ class Compiler implements DiagnosticListener {
internalError("Cannot patch non-existing member '"
"${patchElement.name.slowToString()}'.");
}
- original.addMember(clonePatch(patchElement), this);
+ original.addMember(clonePatch(patchElement, original), this);
} else {
patchMember(originalElement, patchElement);
}
@@ -610,7 +610,7 @@ class Compiler implements DiagnosticListener {
return !element.metadata.isEmpty();
}
- Element clonePatch(Element patchElement) {
+ Element clonePatch(Element patchElement, Element enclosing) {
// The original library does not have an element with the same name
// as the patch library element.
// In this case, the patch library element must not be marked as "patch",
@@ -619,9 +619,23 @@ class Compiler implements DiagnosticListener {
internalError("Cannot add non-private member '"
"${patchElement.name.slowToString()}' from patch.");
}
+ if (patchElement.isFunction()) {
+ var function = new FunctionElement.from(patchElement.name,
+ patchElement,
+ enclosing);
+ // Give the cloned function a patch reference, so it gets the correct
+ // compilation unit for reporting diagnostics.
+ function.patch = patchElement;
Mads Ager (google) 2012/08/01 13:48:34 Isn't there a setPatch method that should be used
Anders Johnsen 2012/08/01 14:21:09 Very nice spotted, I must have confused myself by
+ return function;
+ } else if (patchElement.isField()) {
+ // TODO(ajohnsen): Decide if a VariableElement should have a patch field.
+ return new VariableElement.from(patchElement.name,
+ patchElement,
+ enclosing);
+ }
// TODO(lrn): Create a copy of patchElement that isn't added to any
// object/library yet, but which takes its source from patchElement.
- throw "Adding members from patch is unsupported";
+ throw "Adding ${patchElement.kind} from patch is unsupported";
}
void patchMember(Element originalElement, Element patchElement) {

Powered by Google App Engine
This is Rietveld 408576698