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

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

Issue 10511008: Support overriding fields with fields. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased 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 | dart/lib/compiler/implementation/namer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/lib/compiler/implementation/emitter.dart
diff --git a/dart/lib/compiler/implementation/emitter.dart b/dart/lib/compiler/implementation/emitter.dart
index 399b0c47b64fd087f716c2b73fabbd79b45a3331..3121e1fec87ce642397f0941394cb56826f79d59 100644
--- a/dart/lib/compiler/implementation/emitter.dart
+++ b/dart/lib/compiler/implementation/emitter.dart
@@ -398,7 +398,17 @@ function() {
if (!parameters.optionalParameters.isEmpty()) {
addParameterStubs(member, defineInstanceMember);
}
- } else if (member.kind !== ElementKind.FIELD) {
+ } else if (member.kind === ElementKind.FIELD) {
+ SourceString name = member.name;
+ ClassElement cls = member.getEnclosingClass();
+ if (cls.lookupSuperMember(name) !== null) {
+ String fieldName = namer.instanceFieldName(cls, name);
+ defineInstanceMember(namer.getterName(cls.getLibrary(), name),
+ 'function() {\n return this.$fieldName;\n }');
+ defineInstanceMember(namer.setterName(cls.getLibrary(), name),
+ 'function(x) {\n this.$fieldName = x;\n }');
+ }
+ } else {
compiler.internalError('unexpected kind: "${member.kind}"',
element: member);
}
@@ -433,9 +443,9 @@ function() {
} else {
buffer.add(", ");
}
- LibraryElement library = member.getLibrary();
SourceString name = member.name;
- String fieldName = namer.instanceFieldName(library, name);
+ String fieldName = namer.instanceFieldName(member.getEnclosingClass(),
+ name);
// Getters and setters with suffixes will be generated dynamically.
buffer.add('"$fieldName');
if (needsDynamicGetter || needsDynamicSetter) {
@@ -717,8 +727,9 @@ function() {
if (member.kind == ElementKind.GETTER) {
getter = "this.${namer.getterName(member.getLibrary(), member.name)}()";
} else {
- getter =
- "this.${namer.instanceFieldName(member.getLibrary(), member.name)}";
+ String name = namer.instanceFieldName(member.getEnclosingClass(),
+ member.name);
+ getter = "this.$name";
}
for (Selector selector in selectors) {
if (selector.applies(member, compiler)) {
« no previous file with comments | « no previous file | dart/lib/compiler/implementation/namer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698