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

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

Issue 11366224: Move some string methods in the interceptor, and support for optional parameters in intercepted met… (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
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/lib/interceptors.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 14879)
+++ sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart (working copy)
@@ -394,19 +394,40 @@
CodeBuffer buffer = new CodeBuffer();
buffer.add('function(');
+ JavaScriptBackend backend = compiler.backend;
+ 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;
+ // Use '$' to avoid clashes with other parameter names. Using '$'
+ // works because [JsNames.getValid] used for getting parameter
+ // names never returns '$'.
+ String extraArgumentName = r'$';
+
// 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++;
+ parametersBuffer[0] = extraArgumentName;
+ argumentsBuffer[0] = extraArgumentName;
+ }
+
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) {
+ assert(jsName != extraArgumentName);
+ if (count < positionalArgumentCount + extraArgumentCount) {
parametersBuffer[count] = jsName;
argumentsBuffer[count] = jsName;
} else {
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/lib/interceptors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698