Implement ToPropertyKey operation (#3966)

From ES 6 the ToPropertyKey operation is used to convert elements to a valid property key.
This "new" method uses the ToPrimitive operation which can call the `@@ToPrimitive`
well-known symbol to convert the given element to a key.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.usz@partner.samsung.com
This commit is contained in:
Péter Gál
2020-07-06 15:17:18 +02:00
committed by GitHub
parent ed9e3eccf9
commit ae5cfae3e7
10 changed files with 174 additions and 30 deletions
@@ -96,8 +96,8 @@ ecma_builtin_reflect_dispatch_routine (uint16_t builtin_routine_id, /**< built-i
}
/* 2. */
ecma_string_t *name_str_p = ecma_op_to_prop_name (((arguments_number > 1) ? arguments_list[1]
: ECMA_VALUE_UNDEFINED));
ecma_string_t *name_str_p = ecma_op_to_property_key (((arguments_number > 1) ? arguments_list[1]
: ECMA_VALUE_UNDEFINED));
/* 3. */
if (name_str_p == NULL)
@@ -262,7 +262,7 @@ ecma_builtin_reflect_dispatch_routine (uint16_t builtin_routine_id, /**< built-i
case ECMA_REFLECT_OBJECT_DEFINE_PROPERTY:
{
ecma_object_t *obj_p = ecma_get_object_from_value (arguments_list[0]);
ecma_string_t *name_str_p = ecma_op_to_prop_name (arguments_list[1]);
ecma_string_t *name_str_p = ecma_op_to_property_key (arguments_list[1]);
if (name_str_p == NULL)
{
@@ -297,7 +297,7 @@ ecma_builtin_reflect_dispatch_routine (uint16_t builtin_routine_id, /**< built-i
case ECMA_REFLECT_OBJECT_GET_OWN_PROPERTY_DESCRIPTOR:
{
ecma_object_t *obj_p = ecma_get_object_from_value (arguments_list[0]);
ecma_string_t *name_str_p = ecma_op_to_prop_name (arguments_list[1]);
ecma_string_t *name_str_p = ecma_op_to_property_key (arguments_list[1]);
if (name_str_p == NULL)
{