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 201a369d717df3cb931a2a8b1f67da996eb09f4c..94ac7ca8701fa8b1aaa84e1cfcc3f66ddb75452d 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,12 +278,14 @@ class NsmEmitter extends CodeEmitterHelper { |
' objectClassObject = objectClassObject[1];')); |
} |
- dynamic isIntercepted = // jsAst.Expression or bool. |
+ List<jsAst.Expression> sliceOffsetArguments = |
firstNormalSelector == 0 |
- ? false |
- : firstNormalSelector == shorts.length |
- ? true |
- : js('j < #', js.number(firstNormalSelector)); |
+ ? [] |
+ : (firstNormalSelector == shorts.length |
+ ? [js.number(1)] |
+ : [js('(j < #) ? 1 : 0', js.number(firstNormalSelector))]); |
+ |
+ var sliceOffsetParams = sliceOffsetArguments.isEmpty ? [] : ['sliceOffset']; |
statements.add(js.statement(''' |
// If we are loading a deferred library the object class will not be in |
@@ -292,51 +294,31 @@ class NsmEmitter extends CodeEmitterHelper { |
if (objectClassObject) { |
for (var j = 0; j < shortNames.length; j++) { |
var type = 0; |
- var shortName = shortNames[j]; |
- if (shortName[0] == "${namer.getterPrefix[0]}") type = 1; |
- if (shortName[0] == "${namer.setterPrefix[0]}") type = 2; |
+ var short = shortNames[j]; |
+ if (short[0] == "${namer.getterPrefix[0]}") type = 1; |
+ if (short[0] == "${namer.setterPrefix[0]}") type = 2; |
// Generate call to: |
// |
// createInvocationMirror(String name, internalName, type, |
// arguments, argumentNames) |
// |
- |
- // 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); |
- } |
+ 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); |
} |
}''', { |
+ 'sliceOffsetParams': sliceOffsetParams, |
'noSuchMethodName': namer.noSuchMethodName, |
'createInvocationMirror': createInvocationMirror, |
'names': minify ? 'shortNames' : 'longNames', |
- 'isIntercepted': isIntercepted})); |
+ 'sliceOffsetArguments': sliceOffsetArguments})); |
return statements; |
} |