mirror of
https://github.com/bellard/quickjs.git
synced 2024-11-22 13:48:11 +08:00
reworked set property and fixed corner cases of typed array set property
This commit is contained in:
parent
20a57f90d7
commit
58f374ef42
274
quickjs.c
274
quickjs.c
@ -8293,119 +8293,14 @@ static void js_free_desc(JSContext *ctx, JSPropertyDescriptor *desc)
|
|||||||
JS_FreeValue(ctx, desc->value);
|
JS_FreeValue(ctx, desc->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* generic (and slower) version of JS_SetProperty() for
|
|
||||||
* Reflect.set(). 'obj' must be an object. */
|
|
||||||
static int JS_SetPropertyGeneric(JSContext *ctx,
|
|
||||||
JSValueConst obj, JSAtom prop,
|
|
||||||
JSValue val, JSValueConst this_obj,
|
|
||||||
int flags)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
JSPropertyDescriptor desc;
|
|
||||||
JSValue obj1;
|
|
||||||
JSObject *p;
|
|
||||||
|
|
||||||
obj1 = JS_DupValue(ctx, obj);
|
|
||||||
for(;;) {
|
|
||||||
p = JS_VALUE_GET_OBJ(obj1);
|
|
||||||
if (p->is_exotic) {
|
|
||||||
const JSClassExoticMethods *em = ctx->rt->class_array[p->class_id].exotic;
|
|
||||||
if (em && em->set_property) {
|
|
||||||
ret = em->set_property(ctx, obj1, prop,
|
|
||||||
val, this_obj, flags);
|
|
||||||
JS_FreeValue(ctx, obj1);
|
|
||||||
JS_FreeValue(ctx, val);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = JS_GetOwnPropertyInternal(ctx, &desc, p, prop);
|
|
||||||
if (ret < 0) {
|
|
||||||
JS_FreeValue(ctx, obj1);
|
|
||||||
JS_FreeValue(ctx, val);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
if (ret) {
|
|
||||||
if (desc.flags & JS_PROP_GETSET) {
|
|
||||||
JSObject *setter;
|
|
||||||
if (JS_IsUndefined(desc.setter))
|
|
||||||
setter = NULL;
|
|
||||||
else
|
|
||||||
setter = JS_VALUE_GET_OBJ(desc.setter);
|
|
||||||
ret = call_setter(ctx, setter, this_obj, val, flags);
|
|
||||||
JS_FreeValue(ctx, desc.getter);
|
|
||||||
JS_FreeValue(ctx, desc.setter);
|
|
||||||
JS_FreeValue(ctx, obj1);
|
|
||||||
return ret;
|
|
||||||
} else {
|
|
||||||
JS_FreeValue(ctx, desc.value);
|
|
||||||
if (!(desc.flags & JS_PROP_WRITABLE)) {
|
|
||||||
JS_FreeValue(ctx, obj1);
|
|
||||||
goto read_only_error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/* Note: at this point 'obj1' cannot be a proxy. XXX: may have
|
|
||||||
to check recursion */
|
|
||||||
obj1 = JS_GetPrototypeFree(ctx, obj1);
|
|
||||||
if (JS_IsNull(obj1))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
JS_FreeValue(ctx, obj1);
|
|
||||||
|
|
||||||
if (!JS_IsObject(this_obj)) {
|
|
||||||
JS_FreeValue(ctx, val);
|
|
||||||
return JS_ThrowTypeErrorOrFalse(ctx, flags, "receiver is not an object");
|
|
||||||
}
|
|
||||||
|
|
||||||
p = JS_VALUE_GET_OBJ(this_obj);
|
|
||||||
|
|
||||||
/* modify the property in this_obj if it already exists */
|
|
||||||
ret = JS_GetOwnPropertyInternal(ctx, &desc, p, prop);
|
|
||||||
if (ret < 0) {
|
|
||||||
JS_FreeValue(ctx, val);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
if (ret) {
|
|
||||||
if (desc.flags & JS_PROP_GETSET) {
|
|
||||||
JS_FreeValue(ctx, desc.getter);
|
|
||||||
JS_FreeValue(ctx, desc.setter);
|
|
||||||
JS_FreeValue(ctx, val);
|
|
||||||
return JS_ThrowTypeErrorOrFalse(ctx, flags, "setter is forbidden");
|
|
||||||
} else {
|
|
||||||
JS_FreeValue(ctx, desc.value);
|
|
||||||
if (!(desc.flags & JS_PROP_WRITABLE) ||
|
|
||||||
p->class_id == JS_CLASS_MODULE_NS) {
|
|
||||||
read_only_error:
|
|
||||||
JS_FreeValue(ctx, val);
|
|
||||||
return JS_ThrowTypeErrorReadOnly(ctx, flags, prop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ret = JS_DefineProperty(ctx, this_obj, prop, val,
|
|
||||||
JS_UNDEFINED, JS_UNDEFINED,
|
|
||||||
JS_PROP_HAS_VALUE);
|
|
||||||
JS_FreeValue(ctx, val);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = JS_CreateProperty(ctx, p, prop, val, JS_UNDEFINED, JS_UNDEFINED,
|
|
||||||
flags |
|
|
||||||
JS_PROP_HAS_VALUE |
|
|
||||||
JS_PROP_HAS_ENUMERABLE |
|
|
||||||
JS_PROP_HAS_WRITABLE |
|
|
||||||
JS_PROP_HAS_CONFIGURABLE |
|
|
||||||
JS_PROP_C_W_E);
|
|
||||||
JS_FreeValue(ctx, val);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* return -1 in case of exception or TRUE or FALSE. Warning: 'val' is
|
/* return -1 in case of exception or TRUE or FALSE. Warning: 'val' is
|
||||||
freed by the function. 'flags' is a bitmask of JS_PROP_NO_ADD,
|
freed by the function. 'flags' is a bitmask of JS_PROP_NO_ADD,
|
||||||
JS_PROP_THROW or JS_PROP_THROW_STRICT. If JS_PROP_NO_ADD is set,
|
JS_PROP_THROW or JS_PROP_THROW_STRICT. If JS_PROP_NO_ADD is set,
|
||||||
the new property is not added and an error is raised. */
|
the new property is not added and an error is raised. 'this_obj' is
|
||||||
int JS_SetPropertyInternal(JSContext *ctx, JSValueConst this_obj,
|
the receiver. If obj != this_obj, then obj must be an object
|
||||||
JSAtom prop, JSValue val, int flags)
|
(Reflect.set case). */
|
||||||
|
int JS_SetPropertyInternal(JSContext *ctx, JSValueConst obj,
|
||||||
|
JSAtom prop, JSValue val, JSValueConst this_obj, int flags)
|
||||||
{
|
{
|
||||||
JSObject *p, *p1;
|
JSObject *p, *p1;
|
||||||
JSShapeProperty *prs;
|
JSShapeProperty *prs;
|
||||||
@ -8418,25 +8313,37 @@ int JS_SetPropertyInternal(JSContext *ctx, JSValueConst this_obj,
|
|||||||
#endif
|
#endif
|
||||||
tag = JS_VALUE_GET_TAG(this_obj);
|
tag = JS_VALUE_GET_TAG(this_obj);
|
||||||
if (unlikely(tag != JS_TAG_OBJECT)) {
|
if (unlikely(tag != JS_TAG_OBJECT)) {
|
||||||
switch(tag) {
|
if (JS_VALUE_GET_TAG(obj) == JS_TAG_OBJECT) {
|
||||||
case JS_TAG_NULL:
|
|
||||||
JS_FreeValue(ctx, val);
|
|
||||||
JS_ThrowTypeErrorAtom(ctx, "cannot set property '%s' of null", prop);
|
|
||||||
return -1;
|
|
||||||
case JS_TAG_UNDEFINED:
|
|
||||||
JS_FreeValue(ctx, val);
|
|
||||||
JS_ThrowTypeErrorAtom(ctx, "cannot set property '%s' of undefined", prop);
|
|
||||||
return -1;
|
|
||||||
default:
|
|
||||||
/* even on a primitive type we can have setters on the prototype */
|
|
||||||
p = NULL;
|
p = NULL;
|
||||||
p1 = JS_VALUE_GET_OBJ(JS_GetPrototypePrimitive(ctx, this_obj));
|
p1 = JS_VALUE_GET_OBJ(obj);
|
||||||
goto prototype_lookup;
|
goto prototype_lookup;
|
||||||
|
} else {
|
||||||
|
switch(tag) {
|
||||||
|
case JS_TAG_NULL:
|
||||||
|
JS_FreeValue(ctx, val);
|
||||||
|
JS_ThrowTypeErrorAtom(ctx, "cannot set property '%s' of null", prop);
|
||||||
|
return -1;
|
||||||
|
case JS_TAG_UNDEFINED:
|
||||||
|
JS_FreeValue(ctx, val);
|
||||||
|
JS_ThrowTypeErrorAtom(ctx, "cannot set property '%s' of undefined", prop);
|
||||||
|
return -1;
|
||||||
|
default:
|
||||||
|
/* even on a primitive type we can have setters on the prototype */
|
||||||
|
p = NULL;
|
||||||
|
p1 = JS_VALUE_GET_OBJ(JS_GetPrototypePrimitive(ctx, obj));
|
||||||
|
goto prototype_lookup;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
p = JS_VALUE_GET_OBJ(this_obj);
|
||||||
|
p1 = JS_VALUE_GET_OBJ(obj);
|
||||||
|
if (unlikely(p != p1))
|
||||||
|
goto retry2;
|
||||||
}
|
}
|
||||||
p = JS_VALUE_GET_OBJ(this_obj);
|
|
||||||
retry:
|
/* fast path if obj == this_obj */
|
||||||
prs = find_own_property(&pr, p, prop);
|
retry:
|
||||||
|
prs = find_own_property(&pr, p1, prop);
|
||||||
if (prs) {
|
if (prs) {
|
||||||
if (likely((prs->flags & (JS_PROP_TMASK | JS_PROP_WRITABLE |
|
if (likely((prs->flags & (JS_PROP_TMASK | JS_PROP_WRITABLE |
|
||||||
JS_PROP_LENGTH)) == JS_PROP_WRITABLE)) {
|
JS_PROP_LENGTH)) == JS_PROP_WRITABLE)) {
|
||||||
@ -8469,7 +8376,6 @@ retry:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p1 = p;
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
if (p1->is_exotic) {
|
if (p1->is_exotic) {
|
||||||
if (p1->fast_array) {
|
if (p1->fast_array) {
|
||||||
@ -8493,11 +8399,19 @@ retry:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
typed_array_oob:
|
typed_array_oob:
|
||||||
val = JS_ToNumberFree(ctx, val);
|
/* must convert the argument even if out of bound access */
|
||||||
JS_FreeValue(ctx, val);
|
if (p1->class_id == JS_CLASS_BIG_INT64_ARRAY ||
|
||||||
if (JS_IsException(val))
|
p1->class_id == JS_CLASS_BIG_UINT64_ARRAY) {
|
||||||
return -1;
|
int64_t v;
|
||||||
return JS_ThrowTypeErrorOrFalse(ctx, flags, "out-of-bound numeric index");
|
if (JS_ToBigInt64Free(ctx, &v, val))
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
val = JS_ToNumberFree(ctx, val);
|
||||||
|
JS_FreeValue(ctx, val);
|
||||||
|
if (JS_IsException(val))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -8569,9 +8483,7 @@ retry:
|
|||||||
return -1;
|
return -1;
|
||||||
goto retry2;
|
goto retry2;
|
||||||
} else if (!(prs->flags & JS_PROP_WRITABLE)) {
|
} else if (!(prs->flags & JS_PROP_WRITABLE)) {
|
||||||
read_only_prop:
|
goto read_only_prop;
|
||||||
JS_FreeValue(ctx, val);
|
|
||||||
return JS_ThrowTypeErrorReadOnly(ctx, flags, prop);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8592,16 +8504,56 @@ retry:
|
|||||||
return JS_ThrowTypeErrorOrFalse(ctx, flags, "object is not extensible");
|
return JS_ThrowTypeErrorOrFalse(ctx, flags, "object is not extensible");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->is_exotic) {
|
if (likely(p == JS_VALUE_GET_OBJ(obj))) {
|
||||||
if (p->class_id == JS_CLASS_ARRAY && p->fast_array &&
|
if (p->is_exotic) {
|
||||||
__JS_AtomIsTaggedInt(prop)) {
|
if (p->class_id == JS_CLASS_ARRAY && p->fast_array &&
|
||||||
uint32_t idx = __JS_AtomToUInt32(prop);
|
__JS_AtomIsTaggedInt(prop)) {
|
||||||
if (idx == p->u.array.count) {
|
uint32_t idx = __JS_AtomToUInt32(prop);
|
||||||
/* fast case */
|
if (idx == p->u.array.count) {
|
||||||
return add_fast_array_element(ctx, p, val, flags);
|
/* fast case */
|
||||||
|
return add_fast_array_element(ctx, p, val, flags);
|
||||||
|
} else {
|
||||||
|
goto generic_create_prop;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
goto generic_create_prop;
|
goto generic_create_prop;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
pr = add_property(ctx, p, prop, JS_PROP_C_W_E);
|
||||||
|
if (unlikely(!pr)) {
|
||||||
|
JS_FreeValue(ctx, val);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
pr->u.value = val;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* generic case: modify the property in this_obj if it already exists */
|
||||||
|
ret = JS_GetOwnPropertyInternal(ctx, &desc, p, prop);
|
||||||
|
if (ret < 0) {
|
||||||
|
JS_FreeValue(ctx, val);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
if (ret) {
|
||||||
|
if (desc.flags & JS_PROP_GETSET) {
|
||||||
|
JS_FreeValue(ctx, desc.getter);
|
||||||
|
JS_FreeValue(ctx, desc.setter);
|
||||||
|
JS_FreeValue(ctx, val);
|
||||||
|
return JS_ThrowTypeErrorOrFalse(ctx, flags, "setter is forbidden");
|
||||||
|
} else {
|
||||||
|
JS_FreeValue(ctx, desc.value);
|
||||||
|
if (!(desc.flags & JS_PROP_WRITABLE) ||
|
||||||
|
p->class_id == JS_CLASS_MODULE_NS) {
|
||||||
|
read_only_prop:
|
||||||
|
JS_FreeValue(ctx, val);
|
||||||
|
return JS_ThrowTypeErrorReadOnly(ctx, flags, prop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret = JS_DefineProperty(ctx, this_obj, prop, val,
|
||||||
|
JS_UNDEFINED, JS_UNDEFINED,
|
||||||
|
JS_PROP_HAS_VALUE);
|
||||||
|
JS_FreeValue(ctx, val);
|
||||||
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
generic_create_prop:
|
generic_create_prop:
|
||||||
ret = JS_CreateProperty(ctx, p, prop, val, JS_UNDEFINED, JS_UNDEFINED,
|
ret = JS_CreateProperty(ctx, p, prop, val, JS_UNDEFINED, JS_UNDEFINED,
|
||||||
@ -8615,14 +8567,6 @@ retry:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pr = add_property(ctx, p, prop, JS_PROP_C_W_E);
|
|
||||||
if (unlikely(!pr)) {
|
|
||||||
JS_FreeValue(ctx, val);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
pr->u.value = val;
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* flags can be JS_PROP_THROW or JS_PROP_THROW_STRICT */
|
/* flags can be JS_PROP_THROW or JS_PROP_THROW_STRICT */
|
||||||
@ -8731,7 +8675,7 @@ static int JS_SetPropertyValue(JSContext *ctx, JSValueConst this_obj,
|
|||||||
return -1;
|
return -1;
|
||||||
if (unlikely(idx >= (uint32_t)p->u.array.count)) {
|
if (unlikely(idx >= (uint32_t)p->u.array.count)) {
|
||||||
ta_out_of_bound:
|
ta_out_of_bound:
|
||||||
return JS_ThrowTypeErrorOrFalse(ctx, flags, "out-of-bound numeric index");
|
return TRUE;
|
||||||
}
|
}
|
||||||
p->u.array.u.double_ptr[idx] = d;
|
p->u.array.u.double_ptr[idx] = d;
|
||||||
break;
|
break;
|
||||||
@ -8749,7 +8693,7 @@ static int JS_SetPropertyValue(JSContext *ctx, JSValueConst this_obj,
|
|||||||
JS_FreeValue(ctx, val);
|
JS_FreeValue(ctx, val);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ret = JS_SetPropertyInternal(ctx, this_obj, atom, val, flags);
|
ret = JS_SetPropertyInternal(ctx, this_obj, atom, val, this_obj, flags);
|
||||||
JS_FreeAtom(ctx, atom);
|
JS_FreeAtom(ctx, atom);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -8789,7 +8733,7 @@ int JS_SetPropertyStr(JSContext *ctx, JSValueConst this_obj,
|
|||||||
JSAtom atom;
|
JSAtom atom;
|
||||||
int ret;
|
int ret;
|
||||||
atom = JS_NewAtom(ctx, prop);
|
atom = JS_NewAtom(ctx, prop);
|
||||||
ret = JS_SetPropertyInternal(ctx, this_obj, atom, val, JS_PROP_THROW);
|
ret = JS_SetPropertyInternal(ctx, this_obj, atom, val, this_obj, JS_PROP_THROW);
|
||||||
JS_FreeAtom(ctx, atom);
|
JS_FreeAtom(ctx, atom);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -9246,7 +9190,7 @@ int JS_DefineProperty(JSContext *ctx, JSValueConst this_obj,
|
|||||||
}
|
}
|
||||||
idx = __JS_AtomToUInt32(prop);
|
idx = __JS_AtomToUInt32(prop);
|
||||||
/* if the typed array is detached, p->u.array.count = 0 */
|
/* if the typed array is detached, p->u.array.count = 0 */
|
||||||
if (idx >= typed_array_get_length(ctx, p)) {
|
if (idx >= p->u.array.count) {
|
||||||
typed_array_oob:
|
typed_array_oob:
|
||||||
return JS_ThrowTypeErrorOrFalse(ctx, flags, "out-of-bound index in typed array");
|
return JS_ThrowTypeErrorOrFalse(ctx, flags, "out-of-bound index in typed array");
|
||||||
}
|
}
|
||||||
@ -9640,7 +9584,7 @@ static int JS_SetGlobalVar(JSContext *ctx, JSAtom prop, JSValue val,
|
|||||||
flags = JS_PROP_THROW_STRICT;
|
flags = JS_PROP_THROW_STRICT;
|
||||||
if (is_strict_mode(ctx))
|
if (is_strict_mode(ctx))
|
||||||
flags |= JS_PROP_NO_ADD;
|
flags |= JS_PROP_NO_ADD;
|
||||||
return JS_SetPropertyInternal(ctx, ctx->global_obj, prop, val, flags);
|
return JS_SetPropertyInternal(ctx, ctx->global_obj, prop, val, ctx->global_obj, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return -1, FALSE or TRUE. return FALSE if not configurable or
|
/* return -1, FALSE or TRUE. return FALSE if not configurable or
|
||||||
@ -14840,7 +14784,7 @@ static JSValue build_for_in_iterator(JSContext *ctx, JSValue obj)
|
|||||||
JS_GPN_STRING_MASK | JS_GPN_ENUM_ONLY))
|
JS_GPN_STRING_MASK | JS_GPN_ENUM_ONLY))
|
||||||
goto fail;
|
goto fail;
|
||||||
for(i = 0; i < tab_atom_count; i++) {
|
for(i = 0; i < tab_atom_count; i++) {
|
||||||
JS_SetPropertyInternal(ctx, enum_obj, tab_atom[i].atom, JS_NULL, 0);
|
JS_SetPropertyInternal(ctx, enum_obj, tab_atom[i].atom, JS_NULL, enum_obj, 0);
|
||||||
}
|
}
|
||||||
js_free_prop_enum(ctx, tab_atom, tab_atom_count);
|
js_free_prop_enum(ctx, tab_atom, tab_atom_count);
|
||||||
}
|
}
|
||||||
@ -17260,7 +17204,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
|
|||||||
atom = get_u32(pc);
|
atom = get_u32(pc);
|
||||||
pc += 4;
|
pc += 4;
|
||||||
|
|
||||||
ret = JS_SetPropertyInternal(ctx, sp[-2], atom, sp[-1],
|
ret = JS_SetPropertyInternal(ctx, sp[-2], atom, sp[-1], sp[-2],
|
||||||
JS_PROP_THROW_STRICT);
|
JS_PROP_THROW_STRICT);
|
||||||
JS_FreeValue(ctx, sp[-2]);
|
JS_FreeValue(ctx, sp[-2]);
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
@ -17559,8 +17503,8 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
|
|||||||
atom = JS_ValueToAtom(ctx, sp[-2]);
|
atom = JS_ValueToAtom(ctx, sp[-2]);
|
||||||
if (unlikely(atom == JS_ATOM_NULL))
|
if (unlikely(atom == JS_ATOM_NULL))
|
||||||
goto exception;
|
goto exception;
|
||||||
ret = JS_SetPropertyGeneric(ctx, sp[-3], atom, sp[-1], sp[-4],
|
ret = JS_SetPropertyInternal(ctx, sp[-3], atom, sp[-1], sp[-4],
|
||||||
JS_PROP_THROW_STRICT);
|
JS_PROP_THROW_STRICT);
|
||||||
JS_FreeAtom(ctx, atom);
|
JS_FreeAtom(ctx, atom);
|
||||||
JS_FreeValue(ctx, sp[-4]);
|
JS_FreeValue(ctx, sp[-4]);
|
||||||
JS_FreeValue(ctx, sp[-3]);
|
JS_FreeValue(ctx, sp[-3]);
|
||||||
@ -18239,7 +18183,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
|
|||||||
break;
|
break;
|
||||||
case OP_with_put_var:
|
case OP_with_put_var:
|
||||||
/* XXX: check if strict mode */
|
/* XXX: check if strict mode */
|
||||||
ret = JS_SetPropertyInternal(ctx, obj, atom, sp[-2],
|
ret = JS_SetPropertyInternal(ctx, obj, atom, sp[-2], obj,
|
||||||
JS_PROP_THROW_STRICT);
|
JS_PROP_THROW_STRICT);
|
||||||
JS_FreeValue(ctx, sp[-1]);
|
JS_FreeValue(ctx, sp[-1]);
|
||||||
sp -= 2;
|
sp -= 2;
|
||||||
@ -44112,8 +44056,8 @@ static JSValue js_reflect_set(JSContext *ctx, JSValueConst this_val,
|
|||||||
atom = JS_ValueToAtom(ctx, prop);
|
atom = JS_ValueToAtom(ctx, prop);
|
||||||
if (unlikely(atom == JS_ATOM_NULL))
|
if (unlikely(atom == JS_ATOM_NULL))
|
||||||
return JS_EXCEPTION;
|
return JS_EXCEPTION;
|
||||||
ret = JS_SetPropertyGeneric(ctx, obj, atom,
|
ret = JS_SetPropertyInternal(ctx, obj, atom,
|
||||||
JS_DupValue(ctx, val), receiver, 0);
|
JS_DupValue(ctx, val), receiver, 0);
|
||||||
JS_FreeAtom(ctx, atom);
|
JS_FreeAtom(ctx, atom);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return JS_EXCEPTION;
|
return JS_EXCEPTION;
|
||||||
@ -44460,9 +44404,9 @@ static int js_proxy_set(JSContext *ctx, JSValueConst obj, JSAtom atom,
|
|||||||
if (!s)
|
if (!s)
|
||||||
return -1;
|
return -1;
|
||||||
if (JS_IsUndefined(method)) {
|
if (JS_IsUndefined(method)) {
|
||||||
return JS_SetPropertyGeneric(ctx, s->target, atom,
|
return JS_SetPropertyInternal(ctx, s->target, atom,
|
||||||
JS_DupValue(ctx, value), receiver,
|
JS_DupValue(ctx, value), receiver,
|
||||||
flags);
|
flags);
|
||||||
}
|
}
|
||||||
atom_val = JS_AtomToValue(ctx, atom);
|
atom_val = JS_AtomToValue(ctx, atom);
|
||||||
if (JS_IsException(atom_val)) {
|
if (JS_IsException(atom_val)) {
|
||||||
@ -51483,7 +51427,7 @@ static JSValue js_typed_array_at(JSContext *ctx, JSValueConst this_val,
|
|||||||
idx = len + idx;
|
idx = len + idx;
|
||||||
if (idx < 0 || idx >= len)
|
if (idx < 0 || idx >= len)
|
||||||
return JS_UNDEFINED;
|
return JS_UNDEFINED;
|
||||||
return JS_GetPropertyUint32(ctx, this_val, idx);
|
return JS_GetPropertyInt64(ctx, this_val, idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSValue js_typed_array_set(JSContext *ctx,
|
static JSValue js_typed_array_set(JSContext *ctx,
|
||||||
|
@ -733,13 +733,13 @@ JSValue JS_GetPropertyStr(JSContext *ctx, JSValueConst this_obj,
|
|||||||
JSValue JS_GetPropertyUint32(JSContext *ctx, JSValueConst this_obj,
|
JSValue JS_GetPropertyUint32(JSContext *ctx, JSValueConst this_obj,
|
||||||
uint32_t idx);
|
uint32_t idx);
|
||||||
|
|
||||||
int JS_SetPropertyInternal(JSContext *ctx, JSValueConst this_obj,
|
int JS_SetPropertyInternal(JSContext *ctx, JSValueConst obj,
|
||||||
JSAtom prop, JSValue val,
|
JSAtom prop, JSValue val, JSValueConst this_obj,
|
||||||
int flags);
|
int flags);
|
||||||
static inline int JS_SetProperty(JSContext *ctx, JSValueConst this_obj,
|
static inline int JS_SetProperty(JSContext *ctx, JSValueConst this_obj,
|
||||||
JSAtom prop, JSValue val)
|
JSAtom prop, JSValue val)
|
||||||
{
|
{
|
||||||
return JS_SetPropertyInternal(ctx, this_obj, prop, val, JS_PROP_THROW);
|
return JS_SetPropertyInternal(ctx, this_obj, prop, val, this_obj, JS_PROP_THROW);
|
||||||
}
|
}
|
||||||
int JS_SetPropertyUint32(JSContext *ctx, JSValueConst this_obj,
|
int JS_SetPropertyUint32(JSContext *ctx, JSValueConst this_obj,
|
||||||
uint32_t idx, JSValue val);
|
uint32_t idx, JSValue val);
|
||||||
|
@ -13,41 +13,10 @@ test262/test/built-ins/RegExp/unicode_full_case_folding.js:20: Test262Error: \u0
|
|||||||
test262/test/built-ins/RegExp/unicode_full_case_folding.js:20: strict mode: Test262Error: \u0390 does not match \u1fd3
|
test262/test/built-ins/RegExp/unicode_full_case_folding.js:20: strict mode: Test262Error: \u0390 does not match \u1fd3
|
||||||
test262/test/built-ins/String/prototype/localeCompare/15.5.4.9_CE.js:62: Test262Error: String.prototype.localeCompare considers ö (\u006f\u0308) ≠ ö (\u00f6).
|
test262/test/built-ins/String/prototype/localeCompare/15.5.4.9_CE.js:62: Test262Error: String.prototype.localeCompare considers ö (\u006f\u0308) ≠ ö (\u00f6).
|
||||||
test262/test/built-ins/String/prototype/localeCompare/15.5.4.9_CE.js:62: strict mode: Test262Error: String.prototype.localeCompare considers ö (\u006f\u0308) ≠ ö (\u00f6).
|
test262/test/built-ins/String/prototype/localeCompare/15.5.4.9_CE.js:62: strict mode: Test262Error: String.prototype.localeCompare considers ö (\u006f\u0308) ≠ ö (\u00f6).
|
||||||
test262/test/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js:30: TypeError: out-of-bound numeric index (Testing with Float64Array.)
|
|
||||||
test262/test/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js:30: strict mode: TypeError: out-of-bound numeric index (Testing with Float64Array.)
|
|
||||||
test262/test/built-ins/TypedArray/prototype/sort/sort-tonumber.js:30: TypeError: ArrayBuffer is detached (Testing with Float64Array.)
|
test262/test/built-ins/TypedArray/prototype/sort/sort-tonumber.js:30: TypeError: ArrayBuffer is detached (Testing with Float64Array.)
|
||||||
test262/test/built-ins/TypedArray/prototype/sort/sort-tonumber.js:30: strict mode: TypeError: ArrayBuffer is detached (Testing with Float64Array.)
|
test262/test/built-ins/TypedArray/prototype/sort/sort-tonumber.js:30: strict mode: TypeError: ArrayBuffer is detached (Testing with Float64Array.)
|
||||||
test262/test/built-ins/TypedArrayConstructors/ctors/no-species.js:16: Test262Error: unreachable
|
test262/test/built-ins/TypedArrayConstructors/ctors/no-species.js:16: Test262Error: unreachable
|
||||||
test262/test/built-ins/TypedArrayConstructors/ctors/no-species.js:16: strict mode: Test262Error: unreachable
|
test262/test/built-ins/TypedArrayConstructors/ctors/no-species.js:16: strict mode: Test262Error: unreachable
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer.js:46: Test262Error: (Testing with BigInt64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer.js:46: strict mode: Test262Error: (Testing with BigInt64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/tonumber-value-detached-buffer.js:40: Test262Error: Reflect.defineProperty(ta, 0, {value: {valueOf() {$DETACHBUFFER(ta.buffer); return 42n;}}}) must return true Expected SameValue(«false», «true») to be true (Testing with BigInt64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/tonumber-value-detached-buffer.js:40: strict mode: Test262Error: Reflect.defineProperty(ta, 0, {value: {valueOf() {$DETACHBUFFER(ta.buffer); return 42n;}}}) must return true Expected SameValue(«false», «true») to be true (Testing with BigInt64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer.js:47: Test262Error: (Testing with Float64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer.js:47: strict mode: Test262Error: (Testing with Float64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/tonumber-value-detached-buffer.js:42: Test262Error: Reflect.defineProperty(ta, 0, {value: {valueOf() {$DETACHBUFFER(ta.buffer); return 42;}}} ) must return true Expected SameValue(«false», «true») to be true (Testing with Float64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/tonumber-value-detached-buffer.js:42: strict mode: Test262Error: Reflect.defineProperty(ta, 0, {value: {valueOf() {$DETACHBUFFER(ta.buffer); return 42;}}} ) must return true Expected SameValue(«false», «true») to be true (Testing with Float64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/detached-buffer-realm.js:37: strict mode: TypeError: out-of-bound numeric index (Testing with BigInt64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/detached-buffer.js:34: TypeError: cannot convert bigint to number (Testing with BigInt64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/detached-buffer.js:32: strict mode: TypeError: out-of-bound numeric index (Testing with BigInt64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-minus-zero.js:20: Test262Error: Reflect.set("new TA([42n])", "-0", 1n) must return true Expected SameValue(«false», «true») to be true (Testing with BigInt64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-minus-zero.js:20: strict mode: Test262Error: Reflect.set("new TA([42n])", "-0", 1n) must return true Expected SameValue(«false», «true») to be true (Testing with BigInt64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-not-integer.js:21: Test262Error: Reflect.set("new TA([42n])", "1.1", 1n) must return true Expected SameValue(«false», «true») to be true (Testing with BigInt64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-not-integer.js:21: strict mode: Test262Error: Reflect.set("new TA([42n])", "1.1", 1n) must return true Expected SameValue(«false», «true») to be true (Testing with BigInt64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-out-of-bounds.js:27: Test262Error: Reflect.set("new TA([42n])", "-1", 1n) must return false Expected SameValue(«false», «true») to be true (Testing with BigInt64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/key-is-out-of-bounds.js:27: strict mode: Test262Error: Reflect.set("new TA([42n])", "-1", 1n) must return false Expected SameValue(«false», «true») to be true (Testing with BigInt64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/tonumber-value-detached-buffer.js:24: Test262Error: Expected SameValue(«false», «true») to be true (Testing with BigInt64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/tonumber-value-detached-buffer.js:24: strict mode: Test262Error: Expected SameValue(«false», «true») to be true (Testing with BigInt64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/Set/detached-buffer-realm.js:37: strict mode: TypeError: out-of-bound numeric index (Testing with Float64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/Set/detached-buffer.js:32: strict mode: TypeError: out-of-bound numeric index (Testing with Float64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/Set/key-is-minus-zero.js:22: Test262Error: Reflect.set(sample, "-0", 1) must return true Expected SameValue(«false», «true») to be true (Testing with Float64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/Set/key-is-minus-zero.js:22: strict mode: Test262Error: Reflect.set(sample, "-0", 1) must return true Expected SameValue(«false», «true») to be true (Testing with Float64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/Set/key-is-not-integer.js:22: Test262Error: Reflect.set(sample, "1.1", 1) must return true Expected SameValue(«false», «true») to be true (Testing with Float64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/Set/key-is-not-integer.js:22: strict mode: Test262Error: Reflect.set(sample, "1.1", 1) must return true Expected SameValue(«false», «true») to be true (Testing with Float64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/Set/key-is-out-of-bounds.js:22: Test262Error: Reflect.set(sample, "-1", 1) must return true Expected SameValue(«false», «true») to be true (Testing with Float64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/Set/key-is-out-of-bounds.js:22: strict mode: Test262Error: Reflect.set(sample, "-1", 1) must return true Expected SameValue(«false», «true») to be true (Testing with Float64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/Set/tonumber-value-detached-buffer.js:39: Test262Error: Expected SameValue(«false», «true») to be true (Testing with Float64Array.)
|
|
||||||
test262/test/built-ins/TypedArrayConstructors/internals/Set/tonumber-value-detached-buffer.js:39: strict mode: Test262Error: Expected SameValue(«false», «true») to be true (Testing with Float64Array.)
|
|
||||||
test262/test/language/expressions/assignment/target-member-computed-reference-null.js:32: Test262Error: Expected a DummyError but got a TypeError
|
test262/test/language/expressions/assignment/target-member-computed-reference-null.js:32: Test262Error: Expected a DummyError but got a TypeError
|
||||||
test262/test/language/expressions/assignment/target-member-computed-reference-null.js:32: strict mode: Test262Error: Expected a DummyError but got a TypeError
|
test262/test/language/expressions/assignment/target-member-computed-reference-null.js:32: strict mode: Test262Error: Expected a DummyError but got a TypeError
|
||||||
test262/test/language/expressions/assignment/target-member-computed-reference-undefined.js:32: Test262Error: Expected a DummyError but got a TypeError
|
test262/test/language/expressions/assignment/target-member-computed-reference-undefined.js:32: Test262Error: Expected a DummyError but got a TypeError
|
||||||
|
Loading…
Reference in New Issue
Block a user