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

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: 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 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..201a369d717df3cb931a2a8b1f67da996eb09f4c 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.
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,51 @@ 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,
+ // Create proper Array with all arguments except first
+ // (receiver).
+ Array.prototype.slice.call(arguments, 1),
+ []));
+ }
+ })(#names[j], shortName, type);
+ } else {
+ objectClassObject[shortName] =
+ (function(name, shortName, type) {
+ return function() {
+ return this.#noSuchMethodName(
+ // Object.noSuchMethodName ignores the explicit receiver
+ // argument. We could pass anything in place of [this].
+ this,
+ #createInvocationMirror(name, shortName, type,
+ // Create proper Array with all arguments.
+ Array.prototype.slice.call(arguments, 0),
+ []));
+ }
+ })(#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