Add new target support for object create (#4203)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
#include "ecma-iterator-object.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "jcontext.h"
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
@@ -103,13 +104,11 @@ ecma_value_t
|
||||
ecma_builtin_object_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
if (arguments_list_len == 0
|
||||
|| ecma_is_value_undefined (arguments_list_p[0])
|
||||
|| ecma_is_value_null (arguments_list_p[0]))
|
||||
{
|
||||
return ecma_builtin_object_dispatch_construct (arguments_list_p, arguments_list_len);
|
||||
return ecma_make_object_value (ecma_op_create_object_object_noarg ());
|
||||
}
|
||||
|
||||
return ecma_op_to_object (arguments_list_p[0]);
|
||||
@@ -124,16 +123,25 @@ ecma_value_t
|
||||
ecma_builtin_object_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
if (arguments_list_len == 0)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (JERRY_CONTEXT (current_new_target) != ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT))
|
||||
{
|
||||
ecma_object_t *obj_p = ecma_op_create_object_object_noarg ();
|
||||
ecma_object_t *prototype_obj_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target),
|
||||
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE);
|
||||
if (JERRY_UNLIKELY (prototype_obj_p == NULL))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
return ecma_make_object_value (obj_p);
|
||||
ecma_object_t *object_p = ecma_create_object (prototype_obj_p,
|
||||
0,
|
||||
ECMA_OBJECT_TYPE_GENERAL);
|
||||
ecma_deref_object (prototype_obj_p);
|
||||
|
||||
return ecma_make_object_value (object_p);
|
||||
}
|
||||
|
||||
return ecma_op_create_object_object_arg (arguments_list_p[0]);
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
return ecma_builtin_object_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
} /* ecma_builtin_object_dispatch_construct */
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user