Chromium Code Reviews| 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'); |