Index: sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart |
=================================================================== |
--- sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart (revision 14856) |
+++ sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart (working copy) |
@@ -394,19 +394,36 @@ |
CodeBuffer buffer = new CodeBuffer(); |
buffer.add('function('); |
+ JavaScriptBackend backend = compiler.backend; |
ahe
2012/11/13 18:41:26
Looks like this variable is only used once.
ngeoffray
2012/11/14 09:24:44
Yes, but I need the 'cast' to JavaScriptBackend.
|
+ bool isInterceptorClass = |
+ backend.isInterceptorClass(member.getEnclosingClass()); |
+ |
+ // If the method is in an interceptor class, we need to also pass |
+ // the actual receiver. |
+ int extraArgumentCount = isInterceptorClass ? 1 : 0; |
+ |
// The parameters that this stub takes. |
- List<String> parametersBuffer = new List<String>(selector.argumentCount); |
+ List<String> parametersBuffer = |
+ new List<String>(selector.argumentCount + extraArgumentCount); |
// The arguments that will be passed to the real method. |
- List<String> argumentsBuffer = new List<String>(parameters.parameterCount); |
+ List<String> argumentsBuffer = |
+ new List<String>(parameters.parameterCount + extraArgumentCount); |
int count = 0; |
+ if (isInterceptorClass) { |
+ count++; |
+ // Use $ to avoid clashes with other parameter names. |
floitsch
2012/11/13 18:20:01
Too brittle. Discuss with Erik how this should be
ngeoffray
2012/11/14 09:18:43
Note that this is not touched by the minifier. I c
floitsch
2012/11/14 10:06:33
1. It should go through the minifier (eventually).
ngeoffray
2012/11/14 10:10:58
It doesn't have to be an accident, just an interna
floitsch
2012/11/14 10:18:45
Yes. there are several possibilities. That's why I
floitsch
2012/11/14 12:01:26
As Erik suggests: this should work for now.
Please
|
+ parametersBuffer[0] = r'$'; |
+ argumentsBuffer[0] = r'$'; |
+ } |
+ |
int indexOfLastOptionalArgumentInParameters = positionalArgumentCount - 1; |
TreeElements elements = |
compiler.enqueuer.resolution.getCachedElements(member); |
parameters.orderedForEachParameter((Element element) { |
String jsName = JsNames.getValid(element.name.slowToString()); |
- if (count < positionalArgumentCount) { |
+ if (count < positionalArgumentCount + extraArgumentCount) { |
parametersBuffer[count] = jsName; |
argumentsBuffer[count] = jsName; |
} else { |