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

Unified Diff: pkg/compiler/lib/src/js_emitter/old_emitter/nsm_emitter.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: 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/js_emitter/old_emitter/nsm_emitter.dart
diff --git a/pkg/compiler/lib/src/js_emitter/old_emitter/nsm_emitter.dart b/pkg/compiler/lib/src/js_emitter/old_emitter/nsm_emitter.dart
index 94ac7ca8701fa8b1aaa84e1cfcc3f66ddb75452d..755f43cfd9c0a5f095add29c5f367244b9615691 100644
--- a/pkg/compiler/lib/src/js_emitter/old_emitter/nsm_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/old_emitter/nsm_emitter.dart
@@ -278,14 +278,12 @@ class NsmEmitter extends CodeEmitterHelper {
' objectClassObject = objectClassObject[1];'));
}
- List<jsAst.Expression> sliceOffsetArguments =
+ dynamic isIntercepted = // jsAst.Expression or bool.
floitsch 2015/06/19 21:22:15 firstNormalSelector != 0 && (firstNormalSelector =
sra1 2015/06/22 20:17:00 You can't use || to pick the jsAst. || is bool*bo
firstNormalSelector == 0
- ? []
- : (firstNormalSelector == shorts.length
- ? [js.number(1)]
- : [js('(j < #) ? 1 : 0', js.number(firstNormalSelector))]);
-
- var sliceOffsetParams = sliceOffsetArguments.isEmpty ? [] : ['sliceOffset'];
+ ? false
+ : firstNormalSelector == shorts.length
+ ? true
+ : js('j < #', js.number(firstNormalSelector));
statements.add(js.statement('''
// If we are loading a deferred library the object class will not be in
@@ -294,31 +292,46 @@ class NsmEmitter extends CodeEmitterHelper {
if (objectClassObject) {
for (var j = 0; j < shortNames.length; j++) {
var type = 0;
- var short = shortNames[j];
- if (short[0] == "${namer.getterPrefix[0]}") type = 1;
- if (short[0] == "${namer.setterPrefix[0]}") type = 2;
+ var shortName = shortNames[j];
+ if (shortName[0] == "${namer.getterPrefix[0]}") type = 1;
+ if (shortName[0] == "${namer.setterPrefix[0]}") type = 2;
// Generate call to:
//
// createInvocationMirror(String name, internalName, type,
// arguments, argumentNames)
//
- objectClassObject[short] = (function(name, short,
- type, #sliceOffsetParams) {
- return function() {
- return this.#noSuchMethodName(this,
- #createInvocationMirror(name, short, type,
- Array.prototype.slice.call(arguments,
- #sliceOffsetParams),
- []));
- }
- })(#names[j], short, type, #sliceOffsetArguments);
+
+ // This 'if' is either a static choice or dynamic choice depending on
+ // 'isIntercepted'.
+ if (#isIntercepted) {
+ objectClassObject[shortName] =
+ (function(name, shortName, type) {
+ return function(receiver) {
+ return this.#noSuchMethodName(
+ receiver,
+ #createInvocationMirror(name, shortName, type,
+ Array.prototype.slice.call(arguments, 1),
floitsch 2015/06/19 21:22:15 add comment what the "1" is.
sra1 2015/06/22 20:17:00 Done.
+ []));
+ }
+ })(#names[j], shortName, type);
+ } else {
+ objectClassObject[shortName] =
+ (function(name, shortName, type) {
+ return function() {
+ return this.#noSuchMethodName(
+ this, // Could be dummy receiver.
floitsch 2015/06/19 21:22:15 how is that possible? if the call is not intercept
sra1 2015/06/22 20:17:00 Done.
+ #createInvocationMirror(name, shortName, type,
+ Array.prototype.slice.call(arguments),
Siggi Cherem (dart-lang) 2015/06/19 18:33:22 woudln't this return []? do we need splice here?
sra1 2015/06/19 18:59:38 slice copies a slice of the input. 'arguments' con
Siggi Cherem (dart-lang) 2015/06/19 19:46:00 Then are we missing the 0 argument here? That is:
sra1 2015/06/22 20:17:00 "If begin is omitted, slice begins from index 0."
Siggi Cherem (dart-lang) 2015/06/22 20:37:32 Sorry for all the silly questions here. Apparently
+ []));
+ }
+ })(#names[j], shortName, type);
+ }
}
}''', {
- 'sliceOffsetParams': sliceOffsetParams,
'noSuchMethodName': namer.noSuchMethodName,
'createInvocationMirror': createInvocationMirror,
'names': minify ? 'shortNames' : 'longNames',
- 'sliceOffsetArguments': sliceOffsetArguments}));
+ 'isIntercepted': isIntercepted}));
return statements;
}
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/class_stub_generator.dart ('k') | sdk/lib/_internal/compiler/js_lib/interceptors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698