Add new target support for ArrayBuffer and TypedArray (#4369)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-typedarray-object.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "jcontext.h"
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
@@ -37,14 +39,25 @@ ecma_typedarray_helper_dispatch_construct (const ecma_value_t *arguments_list_p,
|
||||
ecma_typedarray_type_t typedarray_id) /**< id of the typedarray */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
ecma_builtin_id_t proto_id = ecma_typedarray_helper_get_prototype_id (typedarray_id);
|
||||
ecma_object_t *prototype_obj_p = ecma_builtin_get (proto_id);
|
||||
|
||||
if (JERRY_CONTEXT (current_new_target))
|
||||
{
|
||||
prototype_obj_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target), proto_id);
|
||||
}
|
||||
|
||||
ecma_object_t *prototype_obj_p = ecma_builtin_get (ecma_typedarray_helper_get_prototype_id (typedarray_id));
|
||||
ecma_value_t val = ecma_op_create_typedarray (arguments_list_p,
|
||||
arguments_list_len,
|
||||
prototype_obj_p,
|
||||
ecma_typedarray_helper_get_shift_size (typedarray_id),
|
||||
typedarray_id);
|
||||
|
||||
if (JERRY_CONTEXT (current_new_target))
|
||||
{
|
||||
ecma_deref_object (prototype_obj_p);
|
||||
}
|
||||
|
||||
return val;
|
||||
} /* ecma_typedarray_helper_dispatch_construct */
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "jmem.h"
|
||||
#include "jcontext.h"
|
||||
#include "ecma-function-object.h"
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_TYPEDARRAY)
|
||||
|
||||
@@ -141,7 +143,19 @@ ecma_op_create_arraybuffer_object (const ecma_value_t *arguments_list_p, /**< li
|
||||
|
||||
uint32_t length_uint32 = ecma_number_to_uint32 (length_num);
|
||||
|
||||
return ecma_make_object_value (ecma_arraybuffer_new_object (length_uint32));
|
||||
ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target),
|
||||
ECMA_BUILTIN_ID_ARRAYBUFFER_PROTOTYPE);
|
||||
|
||||
if (proto_p == NULL)
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_object_t *array_buffer = ecma_arraybuffer_new_object (length_uint32);
|
||||
ECMA_SET_NON_NULL_POINTER (array_buffer->u2.prototype_cp, proto_p);
|
||||
ecma_deref_object (proto_p);
|
||||
|
||||
return ecma_make_object_value (array_buffer);
|
||||
} /* ecma_op_create_arraybuffer_object */
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user