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:
@@ -22,6 +22,8 @@
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-objects-general.h"
|
||||
#include "ecma-string-object.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "jcontext.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -60,12 +62,24 @@ ecma_op_create_string_object (const ecma_value_t *arguments_list_p, /**< list of
|
||||
prim_value = ecma_make_string_value (str_p);
|
||||
}
|
||||
|
||||
ecma_builtin_id_t proto_id;
|
||||
#if ENABLED (JERRY_BUILTIN_STRING)
|
||||
ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_STRING_PROTOTYPE);
|
||||
proto_id = ECMA_BUILTIN_ID_STRING_PROTOTYPE;
|
||||
#else /* !ENABLED (JERRY_BUILTIN_STRING) */
|
||||
ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE);
|
||||
proto_id = ECMA_BUILTIN_ID_OBJECT_PROTOTYPE;
|
||||
#endif /* ENABLED (JERRY_BUILTIN_STRING) */
|
||||
|
||||
ecma_object_t *prototype_obj_p = ecma_builtin_get (proto_id);
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ecma_object_t *new_target = JERRY_CONTEXT (current_new_target);
|
||||
if (new_target)
|
||||
{
|
||||
prototype_obj_p = ecma_op_get_prototype_from_constructor (new_target, proto_id);
|
||||
if (JERRY_UNLIKELY (prototype_obj_p == NULL))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
ecma_object_t *object_p = ecma_create_object (prototype_obj_p,
|
||||
sizeof (ecma_extended_object_t),
|
||||
ECMA_OBJECT_TYPE_CLASS);
|
||||
@@ -74,6 +88,12 @@ ecma_op_create_string_object (const ecma_value_t *arguments_list_p, /**< list of
|
||||
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_STRING_UL;
|
||||
ext_object_p->u.class_prop.u.value = prim_value;
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (new_target)
|
||||
{
|
||||
ecma_deref_object (prototype_obj_p);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
return ecma_make_object_value (object_p);
|
||||
} /* ecma_op_create_string_object */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user