Added new target support to Boolean, String, Number Object (#4368)

JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
This commit is contained in:
kisbg
2020-12-17 09:44:59 +01:00
committed by GitHub
parent e2be8f4c79
commit 1937f820e1
9 changed files with 211 additions and 17 deletions
+39 -5
View File
@@ -531,14 +531,22 @@ ecma_value_t
ecma_op_to_object (ecma_value_t value) /**< ecma value */
{
ecma_check_value_type_is_spec_defined (value);
ecma_builtin_id_t proto_id = ECMA_BUILTIN_ID_OBJECT_PROTOTYPE;
uint16_t lit_id;
if (ecma_is_value_number (value))
{
return ecma_op_create_number_object (value);
#if ENABLED (JERRY_BUILTIN_NUMBER)
proto_id = ECMA_BUILTIN_ID_NUMBER_PROTOTYPE;
#endif /* ENABLED (JERRY_BUILTIN_NUMBER) */
lit_id = LIT_MAGIC_STRING_NUMBER_UL;
}
else if (ecma_is_value_string (value))
{
return ecma_op_create_string_object (&value, 1);
#if ENABLED (JERRY_BUILTIN_STRING)
proto_id = ECMA_BUILTIN_ID_STRING_PROTOTYPE;
#endif /* ENABLED (JERRY_BUILTIN_STRING) */
lit_id = LIT_MAGIC_STRING_STRING_UL;
}
else if (ecma_is_value_object (value))
{
@@ -547,7 +555,8 @@ ecma_op_to_object (ecma_value_t value) /**< ecma value */
#if ENABLED (JERRY_ESNEXT)
else if (ecma_is_value_symbol (value))
{
return ecma_op_create_symbol_object (value);
proto_id = ECMA_BUILTIN_ID_SYMBOL_PROTOTYPE;
lit_id = LIT_MAGIC_STRING_SYMBOL_UL;
}
#endif /* ENABLED (JERRY_ESNEXT) */
#if ENABLED (JERRY_BUILTIN_BIGINT)
@@ -566,12 +575,37 @@ ecma_op_to_object (ecma_value_t value) /**< ecma value */
else
{
JERRY_ASSERT (ecma_is_value_boolean (value));
return ecma_op_create_boolean_object (value);
#if ENABLED (JERRY_BUILTIN_BOOLEAN)
proto_id = ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE;
#endif /* ENABLED (JERRY_BUILTIN_BOOLEAN) */
lit_id = LIT_MAGIC_STRING_BOOLEAN_UL;
}
}
return ecma_op_create_class_object (proto_id, value, lit_id);
} /* ecma_op_to_object */
/**
* Create a ECMA_OBJECT_TYPE_CLASS object from the given arguments.
*
* @return ecma_value - constructed object
*/
ecma_value_t
ecma_op_create_class_object (ecma_builtin_id_t proto_id, /**< prototype id */
ecma_value_t value, /**< ecma value */
uint16_t class_id) /**< magic string id */
{
ecma_object_t *object_p = ecma_create_object (ecma_builtin_get (proto_id),
sizeof (ecma_extended_object_t),
ECMA_OBJECT_TYPE_CLASS);
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
ext_object_p->u.class_prop.class_id = class_id;
ext_object_p->u.class_prop.u.value = ecma_copy_value_if_not_object (value);
return ecma_make_object_value (object_p);
} /* ecma_op_create_class_object */
/**
* FromPropertyDescriptor operation.
*