This commit is contained in:
2026-01-20 16:38:24 -06:00
parent b28ef39562
commit dc02d6899d
3 changed files with 6 additions and 578 deletions

View File

@@ -211,8 +211,6 @@ DEF( lte, 1, 2, 1, none)
DEF( gt, 1, 2, 1, none)
DEF( gte, 1, 2, 1, none)
DEF( in, 1, 2, 1, none)
DEF( eq, 1, 2, 1, none)
DEF( neq, 1, 2, 1, none)
DEF( strict_eq, 1, 2, 1, none)
DEF( strict_neq, 1, 2, 1, none)
DEF( and, 1, 2, 1, none)

View File

@@ -719,7 +719,6 @@ typedef enum {
JS_OVOP_SHL,
JS_OVOP_SAR,
JS_OVOP_SHR,
JS_OVOP_EQ,
JS_OVOP_LESS,
JS_OVOP_BINARY_COUNT,
@@ -1947,7 +1946,6 @@ static void JS_MarkContext(JSRuntime *rt, JSContext *ctx,
JS_MarkValue(rt, ctx->array_ctor, mark_func);
JS_MarkValue(rt, ctx->regexp_ctor, mark_func);
JS_MarkValue(rt, ctx->function_ctor, mark_func);
JS_MarkValue(rt, ctx->function_proto, mark_func);
if (ctx->array_shape)
mark_func(rt, &ctx->array_shape->header);
@@ -2006,7 +2004,6 @@ void JS_FreeContext(JSContext *ctx)
JS_FreeValue(ctx, ctx->array_ctor);
JS_FreeValue(ctx, ctx->regexp_ctor);
JS_FreeValue(ctx, ctx->function_ctor);
JS_FreeValue(ctx, ctx->function_proto);
js_free_shape_null(ctx->rt, ctx->array_shape);
@@ -11070,94 +11067,6 @@ static BOOL tag_is_number(uint32_t tag)
tag == JS_TAG_FLOAT64);
}
static no_inline __exception int js_eq_slow(JSContext *ctx, JSValue *sp,
BOOL is_neq)
{
JSValue op1, op2;
int res;
uint32_t tag1, tag2;
op1 = sp[-2];
op2 = sp[-1];
redo:
tag1 = JS_VALUE_GET_NORM_TAG(op1);
tag2 = JS_VALUE_GET_NORM_TAG(op2);
if (tag_is_number(tag1) && tag_is_number(tag2)) {
if (tag1 == JS_TAG_INT && tag2 == JS_TAG_INT) {
res = JS_VALUE_GET_INT(op1) == JS_VALUE_GET_INT(op2);
} else if ((tag1 == JS_TAG_FLOAT64 &&
(tag2 == JS_TAG_INT || tag2 == JS_TAG_FLOAT64)) ||
(tag2 == JS_TAG_FLOAT64 &&
(tag1 == JS_TAG_INT || tag1 == JS_TAG_FLOAT64))) {
double d1, d2;
if (tag1 == JS_TAG_FLOAT64) {
d1 = JS_VALUE_GET_FLOAT64(op1);
} else {
d1 = JS_VALUE_GET_INT(op1);
}
if (tag2 == JS_TAG_FLOAT64) {
d2 = JS_VALUE_GET_FLOAT64(op2);
} else {
d2 = JS_VALUE_GET_INT(op2);
}
res = (d1 == d2);
}
} else if (tag1 == tag2) {
res = js_strict_eq2(ctx, op1, op2, JS_EQ_STRICT);
} else if (tag1 == JS_TAG_NULL && tag2 == JS_TAG_NULL) {
res = TRUE;
} else if (tag_is_string(tag1) && tag_is_string(tag2)) {
/* needed when comparing strings and ropes */
res = js_strict_eq2(ctx, op1, op2, JS_EQ_STRICT);
} else if ((tag_is_string(tag1) && tag_is_number(tag2)) ||
(tag_is_string(tag2) && tag_is_number(tag1))) {
op1 = JS_ToNumericFree(ctx, op1);
if (JS_IsException(op1)) {
JS_FreeValue(ctx, op2);
goto exception;
}
op2 = JS_ToNumericFree(ctx, op2);
if (JS_IsException(op2)) {
JS_FreeValue(ctx, op1);
goto exception;
}
res = js_strict_eq2(ctx, op1, op2, JS_EQ_STRICT);
} else if (tag1 == JS_TAG_BOOL) {
op1 = JS_NewInt32(ctx, JS_VALUE_GET_INT(op1));
goto redo;
} else if (tag2 == JS_TAG_BOOL) {
op2 = JS_NewInt32(ctx, JS_VALUE_GET_INT(op2));
goto redo;
} else if ((tag1 == JS_TAG_OBJECT &&
(tag_is_number(tag2) || tag_is_string(tag2) || tag2 == JS_TAG_SYMBOL)) ||
(tag2 == JS_TAG_OBJECT &&
(tag_is_number(tag1) || tag_is_string(tag1) || tag1 == JS_TAG_SYMBOL))) {
op1 = JS_ToPrimitiveFree(ctx, op1, HINT_NONE);
if (JS_IsException(op1)) {
JS_FreeValue(ctx, op2);
goto exception;
}
op2 = JS_ToPrimitiveFree(ctx, op2, HINT_NONE);
if (JS_IsException(op2)) {
JS_FreeValue(ctx, op1);
goto exception;
}
goto redo;
} else {
res = FALSE;
JS_FreeValue(ctx, op1);
JS_FreeValue(ctx, op2);
}
done:
sp[-2] = JS_NewBool(ctx, res ^ is_neq);
return 0;
exception:
sp[-2] = JS_NULL;
sp[-1] = JS_NULL;
return -1;
}
/* XXX: Should take JSValueConst arguments */
static BOOL js_strict_eq2(JSContext *ctx, JSValue op1, JSValue op2,
JSStrictEqModeEnum eq_mode)
@@ -11194,18 +11103,6 @@ static BOOL js_strict_eq2(JSContext *ctx, JSValue op1, JSValue op2,
}
}
break;
case JS_TAG_SYMBOL:
{
JSAtomStruct *p1, *p2;
if (tag1 != tag2) {
res = FALSE;
} else {
p1 = JS_VALUE_GET_PTR(op1);
p2 = JS_VALUE_GET_PTR(op2);
res = (p1 == p2);
}
}
break;
case JS_TAG_OBJECT:
if (tag1 != tag2)
res = FALSE;
@@ -14414,8 +14311,6 @@ static JSValue JS_CallInternal_OLD(JSContext *caller_ctx, JSValueConst func_obj,
OP_CMP(OP_lte, <=, js_relational_slow(ctx, sp, opcode));
OP_CMP(OP_gt, >, js_relational_slow(ctx, sp, opcode));
OP_CMP(OP_gte, >=, js_relational_slow(ctx, sp, opcode));
OP_CMP(OP_eq, ==, js_eq_slow(ctx, sp, 0));
OP_CMP(OP_neq, !=, js_eq_slow(ctx, sp, 1));
OP_CMP(OP_strict_eq, ==, js_strict_eq_slow(ctx, sp, 0));
OP_CMP(OP_strict_neq, !=, js_strict_eq_slow(ctx, sp, 1));
@@ -26841,211 +26736,6 @@ static JSValue js_object_constructor(JSContext *ctx, JSValueConst new_target,
return ret;
}
static JSValue js_object_create(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
JSValueConst proto, props;
JSValue obj;
proto = argv[0];
if (!JS_IsObject(proto) && !JS_IsNull(proto))
return JS_ThrowTypeError(ctx, "not a prototype");
obj = JS_NewObjectProto(ctx, proto);
if (JS_IsException(obj))
return JS_EXCEPTION;
props = argv[1];
if (!JS_IsNull(props)) {
if (JS_ObjectDefineProperties(ctx, obj, props)) {
JS_FreeValue(ctx, obj);
return JS_EXCEPTION;
}
}
return obj;
}
static JSValue js_object_getPrototypeOf(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv, int magic)
{
JSValueConst val;
val = argv[0];
if (JS_VALUE_GET_TAG(val) != JS_TAG_OBJECT) {
/* ES6 feature non compatible with ES5.1: primitive types are
accepted */
if (magic || JS_VALUE_GET_TAG(val) == JS_TAG_NULL)
return JS_ThrowTypeErrorNotAnObject(ctx);
}
return JS_GetPrototype(ctx, val);
}
static JSValue js_object_setPrototypeOf(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
JSValueConst obj;
obj = argv[0];
if (JS_SetPrototypeInternal(ctx, obj, argv[1]) < 0)
return JS_EXCEPTION;
return JS_DupValue(ctx, obj);
}
/* magic = 1 if called as Reflect.defineProperty */
static JSValue js_object_defineProperty(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv, int magic)
{
JSValueConst obj, prop, desc;
int ret, flags;
JSAtom atom;
obj = argv[0];
prop = argv[1];
desc = argv[2];
if (JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT)
return JS_ThrowTypeErrorNotAnObject(ctx);
atom = JS_ValueToAtom(ctx, prop);
if (unlikely(atom == JS_ATOM_NULL))
return JS_EXCEPTION;
flags = 0;
if (!magic)
flags |= JS_PROP_THROW;
ret = JS_DefinePropertyDesc(ctx, obj, atom, desc, flags);
JS_FreeAtom(ctx, atom);
if (ret < 0) {
return JS_EXCEPTION;
} else if (magic) {
return JS_NewBool(ctx, ret);
} else {
return JS_DupValue(ctx, obj);
}
}
static JSValue js_object_defineProperties(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
// defineProperties(obj, properties)
JSValueConst obj = argv[0];
if (JS_ObjectDefineProperties(ctx, obj, argv[1]))
return JS_EXCEPTION;
else
return JS_DupValue(ctx, obj);
}
static JSValue js_object_getOwnPropertyDescriptor(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv, int magic)
{
JSValueConst prop;
JSAtom atom;
JSValue ret, obj;
JSPropertyDescriptor desc;
int res, flags;
if (magic) {
/* Reflect.getOwnPropertyDescriptor case */
if (JS_VALUE_GET_TAG(argv[0]) != JS_TAG_OBJECT)
return JS_ThrowTypeErrorNotAnObject(ctx);
obj = JS_DupValue(ctx, argv[0]);
} else {
obj = JS_ToObject(ctx, argv[0]);
if (JS_IsException(obj))
return obj;
}
prop = argv[1];
atom = JS_ValueToAtom(ctx, prop);
if (unlikely(atom == JS_ATOM_NULL))
goto exception;
ret = JS_NULL;
if (JS_VALUE_GET_TAG(obj) == JS_TAG_OBJECT) {
res = JS_GetOwnPropertyInternal(ctx, &desc, JS_VALUE_GET_OBJ(obj), atom);
if (res < 0)
goto exception;
if (res) {
ret = JS_NewObject(ctx);
if (JS_IsException(ret))
goto exception1;
flags = JS_PROP_C_W_E | JS_PROP_THROW;
if (desc.flags & JS_PROP_GETSET) {
if (JS_DefinePropertyValue(ctx, ret, JS_ATOM_get, JS_DupValue(ctx, desc.getter), flags) < 0
|| JS_DefinePropertyValue(ctx, ret, JS_ATOM_set, JS_DupValue(ctx, desc.setter), flags) < 0)
goto exception1;
} else {
if (JS_DefinePropertyValue(ctx, ret, JS_ATOM_value, JS_DupValue(ctx, desc.value), flags) < 0
|| JS_DefinePropertyValue(ctx, ret, JS_ATOM_writable,
JS_NewBool(ctx, desc.flags & JS_PROP_WRITABLE), flags) < 0)
goto exception1;
}
if (JS_DefinePropertyValue(ctx, ret, JS_ATOM_enumerable,
JS_NewBool(ctx, desc.flags & JS_PROP_ENUMERABLE), flags) < 0
|| JS_DefinePropertyValue(ctx, ret, JS_ATOM_configurable,
JS_NewBool(ctx, desc.flags & JS_PROP_CONFIGURABLE), flags) < 0)
goto exception1;
js_free_desc(ctx, &desc);
}
}
JS_FreeAtom(ctx, atom);
JS_FreeValue(ctx, obj);
return ret;
exception1:
js_free_desc(ctx, &desc);
JS_FreeValue(ctx, ret);
exception:
JS_FreeAtom(ctx, atom);
JS_FreeValue(ctx, obj);
return JS_EXCEPTION;
}
static JSValue js_object_getOwnPropertyDescriptors(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
//getOwnPropertyDescriptors(obj)
JSValue obj, r;
JSObject *p;
JSPropertyEnum *props;
uint32_t len, i;
r = JS_NULL;
obj = JS_ToObject(ctx, argv[0]);
if (JS_IsException(obj))
return JS_EXCEPTION;
p = JS_VALUE_GET_OBJ(obj);
if (JS_GetOwnPropertyNamesInternal(ctx, &props, &len, p,
JS_GPN_STRING_MASK | JS_GPN_SYMBOL_MASK))
goto exception;
r = JS_NewObject(ctx);
if (JS_IsException(r))
goto exception;
for(i = 0; i < len; i++) {
JSValue atomValue, desc;
JSValueConst args[2];
atomValue = JS_AtomToValue(ctx, props[i].atom);
if (JS_IsException(atomValue))
goto exception;
args[0] = obj;
args[1] = atomValue;
desc = js_object_getOwnPropertyDescriptor(ctx, JS_NULL, 2, args, 0);
JS_FreeValue(ctx, atomValue);
if (JS_IsException(desc))
goto exception;
if (!JS_IsNull(desc)) {
if (JS_DefinePropertyValue(ctx, r, props[i].atom, desc,
JS_PROP_C_W_E | JS_PROP_THROW) < 0)
goto exception;
}
}
JS_FreePropertyEnum(ctx, props, len);
JS_FreeValue(ctx, obj);
return r;
exception:
JS_FreePropertyEnum(ctx, props, len);
JS_FreeValue(ctx, obj);
JS_FreeValue(ctx, r);
return JS_EXCEPTION;
}
static JSValue JS_GetOwnPropertyNames2(JSContext *ctx, JSValueConst obj1,
int flags, int kind)
{
@@ -27125,13 +26815,6 @@ done:
return r;
}
static JSValue js_object_getOwnPropertyNames(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
return JS_GetOwnPropertyNames2(ctx, argv[0],
JS_GPN_STRING_MASK, JS_ITERATOR_KIND_KEY);
}
static JSValue js_object_keys(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv, int kind)
{
@@ -27139,77 +26822,6 @@ static JSValue js_object_keys(JSContext *ctx, JSValueConst this_val,
JS_GPN_ENUM_ONLY | JS_GPN_STRING_MASK, kind);
}
static JSValue js_object_isExtensible(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv, int reflect)
{
JSValueConst obj;
int ret;
obj = argv[0];
if (JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT) {
if (reflect)
return JS_ThrowTypeErrorNotAnObject(ctx);
else
return JS_FALSE;
}
ret = JS_IsExtensible(ctx, obj);
if (ret < 0)
return JS_EXCEPTION;
else
return JS_NewBool(ctx, ret);
}
static JSValue js_object_preventExtensions(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv, int reflect)
{
JSValueConst obj;
int ret;
obj = argv[0];
if (JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT) {
if (reflect)
return JS_ThrowTypeErrorNotAnObject(ctx);
else
return JS_DupValue(ctx, obj);
}
ret = JS_PreventExtensions(ctx, obj);
if (ret < 0)
return JS_EXCEPTION;
if (reflect) {
return JS_NewBool(ctx, ret);
} else {
if (!ret)
return JS_ThrowTypeError(ctx, "proxy preventExtensions handler returned false");
return JS_DupValue(ctx, obj);
}
}
static JSValue js_object_hasOwn(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
JSValue obj;
JSAtom atom;
JSObject *p;
BOOL ret;
obj = JS_ToObject(ctx, argv[0]);
if (JS_IsException(obj))
return obj;
atom = JS_ValueToAtom(ctx, argv[1]);
if (unlikely(atom == JS_ATOM_NULL)) {
JS_FreeValue(ctx, obj);
return JS_EXCEPTION;
}
p = JS_VALUE_GET_OBJ(obj);
ret = JS_GetOwnPropertyInternal(ctx, NULL, p, atom);
JS_FreeAtom(ctx, atom);
JS_FreeValue(ctx, obj);
if (ret < 0)
return JS_EXCEPTION;
else
return JS_NewBool(ctx, ret);
}
static JSValue js_object_toString(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
@@ -27260,34 +26872,6 @@ static JSValue js_object_toString(JSContext *ctx, JSValueConst this_val,
return JS_ConcatString3(ctx, "[object ", tag, "]");
}
static JSValue js_object_assign(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
// Object.assign(obj, source1)
JSValue obj, s;
int i;
s = JS_NULL;
obj = JS_ToObject(ctx, argv[0]);
if (JS_IsException(obj))
goto exception;
for (i = 1; i < argc; i++) {
if (!JS_IsNull(argv[i]) && !JS_IsNull(argv[i])) {
s = JS_ToObject(ctx, argv[i]);
if (JS_IsException(s))
goto exception;
if (JS_CopyDataProperties(ctx, obj, s, JS_NULL, TRUE))
goto exception;
JS_FreeValue(ctx, s);
}
}
return obj;
exception:
JS_FreeValue(ctx, obj);
JS_FreeValue(ctx, s);
return JS_EXCEPTION;
}
static JSValue js_object_seal(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv, int freeze_flag)
{
@@ -27339,32 +26923,6 @@ static JSValue js_object_seal(JSContext *ctx, JSValueConst this_val,
return JS_EXCEPTION;
}
/* return an empty string if not an object */
static JSValue js_object___getClass(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
JSAtom atom;
JSObject *p;
uint32_t tag;
int class_id;
tag = JS_VALUE_GET_NORM_TAG(argv[0]);
if (tag == JS_TAG_OBJECT) {
p = JS_VALUE_GET_OBJ(argv[0]);
class_id = p->class_id;
atom = ctx->rt->class_array[class_id].class_name;
} else {
atom = JS_ATOM_empty_string;
}
return JS_AtomToString(ctx, atom);
}
static JSValue js_object_is(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
return JS_NewBool(ctx, js_same_value(ctx, argv[0], argv[1]));
}
static JSValue JS_SpeciesConstructor(JSContext *ctx, JSValueConst obj,
JSValueConst defaultConstructor)
{
@@ -27394,25 +26952,8 @@ static JSValue JS_SpeciesConstructor(JSContext *ctx, JSValueConst obj,
return species;
}
static const JSCFunctionListEntry js_object_funcs[] = {
JS_CFUNC_DEF("create", 2, js_object_create ),
JS_CFUNC_MAGIC_DEF("getPrototypeOf", 1, js_object_getPrototypeOf, 0 ),
JS_CFUNC_DEF("setPrototypeOf", 2, js_object_setPrototypeOf ),
JS_CFUNC_MAGIC_DEF("defineProperty", 3, js_object_defineProperty, 0 ),
JS_CFUNC_DEF("defineProperties", 2, js_object_defineProperties ),
JS_CFUNC_DEF("getOwnPropertyNames", 1, js_object_getOwnPropertyNames ),
JS_CFUNC_MAGIC_DEF("isExtensible", 1, js_object_isExtensible, 0 ),
JS_CFUNC_MAGIC_DEF("preventExtensions", 1, js_object_preventExtensions, 0 ),
JS_CFUNC_MAGIC_DEF("getOwnPropertyDescriptor", 2, js_object_getOwnPropertyDescriptor, 0 ),
JS_CFUNC_DEF("getOwnPropertyDescriptors", 1, js_object_getOwnPropertyDescriptors ),
JS_CFUNC_DEF("is", 2, js_object_is ),
JS_CFUNC_DEF("assign", 2, js_object_assign ),
JS_CFUNC_DEF("__getClass", 1, js_object___getClass ),
JS_CFUNC_DEF("hasOwn", 2, js_object_hasOwn ),
};
static const JSCFunctionListEntry js_object_proto_funcs[] = {
JS_CFUNC_DEF("toString", 0, js_object_toString ),
// JS_CFUNC_DEF("toString", 0, js_object_toString ),
};
/* Function class */
@@ -27423,68 +26964,6 @@ static JSValue js_function_proto(JSContext *ctx, JSValueConst this_val,
return JS_NULL;
}
/* XXX: add a specific eval mode so that Function("}), ({") is rejected */
static JSValue js_function_constructor(JSContext *ctx, JSValueConst new_target,
int argc, JSValueConst *argv, int magic)
{
int i, n, ret;
JSValue s, proto, obj = JS_NULL;
StringBuffer b_s, *b = &b_s;
string_buffer_init(ctx, b, 0);
string_buffer_putc8(b, '(');
string_buffer_puts8(b, "function");
string_buffer_puts8(b, " anonymous(");
n = argc - 1;
for(i = 0; i < n; i++) {
if (i != 0) {
string_buffer_putc8(b, ',');
}
if (string_buffer_concat_value(b, argv[i]))
goto fail;
}
string_buffer_puts8(b, "\n) {\n");
if (n >= 0) {
if (string_buffer_concat_value(b, argv[n]))
goto fail;
}
string_buffer_puts8(b, "\n})");
s = string_buffer_end(b);
if (JS_IsException(s))
goto fail1;
obj = JS_EvalObject(ctx, ctx->global_obj, s, JS_EVAL_TYPE_INDIRECT, -1);
JS_FreeValue(ctx, s);
if (JS_IsException(obj))
goto fail1;
if (!JS_IsNull(new_target)) {
/* set the prototype */
proto = JS_GetProperty(ctx, new_target, JS_ATOM_prototype);
if (JS_IsException(proto))
goto fail1;
if (!JS_IsObject(proto)) {
JSContext *realm;
JS_FreeValue(ctx, proto);
realm = JS_GetFunctionRealm(ctx, new_target);
if (!realm)
goto fail1;
proto = JS_DupValue(ctx, realm->class_proto[JS_CLASS_BYTECODE_FUNCTION]);
}
ret = JS_SetPrototypeInternal(ctx, obj, proto);
JS_FreeValue(ctx, proto);
if (ret < 0)
goto fail1;
}
return obj;
fail:
string_buffer_free(b);
fail1:
JS_FreeValue(ctx, obj);
return JS_EXCEPTION;
}
static __exception int js_get_length32(JSContext *ctx, uint32_t *pres,
JSValueConst obj)
{
@@ -27729,7 +27208,7 @@ static JSValue js_error_toString(JSContext *ctx, JSValueConst this_val,
}
static const JSCFunctionListEntry js_error_proto_funcs[] = {
JS_CFUNC_DEF("toString", 0, js_error_toString ),
// JS_CFUNC_DEF("toString", 0, js_error_toString ),
JS_PROP_STRING_DEF("name", "Error", JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE ),
JS_PROP_STRING_DEF("message", "", JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE ),
};
@@ -28204,7 +27683,7 @@ static JSValue js_create_array(JSContext *ctx, int len, JSValueConst *tab)
}
static const JSCFunctionListEntry js_array_proto_funcs[] = {
JS_CFUNC_DEF("toString", 0, js_array_toString ),
// JS_CFUNC_DEF("toString", 0, js_array_toString ),
JS_CFUNC_MAGIC_DEF("pop", 0, js_array_pop, 0 ),
JS_CFUNC_MAGIC_DEF("push", 1, js_array_push, 0 ),
JS_CFUNC_MAGIC_DEF("shift", 0, js_array_pop, 1 ),
@@ -28568,7 +28047,7 @@ static JSValue js_string_concat(JSContext *ctx, JSValueConst this_val,
static const JSCFunctionListEntry js_string_proto_funcs[] = {
JS_CFUNC_DEF("concat", 1, js_string_concat),
JS_CFUNC_DEF("toString", 0, js_string_toString ),
// JS_CFUNC_DEF("toString", 0, js_string_toString ),
JS_CFUNC_DEF("valueOf", 0, js_string_toString ),
};
@@ -30154,7 +29633,7 @@ static JSValue js_symbol_get_description(JSContext *ctx, JSValueConst this_val)
}
static const JSCFunctionListEntry js_symbol_proto_funcs[] = {
JS_CFUNC_DEF("toString", 0, js_symbol_toString ),
// JS_CFUNC_DEF("toString", 0, js_symbol_toString ),
JS_CFUNC_DEF("valueOf", 0, js_symbol_valueOf ),
// XXX: should have writable: false
JS_CFUNC_DEF("[Symbol.toPrimitive]", 1, js_symbol_valueOf ),
@@ -32947,47 +32426,6 @@ static JSValue js_cell_object(JSContext *ctx, JSValueConst this_val,
return JS_NULL;
}
/* object.values(obj) */
static JSValue js_cell_object_values(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
if (argc < 1) return JS_NULL;
return JS_GetOwnPropertyNames2(ctx, argv[0],
JS_GPN_ENUM_ONLY | JS_GPN_STRING_MASK,
JS_ITERATOR_KIND_VALUE);
}
/* object.assign(obj, ...args) */
static JSValue js_cell_object_assign(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
if (argc < 1) return JS_NULL;
return js_object_assign(ctx, this_val, argc, argv);
}
/* object.has(obj, key) - check if object has own property */
static JSValue js_cell_object_has(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv)
{
if (argc < 2) return JS_NULL;
if (!JS_IsObject(argv[0])) return JS_NULL;
JSAtom atom = JS_ValueToAtom(ctx, argv[1]);
if (atom == JS_ATOM_NULL) return JS_EXCEPTION;
int ret = JS_HasProperty(ctx, argv[0], atom);
JS_FreeAtom(ctx, atom);
if (ret < 0) return JS_EXCEPTION;
return JS_NewBool(ctx, ret);
}
static const JSCFunctionListEntry js_cell_object_funcs[] = {
JS_CFUNC_DEF("values", 1, js_cell_object_values),
JS_CFUNC_DEF("assign", 2, js_cell_object_assign),
JS_CFUNC_DEF("has", 2, js_cell_object_has),
};
/* ----------------------------------------------------------------------------
* fn function and sub-functions
* ---------------------------------------------------------------------------- */
@@ -33573,8 +33011,6 @@ static const JSCFunctionListEntry js_blob_proto_funcs[] = {
/* Initialize blob - called during context setup (but we do it in JS_AddIntrinsicBaseObjects now) */
JSValue js_blob_use(JSContext *js)
{
/* Blob is now initialized as an intrinsic in JS_AddIntrinsicBaseObjects */
/* Return the blob constructor for compatibility */
return JS_GetPropertyStr(js, js->global_obj, "blob");
}
@@ -34432,14 +33868,9 @@ void JS_AddIntrinsicBaseObjects(JSContext *ctx)
JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
JSValue object_func = JS_NewCFunction(ctx, js_cell_object, "object", 2);
JS_SetPropertyFunctionList(ctx, object_func, js_cell_object_funcs, countof(js_cell_object_funcs));
JS_DefinePropertyValueStr(ctx, ctx->global_obj, "object", object_func,
JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
JSValue fn_obj = JS_NewObject(ctx);
JS_DefinePropertyValueStr(ctx, ctx->global_obj, "fn", fn_obj,
JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
/* Blob intrinsic type */
{
JSClassDef blob_class = {