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

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

Issue 11348133: Add JSNull, JSBool and JSFunction, and move toString into the new interceptor scheme. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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: sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart (revision 15091)
+++ sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart (working copy)
@@ -1182,7 +1182,6 @@
Map<int, String> cache;
String extraArg;
- String extraArgWithThis;
String extraArgWithoutComma;
// Methods on foreign classes take an extra parameter, which is
// the actual receiver of the call.
@@ -1190,13 +1189,11 @@
if (backend.isInterceptorClass(member.getEnclosingClass())) {
cache = interceptorClosureCache;
extraArg = 'receiver, ';
- extraArgWithThis = 'this.receiver, ';
extraArgWithoutComma = 'receiver';
} else {
cache = boundClosureCache;
extraArg = '';
extraArgWithoutComma = '';
- extraArgWithThis = '';
}
String closureClass =
@@ -1230,8 +1227,12 @@
String joinedArgs = Strings.join(arguments, ", ");
boundClosureBuffer.add(
"$invocationName: function($joinedArgs) {");
- boundClosureBuffer.add(
- " return this.self[this.target]($extraArgWithThis$joinedArgs);");
+ String callArgs = extraArg.isEmpty
+ ? joinedArgs
+ : joinedArgs.isEmpty
+ ? 'this.$extraArgWithoutComma'
+ : 'this.$extraArg$joinedArgs';
Johnni Winther 2012/11/20 09:26:20 Why the 'this.' prefix?
ngeoffray 2012/11/20 10:30:50 Because you're using a field of the bound closure,
+ boundClosureBuffer.add(" return this.self[this.target]($callArgs);");
Johnni Winther 2012/11/20 09:26:20 If extraArgWithoutComma is '' then callArgs become
ngeoffray 2012/11/20 10:30:50 If extraArgWithoutComma is '', then extrArg is ''.
karlklose 2012/11/20 10:31:00 I don't think this can happen, because extraArgWit
ngeoffray 2012/11/20 10:36:21 I added one flag: hasExtraArgument. What other fla
karlklose 2012/11/20 14:06:23 I thought about isInterceptor and hasArguments, bu
boundClosureBuffer.add(" }");
addParameterStubs(callElement, (String stubName, CodeBuffer memberValue) {
boundClosureBuffer.add(',\n $stubName: $memberValue');

Powered by Google App Engine
This is Rietveld 408576698