Skip to content

Commit e7f4948

Browse files
committed
---
yaml --- r: 30433 b: refs/heads/master c: 14ddfb7 h: refs/heads/master i: 30431: 5258c3a v: v3
1 parent 3dd9cbf commit e7f4948

File tree

4 files changed

+41
-6
lines changed

4 files changed

+41
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 89daba54544de1150c66ba72da078b9f113feb51
2+
refs/heads/master: 14ddfb7aac9d8e75c96d2395404a5937b22a149f

trunk/pkg/compiler/lib/src/js_backend/namer.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,10 @@ class Namer {
418418
case JsGetName.GETTER_PREFIX: return getterPrefix;
419419
case JsGetName.SETTER_PREFIX: return setterPrefix;
420420
case JsGetName.CALL_PREFIX: return callPrefix;
421+
case JsGetName.CALL_PREFIX0: return '${callPrefix}\$0';
422+
case JsGetName.CALL_PREFIX1: return '${callPrefix}\$1';
423+
case JsGetName.CALL_PREFIX2: return '${callPrefix}\$2';
424+
case JsGetName.CALL_PREFIX3: return '${callPrefix}\$3';
421425
case JsGetName.CALL_CATCH_ALL: return callCatchAllName;
422426
case JsGetName.REFLECTABLE: return reflectableField;
423427
case JsGetName.CLASS_DESCRIPTOR_PROPERTY:

trunk/sdk/lib/_internal/compiler/js_lib/js_helper.dart

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,20 +1146,47 @@ class Primitives {
11461146

11471147
static applyFunctionWithPositionalArguments(Function function,
11481148
List positionalArguments) {
1149-
int argumentCount = 0;
11501149
List arguments;
11511150

11521151
if (positionalArguments != null) {
11531152
if (JS('bool', '# instanceof Array', positionalArguments)) {
1154-
arguments = positionalArguments;
1153+
arguments = JS('JSArray', '#', positionalArguments);
11551154
} else {
11561155
arguments = new List.from(positionalArguments);
11571156
}
1158-
argumentCount = JS('int', '#.length', arguments);
11591157
} else {
11601158
arguments = [];
11611159
}
11621160

1161+
if (arguments.length == 0) {
1162+
String selectorName = JS_GET_NAME(JsGetName.CALL_PREFIX0);
1163+
if (JS('bool', '!!#[#]', function, selectorName)) {
1164+
return JS('', '#[#]()', function, selectorName);
1165+
}
1166+
} else if (arguments.length == 1) {
1167+
String selectorName = JS_GET_NAME(JsGetName.CALL_PREFIX1);
1168+
if (JS('bool', '!!#[#]', function, selectorName)) {
1169+
return JS('', '#[#](#[0])', function, selectorName, arguments);
1170+
}
1171+
} else if (arguments.length == 2) {
1172+
String selectorName = JS_GET_NAME(JsGetName.CALL_PREFIX2);
1173+
if (JS('bool', '!!#[#]', function, selectorName)) {
1174+
return JS('', '#[#](#[0],#[1])', function, selectorName,
1175+
arguments, arguments);
1176+
}
1177+
} else if (arguments.length == 3) {
1178+
String selectorName = JS_GET_NAME(JsGetName.CALL_PREFIX3);
1179+
if (JS('bool', '!!#[#]', function, selectorName)) {
1180+
return JS('', '#[#](#[0],#[1],#[2])', function, selectorName,
1181+
arguments, arguments, arguments);
1182+
}
1183+
}
1184+
return _genericApplyFunctionWithPositionalArguments(function, arguments);
1185+
}
1186+
1187+
static _genericApplyFunctionWithPositionalArguments(Function function,
1188+
List arguments) {
1189+
int argumentCount = arguments.length;
11631190
String selectorName =
11641191
'${JS_GET_NAME(JsGetName.CALL_PREFIX)}\$$argumentCount';
11651192
var jsFunction = JS('var', '#[#]', function, selectorName);
@@ -1168,7 +1195,7 @@ class Primitives {
11681195
jsFunction = JS('', '#["call*"]', interceptor);
11691196

11701197
if (jsFunction == null) {
1171-
return functionNoSuchMethod(function, positionalArguments, null);
1198+
return functionNoSuchMethod(function, arguments, null);
11721199
}
11731200
ReflectionInfo info = new ReflectionInfo(jsFunction);
11741201
int requiredArgumentCount = info.requiredParameterCount;
@@ -1177,7 +1204,7 @@ class Primitives {
11771204
if (info.areOptionalParametersNamed ||
11781205
requiredArgumentCount > argumentCount ||
11791206
maxArgumentCount < argumentCount) {
1180-
return functionNoSuchMethod(function, positionalArguments, null);
1207+
return functionNoSuchMethod(function, arguments, null);
11811208
}
11821209
arguments = new List.from(arguments);
11831210
for (int pos = argumentCount; pos < maxArgumentCount; pos++) {

trunk/sdk/lib/_internal/compiler/js_lib/shared/embedded_names.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ enum JsGetName {
7575
GETTER_PREFIX,
7676
SETTER_PREFIX,
7777
CALL_PREFIX,
78+
CALL_PREFIX0,
79+
CALL_PREFIX1,
80+
CALL_PREFIX2,
81+
CALL_PREFIX3,
7882
CALL_CATCH_ALL,
7983
REFLECTABLE,
8084
CLASS_DESCRIPTOR_PROPERTY,

0 commit comments

Comments
 (0)