ref: dbb86fcd8b6ab141f20512315a7ad12b63264638
parent: e38bff1f68b17b98364764ec70cb0f06405759c5
author: Tor Andersson <tor.andersson@artifex.com>
date: Fri Apr 23 07:12:36 EDT 2021
Call "join" property instead of hardcoding Ap_join in Ap_toString.
--- a/jsarray.c
+++ b/jsarray.c
@@ -423,9 +423,18 @@
static void Ap_toString(js_State *J)
{
- int top = js_gettop(J);
- js_pop(J, top - 1);
- Ap_join(J);
+ if (!js_iscoercible(J, 0))
+ js_typeerror(J, "'this' is not an object");
+ js_getproperty(J, 0, "join");
+ if (!js_iscallable(J, -1)) {
+ // TODO: call Object.prototype.toString implementation; not via Object.toString JS objects
+ js_getglobal(J, "Object");
+ js_getproperty(J, -1, "toString");
+ js_rot2pop1(J);
+ }
+ js_copy(J, 0);
+ js_call(J, 0);
+ js_pop(J, 1);
}
static void Ap_indexOf(js_State *J)