Use ECMA-262 r5 semantics for missing this argument to call/apply.

This commit is contained in:
Tor Andersson
2014-01-19 15:45:29 +01:00
parent 58421f1601
commit 0467057b64
+6 -12
View File
@@ -52,13 +52,10 @@ static int Fp_apply(js_State *J, int n)
char name[20];
if (!js_iscallable(J, 0))
jsR_error(J, "TypeError");
js_copy(J, 0);
jsR_error(J, "TypeError: not a function");
if (js_isundefined(J, 1) || js_isnull(J, 1))
js_pushglobal(J);
else
js_copy(J, 1);
js_copy(J, 0);
js_copy(J, 1);
js_getproperty(J, 2, "length");
argc = js_tonumber(J, -1);
@@ -78,13 +75,10 @@ static int Fp_call(js_State *J, int n)
int i;
if (!js_iscallable(J, 0))
jsR_error(J, "TypeError");
js_copy(J, 0);
jsR_error(J, "TypeError: not a function");
if (js_isundefined(J, 1) || js_isnull(J, 1))
js_pushglobal(J);
else
js_copy(J, 1);
js_copy(J, 0);
js_copy(J, 1);
for (i = 1; i < n; ++i)
js_copy(J, i + 1);