mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
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:
parent
fdaacde667
commit
2919a6463f
@ -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 */
|
||||
|
||||
/**
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class MyInt32Array extends Int32Array {};
|
||||
var t1= new MyInt32Array([1,2]);
|
||||
|
||||
assert(Object.getPrototypeOf(t1) == MyInt32Array.prototype)
|
||||
|
||||
|
||||
class MyArrayBuffer extends ArrayBuffer {};
|
||||
var t2= new MyArrayBuffer(8);
|
||||
|
||||
assert(Object.getPrototypeOf(t2) == MyArrayBuffer.prototype)
|
||||
@ -3,7 +3,6 @@
|
||||
<!-- Uncategorized failing tests -->
|
||||
<test id="built-ins/Array/prototype/splice/property-traps-order-with-species.js"><reason></reason></test>
|
||||
<test id="built-ins/ArrayBuffer/data-allocation-after-object-creation.js"><reason></reason></test>
|
||||
<test id="built-ins/ArrayBuffer/prototype-from-newtarget.js"><reason></reason></test>
|
||||
<test id="built-ins/AsyncFunction/AsyncFunction-is-subclass.js"><reason></reason></test>
|
||||
<test id="built-ins/AsyncFunction/AsyncFunctionPrototype-prototype.js"><reason></reason></test>
|
||||
<test id="built-ins/AsyncFunction/AsyncFunctionPrototype-to-string.js"><reason></reason></test>
|
||||
@ -304,30 +303,21 @@
|
||||
<test id="built-ins/TypedArrayConstructors/ctors-bigint/buffer-arg/custom-proto-access-throws.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors-bigint/buffer-arg/defined-negative-length.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors-bigint/buffer-arg/toindex-byteoffset.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors-bigint/buffer-arg/use-custom-proto-if-object.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors-bigint/length-arg/custom-proto-access-throws.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors-bigint/length-arg/toindex-length.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors-bigint/length-arg/use-custom-proto-if-object.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors-bigint/no-args/custom-proto-access-throws.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors-bigint/no-args/use-custom-proto-if-object.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors-bigint/object-arg/custom-proto-access-throws.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors-bigint/object-arg/use-custom-proto-if-object.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/custom-proto-access-throws.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors/buffer-arg/byteoffset-is-negative-zero.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors/buffer-arg/custom-proto-access-throws.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors/buffer-arg/defined-negative-length.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors/buffer-arg/toindex-byteoffset.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors/buffer-arg/use-custom-proto-if-object.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors/length-arg/custom-proto-access-throws.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors/length-arg/toindex-length.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors/length-arg/use-custom-proto-if-object.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors/no-args/custom-proto-access-throws.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors/no-args/use-custom-proto-if-object.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors/object-arg/custom-proto-access-throws.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors/object-arg/returns.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors/object-arg/use-custom-proto-if-object.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors/typedarray-arg/custom-proto-access-throws.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors/typedarray-arg/use-custom-proto-if-object.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/from/BigInt/custom-ctor-returns-other-instance.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/from/BigInt/custom-ctor.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/from/BigInt/new-instance-using-custom-ctor.js"><reason></reason></test>
|
||||
@ -9528,7 +9518,6 @@
|
||||
<test id="annexB/language/statements/const/dstr/object-pattern-emulates-undefined.js"><reason></reason></test>
|
||||
<test id="annexB/language/statements/for-of/iterator-close-return-emulates-undefined-throws-when-called.js"><reason></reason></test>
|
||||
<test id="annexB/language/statements/function/default-parameters-emulates-undefined.js"><reason></reason></test>
|
||||
<test id="built-ins/ArrayBuffer/proto-from-ctor-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/AsyncFunction/proto-from-ctor-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/Atomics/notify/bigint/notify-all-on-loc.js"><reason></reason></test>
|
||||
<test id="built-ins/Atomics/notify/count-defaults-to-infinity-missing.js"><reason></reason></test>
|
||||
@ -9662,17 +9651,7 @@
|
||||
<test id="built-ins/RegExp/prototype/unicode/cross-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/SharedArrayBuffer/proto-from-ctor-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors-bigint/buffer-arg/proto-from-ctor-realm-sab.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors-bigint/buffer-arg/proto-from-ctor-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors-bigint/length-arg/proto-from-ctor-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors-bigint/no-args/proto-from-ctor-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors-bigint/object-arg/proto-from-ctor-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors-bigint/typedarray-arg/proto-from-ctor-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors/buffer-arg/proto-from-ctor-realm-sab.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors/buffer-arg/proto-from-ctor-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors/length-arg/proto-from-ctor-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors/no-args/proto-from-ctor-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors/object-arg/proto-from-ctor-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/ctors/typedarray-arg/proto-from-ctor-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer-realm.js"><reason></reason></test>
|
||||
<test id="built-ins/TypedArrayConstructors/internals/Get/BigInt/detached-buffer-realm.js"><reason></reason></test>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user