mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Rework the Reflect.defineProperty method (#3770)
Also a minor update to the FromPropertyDescriptor operation since in ES6 we can use a property descriptor whitout any keys JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
This commit is contained in:
parent
1105b43c22
commit
ecf159795a
@ -261,20 +261,32 @@ ecma_builtin_reflect_dispatch_routine (uint16_t builtin_routine_id, /**< built-i
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_value_t result = ecma_builtin_object_object_define_property (obj_p, name_str_p, arguments_list[2]);
|
||||
ecma_property_descriptor_t prop_desc;
|
||||
ecma_value_t conv_result = ecma_op_to_property_descriptor (arguments_list[2], &prop_desc);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (conv_result))
|
||||
{
|
||||
ecma_deref_ecma_string (name_str_p);
|
||||
return conv_result;
|
||||
}
|
||||
|
||||
prop_desc.flags |= ECMA_PROP_IS_THROW;
|
||||
|
||||
ecma_value_t result = ecma_op_object_define_own_property (obj_p,
|
||||
name_str_p,
|
||||
&prop_desc);
|
||||
|
||||
ecma_deref_ecma_string (name_str_p);
|
||||
bool is_error = ECMA_IS_VALUE_ERROR (result);
|
||||
ecma_free_property_descriptor (&prop_desc);
|
||||
|
||||
if (is_error)
|
||||
if (ECMA_IS_VALUE_ERROR (result))
|
||||
{
|
||||
jcontext_release_exception ();
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_free_value (result);
|
||||
return result;
|
||||
}
|
||||
|
||||
return ecma_make_boolean_value (!is_error);
|
||||
bool boolean_result = ecma_op_to_boolean (result);
|
||||
|
||||
return ecma_make_boolean_value (boolean_result);
|
||||
}
|
||||
case ECMA_REFLECT_OBJECT_GET_OWN_PROPERTY_DESCRIPTOR:
|
||||
{
|
||||
|
||||
@ -594,38 +594,42 @@ ecma_op_from_property_descriptor (const ecma_property_descriptor_t *src_prop_des
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 4. */
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
JERRY_ASSERT (src_prop_desc_p->flags & (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED));
|
||||
|
||||
/* a. */
|
||||
if (src_prop_desc_p->get_p == NULL)
|
||||
#else /* ENABLED (JERRY_ES2015) */
|
||||
if (src_prop_desc_p->flags & (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED))
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
{
|
||||
prop_desc.value = ECMA_VALUE_UNDEFINED;
|
||||
}
|
||||
else
|
||||
{
|
||||
prop_desc.value = ecma_make_object_value (src_prop_desc_p->get_p);
|
||||
}
|
||||
/* a. */
|
||||
if (src_prop_desc_p->get_p == NULL)
|
||||
{
|
||||
prop_desc.value = ECMA_VALUE_UNDEFINED;
|
||||
}
|
||||
else
|
||||
{
|
||||
prop_desc.value = ecma_make_object_value (src_prop_desc_p->get_p);
|
||||
}
|
||||
|
||||
completion = ecma_op_object_define_own_property (obj_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_GET),
|
||||
&prop_desc);
|
||||
JERRY_ASSERT (ecma_is_value_true (completion));
|
||||
completion = ecma_op_object_define_own_property (obj_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_GET),
|
||||
&prop_desc);
|
||||
JERRY_ASSERT (ecma_is_value_true (completion));
|
||||
|
||||
/* b. */
|
||||
if (src_prop_desc_p->set_p == NULL)
|
||||
{
|
||||
prop_desc.value = ECMA_VALUE_UNDEFINED;
|
||||
}
|
||||
else
|
||||
{
|
||||
prop_desc.value = ecma_make_object_value (src_prop_desc_p->set_p);
|
||||
}
|
||||
/* b. */
|
||||
if (src_prop_desc_p->set_p == NULL)
|
||||
{
|
||||
prop_desc.value = ECMA_VALUE_UNDEFINED;
|
||||
}
|
||||
else
|
||||
{
|
||||
prop_desc.value = ecma_make_object_value (src_prop_desc_p->set_p);
|
||||
}
|
||||
|
||||
completion = ecma_op_object_define_own_property (obj_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_SET),
|
||||
&prop_desc);
|
||||
JERRY_ASSERT (ecma_is_value_true (completion));
|
||||
completion = ecma_op_object_define_own_property (obj_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_SET),
|
||||
&prop_desc);
|
||||
JERRY_ASSERT (ecma_is_value_true (completion));
|
||||
}
|
||||
}
|
||||
|
||||
prop_desc.value = ecma_make_boolean_value (src_prop_desc_p->flags & ECMA_PROP_IS_ENUMERABLE);
|
||||
|
||||
@ -161,7 +161,6 @@
|
||||
<test id="built-ins/Promise/reject/name.js"><reason></reason></test>
|
||||
<test id="built-ins/Promise/resolve/name.js"><reason></reason></test>
|
||||
<test id="built-ins/Promise/symbol-species-name.js"><reason></reason></test>
|
||||
<test id="built-ins/Proxy/defineProperty/trap-return-is-false.js"><reason></reason></test>
|
||||
<test id="built-ins/Proxy/enumerate/call-parameters.js"><reason></reason></test>
|
||||
<test id="built-ins/Proxy/enumerate/return-is-abrupt.js"><reason></reason></test>
|
||||
<test id="built-ins/Proxy/enumerate/return-trap-result.js"><reason></reason></test>
|
||||
@ -175,8 +174,6 @@
|
||||
<test id="built-ins/Reflect/apply/name.js"><reason></reason></test>
|
||||
<test id="built-ins/Reflect/construct/name.js"><reason></reason></test>
|
||||
<test id="built-ins/Reflect/defineProperty/name.js"><reason></reason></test>
|
||||
<test id="built-ins/Reflect/defineProperty/return-abrupt-from-attributes.js"><reason></reason></test>
|
||||
<test id="built-ins/Reflect/defineProperty/return-abrupt-from-result.js"><reason></reason></test>
|
||||
<test id="built-ins/Reflect/deleteProperty/name.js"><reason></reason></test>
|
||||
<test id="built-ins/Reflect/enumerate/does-not-iterate-over-symbol-properties.js"><reason></reason></test>
|
||||
<test id="built-ins/Reflect/enumerate/enumerate.js"><reason></reason></test>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user