mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
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:
parent
99c7099eaa
commit
148f69f4a5
@ -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 */
|
||||
|
||||
/**
|
||||
|
||||
@ -66,42 +66,6 @@ ecma_op_create_object_object_noarg (void)
|
||||
return ecma_op_create_object_object_noarg_and_set_prototype (object_prototype_p);
|
||||
} /* ecma_op_create_object_object_noarg */
|
||||
|
||||
/**
|
||||
* 'Object' object creation operation with one argument.
|
||||
*
|
||||
* See also: ECMA-262 v5, 15.2.2.1
|
||||
*
|
||||
* @return pointer to newly created 'Object' object
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_create_object_object_arg (ecma_value_t value) /**< argument of constructor */
|
||||
{
|
||||
ecma_check_value_type_is_spec_defined (value);
|
||||
|
||||
if (!ecma_is_value_undefined (value)
|
||||
&& !ecma_is_value_null (value))
|
||||
{
|
||||
/* 1.b, 1.c, 1.d */
|
||||
JERRY_ASSERT (ecma_is_value_object (value)
|
||||
|| ecma_is_value_number (value)
|
||||
|| ecma_is_value_prop_name (value)
|
||||
|| ecma_is_value_boolean (value)
|
||||
|| ecma_is_value_bigint (value));
|
||||
|
||||
return ecma_op_to_object (value);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 2. */
|
||||
JERRY_ASSERT (ecma_is_value_undefined (value)
|
||||
|| ecma_is_value_null (value));
|
||||
|
||||
ecma_object_t *obj_p = ecma_op_create_object_object_noarg ();
|
||||
|
||||
return ecma_make_object_value (obj_p);
|
||||
}
|
||||
} /* ecma_op_create_object_object_arg */
|
||||
|
||||
/**
|
||||
* Object creation operation with no arguments.
|
||||
* It sets the given prototype to the newly created object.
|
||||
|
||||
@ -28,7 +28,6 @@
|
||||
|
||||
ecma_value_t ecma_reject (bool is_throw);
|
||||
ecma_object_t *ecma_op_create_object_object_noarg (void);
|
||||
ecma_value_t ecma_op_create_object_object_arg (ecma_value_t value);
|
||||
ecma_object_t *ecma_op_create_object_object_noarg_and_set_prototype (ecma_object_t *object_prototype_p);
|
||||
|
||||
ecma_value_t ecma_op_general_object_delete (ecma_object_t *obj_p, ecma_string_t *property_name_p, bool is_throw);
|
||||
|
||||
@ -807,7 +807,6 @@
|
||||
<test id="built-ins/Object/keys/order-after-define-property.js"><reason></reason></test>
|
||||
<test id="built-ins/Object/proto-from-ctor-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/Object/prototype/toString/symbol-tag-non-str-proxy-function.js"><reason></reason></test>
|
||||
<test id="built-ins/Object/subclass-object-arg.js"><reason></reason></test>
|
||||
<test id="built-ins/Promise/all/invoke-resolve-get-error.js"><reason>Test expects incorrect call order</reason></test>
|
||||
<test id="built-ins/Promise/all/resolve-non-callable.js"><reason>Test expects incorrect call order</reason></test>
|
||||
<test id="built-ins/Promise/allSettled/call-resolve-element-after-return.js"><reason></reason></test>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user