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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/class_stub_generator.dart

Issue 1181063005: Fix for issue 23432 - Get the correct receiver in noSuchMethod stubs. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: fix bad merge Created 5 years, 6 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/old_emitter/nsm_emitter.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart2js.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 class ClassStubGenerator { 7 class ClassStubGenerator {
8 final Namer namer; 8 final Namer namer;
9 final Compiler compiler; 9 final Compiler compiler;
10 final JavaScriptBackend backend; 10 final JavaScriptBackend backend;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 new List.generate(selector.argumentCount, (i) => '\$$i'); 151 new List.generate(selector.argumentCount, (i) => '\$$i');
152 152
153 List<jsAst.Expression> argNames = 153 List<jsAst.Expression> argNames =
154 selector.callStructure.getOrderedNamedArguments().map((String name) => 154 selector.callStructure.getOrderedNamedArguments().map((String name) =>
155 js.string(name)).toList(); 155 js.string(name)).toList();
156 156
157 String methodName = selector.invocationMirrorMemberName; 157 String methodName = selector.invocationMirrorMemberName;
158 String internalName = namer.invocationMirrorInternalName(selector); 158 String internalName = namer.invocationMirrorInternalName(selector);
159 159
160 assert(backend.isInterceptedName(Compiler.NO_SUCH_METHOD)); 160 assert(backend.isInterceptedName(Compiler.NO_SUCH_METHOD));
161 bool isIntercepted = backend.isInterceptedName(selector.name);
161 jsAst.Expression expression = 162 jsAst.Expression expression =
162 js('''this.#noSuchMethodName(this, 163 js('''this.#noSuchMethodName(#receiver,
163 #createInvocationMirror(#methodName, 164 #createInvocationMirror(#methodName,
164 #internalName, 165 #internalName,
165 #type, 166 #type,
166 #arguments, 167 #arguments,
167 #namedArguments))''', 168 #namedArguments))''',
168 {'noSuchMethodName': namer.noSuchMethodName, 169 {'receiver': isIntercepted ? r'$receiver' : 'this',
170 'noSuchMethodName': namer.noSuchMethodName,
169 'createInvocationMirror': 171 'createInvocationMirror':
170 backend.emitter.staticFunctionAccess( 172 backend.emitter.staticFunctionAccess(
171 backend.getCreateInvocationMirror()), 173 backend.getCreateInvocationMirror()),
172 'methodName': 174 'methodName':
173 js.string(compiler.enableMinification 175 js.string(compiler.enableMinification
174 ? internalName : methodName), 176 ? internalName : methodName),
175 'internalName': js.string(internalName), 177 'internalName': js.string(internalName),
176 'type': js.number(type), 178 'type': js.number(type),
177 'arguments': 179 'arguments':
178 new jsAst.ArrayInitializer(parameterNames.map(js).toList()), 180 new jsAst.ArrayInitializer(parameterNames.map(js).toList()),
179 'namedArguments': new jsAst.ArrayInitializer(argNames)}); 181 'namedArguments': new jsAst.ArrayInitializer(argNames)});
180 182
181 jsAst.Expression function; 183 jsAst.Expression function;
182 if (backend.isInterceptedName(selector.name)) { 184 if (isIntercepted) {
183 function = js(r'function($receiver, #) { return # }', 185 function = js(r'function($receiver, #) { return # }',
184 [parameterNames, expression]); 186 [parameterNames, expression]);
185 } else { 187 } else {
186 function = js(r'function(#) { return # }', [parameterNames, expression]); 188 function = js(r'function(#) { return # }', [parameterNames, expression]);
187 } 189 }
188 return new StubMethod(name, function); 190 return new StubMethod(name, function);
189 } 191 }
190 } 192 }
191 193
192 /// Creates two JavaScript functions: `tearOffGetter` and `tearOff`. 194 /// Creates two JavaScript functions: `tearOffGetter` and `tearOff`.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 ? function() { 281 ? function() {
280 if (cache === void 0) cache = #tearOff( 282 if (cache === void 0) cache = #tearOff(
281 this, funcs, reflectionInfo, true, [], name).prototype; 283 this, funcs, reflectionInfo, true, [], name).prototype;
282 return cache; 284 return cache;
283 } 285 }
284 : tearOffGetter(funcs, reflectionInfo, name, isIntercepted); 286 : tearOffGetter(funcs, reflectionInfo, name, isIntercepted);
285 }''', {'tearOff': tearOffAccessExpression}); 287 }''', {'tearOff': tearOffAccessExpression});
286 288
287 return <jsAst.Statement>[tearOffGetter, tearOff]; 289 return <jsAst.Statement>[tearOffGetter, tearOff];
288 } 290 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/old_emitter/nsm_emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698