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

Unified Diff: sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart

Issue 11445005: Fix issue 7086: support call-through getter for interceptor classes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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 | tests/language/interceptor5_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart (revision 15720)
+++ sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart (working copy)
@@ -1304,15 +1304,23 @@
DefineMemberFunction defineInstanceMember) {
assert(invariant(member, member.isDeclaration));
LibraryElement memberLibrary = member.getLibrary();
+ JavaScriptBackend backend = compiler.backend;
+ // If the class is an interceptor class, the stub gets the
+ // receiver explicitely and we need to pass it to the getter call.
+ bool isInterceptorClass =
+ backend.isInterceptorClass(member.getEnclosingClass());
+ String extraArgument = isInterceptorClass ? 'receiver' : '';
String getter;
if (member.isGetter()) {
- getter = "this.${namer.getterName(member.getLibrary(), member.name)}()";
+ String getterName = namer.getterName(member.getLibrary(), member.name);
+ getter = "this.$getterName($extraArgument)";
} else {
String name = member.isNative()
? member.nativeName()
: namer.instanceFieldName(memberLibrary, member.name);
getter = "this.$name";
}
+
for (Selector selector in selectors) {
if (selector.applies(member, compiler)) {
String invocationName =
@@ -1328,8 +1336,15 @@
}
String joined = Strings.join(arguments, ", ");
CodeBuffer getterBuffer = new CodeBuffer();
+ getterBuffer.add("function(");
+ if (isInterceptorClass) {
+ getterBuffer.add(extraArgument);
+ if (!arguments.isEmpty) {
+ getterBuffer.add(', ');
+ }
+ }
getterBuffer.add(
- "function($joined) { return $getter.$closureCallName($joined); }");
+ "$joined) { return $getter.$closureCallName($joined); }");
defineInstanceMember(invocationName, getterBuffer);
}
}
« no previous file with comments | « no previous file | tests/language/interceptor5_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698