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
@@ -284,7 +284,7 @@ ecma_builtin_object_prototype_dispatch_routine (uint16_t builtin_routine_id, /**
}
#endif /* ENABLED (JERRY_ESNEXT)*/
ecma_string_t *prop_name_p = ecma_op_to_prop_name (arguments_list_p[0]);
ecma_string_t *prop_name_p = ecma_op_to_property_key (arguments_list_p[0]);
if (prop_name_p == NULL)
{
@@ -1213,7 +1213,7 @@ ecma_builtin_object_dispatch_routine (uint16_t builtin_routine_id, /**< built-in
if (builtin_routine_id == ECMA_OBJECT_ROUTINE_DEFINE_PROPERTY)
{
ecma_string_t *prop_name_p = ecma_op_to_prop_name (arg2);
ecma_string_t *prop_name_p = ecma_op_to_property_key (arg2);
if (prop_name_p == NULL)
{
@@ -1275,7 +1275,7 @@ ecma_builtin_object_dispatch_routine (uint16_t builtin_routine_id, /**< built-in
}
case ECMA_OBJECT_ROUTINE_GET_OWN_PROPERTY_DESCRIPTOR:
{
ecma_string_t *prop_name_p = ecma_op_to_prop_name (arg2);
ecma_string_t *prop_name_p = ecma_op_to_property_key (arg2);
if (prop_name_p == NULL)
{
@@ -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)
{