[ES2015 profile]add TypedArray intrinsic object (#1507)
* add %TypedArray% intrinsic object * implement Int8Array * will implement other types and prototype functions in the following patches. JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
This commit is contained in:
committed by
László Langó
parent
177c30de78
commit
adfe61b4ed
@@ -174,6 +174,11 @@ OBJECT_VALUE (LIT_MAGIC_STRING_ARRAY_BUFFER_UL,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* !CONFIG_DISABLE_ARRAYBUFFER_BUILTIN */
|
||||
|
||||
#ifndef CONFIG_DISABLE_TYPEDARRAY_BUILTIN
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_INT8_ARRAY_UL,
|
||||
ECMA_BUILTIN_ID_INT8ARRAY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* !CONFIG_DISABLE_ARRAYBUFFER_BUILTIN */
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#include "ecma-builtins.h"
|
||||
|
||||
#ifndef CONFIG_DISABLE_TYPEDARRAY_BUILTIN
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-int8array-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID int8array_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmabuiltins
|
||||
* @{
|
||||
*
|
||||
* \addtogroup int8array prototype ECMA Int8Array.prototype object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !CONFIG_DISABLE_TYPEDARRAY_BUILTIN */
|
||||
@@ -0,0 +1,60 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Int8Array prototype description
|
||||
*/
|
||||
|
||||
#ifndef OBJECT_ID
|
||||
# define OBJECT_ID(builtin_object_id)
|
||||
#endif /* !OBJECT_ID */
|
||||
|
||||
#ifndef NUMBER_VALUE
|
||||
# define NUMBER_VALUE(name, number_value, prop_attributes)
|
||||
#endif /* !NUMBER_VALUE */
|
||||
|
||||
#ifndef STRING_VALUE
|
||||
# define STRING_VALUE(name, magic_string_id, prop_attributes)
|
||||
#endif /* !STRING_VALUE */
|
||||
|
||||
#ifndef OBJECT_VALUE
|
||||
# define OBJECT_VALUE(name, obj_builtin_id, prop_attributes)
|
||||
#endif /* !OBJECT_VALUE */
|
||||
|
||||
#ifndef ROUTINE
|
||||
# define ROUTINE(name, c_function_name, args_number, length_prop_value)
|
||||
#endif /* !ROUTINE */
|
||||
|
||||
/* Object identifier */
|
||||
OBJECT_ID (ECMA_BUILTIN_ID_INT8ARRAY_PROTOTYPE)
|
||||
|
||||
/* ES2015 22.2.3.4 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_INT8ARRAY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ES2015 22.2.6.1 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_BYTES_PER_ELEMENT_U,
|
||||
1,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
|
||||
#undef OBJECT_ID
|
||||
#undef SIMPLE_VALUE
|
||||
#undef NUMBER_VALUE
|
||||
#undef STRING_VALUE
|
||||
#undef OBJECT_VALUE
|
||||
#undef ROUTINE
|
||||
#undef ACCESSOR_READ_WRITE
|
||||
#undef ACCESSOR_READ_ONLY
|
||||
@@ -0,0 +1,86 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-typedarray-object.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#ifndef CONFIG_DISABLE_TYPEDARRAY_BUILTIN
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-int8array.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID int8array
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmabuiltins
|
||||
* @{
|
||||
*
|
||||
* \addtogroup string ECMA Int8Array object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handle calling [[Call]] of Int8Array
|
||||
*
|
||||
* ES2015 22.2.4 The TypedArray constructors are not intended
|
||||
* to be called as a function and will throw an exception when called in that manner.
|
||||
*
|
||||
* @return ecma value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_int8array_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Int8Array cannot be directly called"));
|
||||
} /* ecma_builtin_int8array_dispatch_call */
|
||||
|
||||
/**
|
||||
* Handle calling [[Construct]] of built-in %TypedArray% object
|
||||
*
|
||||
* ES2015 22.2.1 If %TypedArray% is directly called or
|
||||
* called as part of a new expression an exception is thrown
|
||||
*
|
||||
* @return ecma value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_int8array_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_INT8ARRAY_PROTOTYPE);
|
||||
ecma_value_t val = ecma_op_create_typedarray (arguments_list_p,
|
||||
arguments_list_len,
|
||||
prototype_obj_p,
|
||||
0,
|
||||
LIT_MAGIC_STRING_INT8_ARRAY_UL);
|
||||
|
||||
ecma_deref_object (prototype_obj_p);
|
||||
|
||||
return val;
|
||||
} /* ecma_builtin_int8array_dispatch_construct */
|
||||
|
||||
#endif /* !CONFIG_DISABLE_TYPEDARRAY_BUILTIN */
|
||||
@@ -0,0 +1,76 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Int8Array description
|
||||
*/
|
||||
|
||||
#ifndef OBJECT_ID
|
||||
# define OBJECT_ID(builtin_object_id)
|
||||
#endif /* !OBJECT_ID */
|
||||
|
||||
#ifndef NUMBER_VALUE
|
||||
# define NUMBER_VALUE(name, number_value, prop_attributes)
|
||||
#endif /* !NUMBER_VALUE */
|
||||
|
||||
#ifndef STRING_VALUE
|
||||
# define STRING_VALUE(name, magic_string_id, prop_attributes)
|
||||
#endif /* !STRING_VALUE */
|
||||
|
||||
#ifndef OBJECT_VALUE
|
||||
# define OBJECT_VALUE(name, obj_builtin_id, prop_attributes)
|
||||
#endif /* !OBJECT_VALUE */
|
||||
|
||||
#ifndef ROUTINE
|
||||
# define ROUTINE(name, c_function_name, args_number, length_prop_value)
|
||||
#endif /* !ROUTINE */
|
||||
|
||||
/* Object identifier */
|
||||
OBJECT_ID (ECMA_BUILTIN_ID_INT8ARRAY)
|
||||
|
||||
|
||||
/* ES2015 22.2.5 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
3,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* ES2015 22.2.5.1 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_BYTES_PER_ELEMENT_U,
|
||||
1,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* ES2015 22.2.5 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
3,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* ES2015 22.2.5 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_INT8_ARRAY_UL,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* ES2015 22.2.5.2 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_INT8ARRAY_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
|
||||
#undef OBJECT_ID
|
||||
#undef SIMPLE_VALUE
|
||||
#undef NUMBER_VALUE
|
||||
#undef STRING_VALUE
|
||||
#undef OBJECT_VALUE
|
||||
#undef ROUTINE
|
||||
#undef ACCESSOR_READ_WRITE
|
||||
#undef ACCESSOR_READ_ONLY
|
||||
@@ -240,7 +240,7 @@ ecma_builtin_object_prototype_object_property_is_enumerable (ecma_value_t this_a
|
||||
ECMA_PROPERTY_GET_NO_OPTIONS);
|
||||
|
||||
/* 4. */
|
||||
if (property != ECMA_PROPERTY_TYPE_NOT_FOUND)
|
||||
if (property != ECMA_PROPERTY_TYPE_NOT_FOUND && property != ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP)
|
||||
{
|
||||
bool is_enumerable = ecma_is_property_enumerable (property);
|
||||
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-typedarray-object.h"
|
||||
#include "ecma-try-catch-macro.h"
|
||||
#include "jrt.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "ecma-gc.h"
|
||||
|
||||
#ifndef CONFIG_DISABLE_TYPEDARRAY_BUILTIN
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-typedarray-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID typedarray_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmabuiltins
|
||||
* @{
|
||||
*
|
||||
* \addtogroup typedarray prototype ECMA %TypedArray%.prototype object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The %TypedArray%.prototype.buffer accessor
|
||||
*
|
||||
* See also:
|
||||
* ES2015, 22.2.3.1
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_typedarray_prototype_buffer_getter (ecma_value_t this_arg) /**< this argument */
|
||||
{
|
||||
if (ecma_is_typedarray (this_arg))
|
||||
{
|
||||
ecma_object_t *typedarray_p = ecma_get_object_from_value (this_arg);
|
||||
ecma_object_t *obj_p = ecma_typedarray_get_arraybuffer (typedarray_p);
|
||||
ecma_ref_object (obj_p);
|
||||
|
||||
return ecma_make_object_value (obj_p);
|
||||
}
|
||||
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a TypedArray."));
|
||||
} /* ecma_builtin_typedarray_prototype_buffer_getter */
|
||||
|
||||
/**
|
||||
* The %TypedArray%.prototype.byteLength accessor
|
||||
*
|
||||
* See also:
|
||||
* ES2015, 22.2.3.2
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_typedarray_prototype_bytelength_getter (ecma_value_t this_arg) /**< this argument */
|
||||
{
|
||||
if (ecma_is_typedarray (this_arg))
|
||||
{
|
||||
ecma_object_t *typedarray_p = ecma_get_object_from_value (this_arg);
|
||||
uint8_t shift = ecma_typedarray_get_element_size_shift (typedarray_p);
|
||||
|
||||
return ecma_make_uint32_value (ecma_typedarray_get_length (typedarray_p) << shift);
|
||||
}
|
||||
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a TypedArray."));
|
||||
} /* ecma_builtin_typedarray_prototype_bytelength_getter */
|
||||
|
||||
/**
|
||||
* The %TypedArray%.prototype.byteOffset accessor
|
||||
*
|
||||
* See also:
|
||||
* ES2015, 22.2.3.3
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_typedarray_prototype_byteoffset_getter (ecma_value_t this_arg) /**< this argument */
|
||||
{
|
||||
if (ecma_is_typedarray (this_arg))
|
||||
{
|
||||
ecma_object_t *typedarray_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
return ecma_make_uint32_value (ecma_typedarray_get_offset (typedarray_p));
|
||||
}
|
||||
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a TypedArray."));
|
||||
} /* ecma_builtin_typedarray_prototype_byteoffset_getter */
|
||||
|
||||
/**
|
||||
* The %TypedArray%.prototype.length accessor
|
||||
*
|
||||
* See also:
|
||||
* ES2015, 22.2.3.17
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_typedarray_prototype_length_getter (ecma_value_t this_arg) /**< this argument */
|
||||
{
|
||||
if (ecma_is_typedarray (this_arg))
|
||||
{
|
||||
ecma_object_t *typedarray_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
return ecma_make_uint32_value (ecma_typedarray_get_length (typedarray_p));
|
||||
}
|
||||
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a TypedArray."));
|
||||
} /* ecma_builtin_typedarray_prototype_length_getter */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !CONFIG_DISABLE_TYPEDARRAY_BUILTIN */
|
||||
@@ -0,0 +1,73 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* %TypedArrayPrototype% description
|
||||
*/
|
||||
|
||||
#ifndef OBJECT_ID
|
||||
# define OBJECT_ID(builtin_object_id)
|
||||
#endif /* !OBJECT_ID */
|
||||
|
||||
#ifndef NUMBER_VALUE
|
||||
# define NUMBER_VALUE(name, number_value, prop_attributes)
|
||||
#endif /* !NUMBER_VALUE */
|
||||
|
||||
#ifndef STRING_VALUE
|
||||
# define STRING_VALUE(name, magic_string_id, prop_attributes)
|
||||
#endif /* !STRING_VALUE */
|
||||
|
||||
#ifndef OBJECT_VALUE
|
||||
# define OBJECT_VALUE(name, obj_builtin_id, prop_attributes)
|
||||
#endif /* !OBJECT_VALUE */
|
||||
|
||||
#ifndef ROUTINE
|
||||
# define ROUTINE(name, c_function_name, args_number, length_prop_value)
|
||||
#endif /* !ROUTINE */
|
||||
|
||||
/* Object identifier */
|
||||
OBJECT_ID (ECMA_BUILTIN_ID_TYPEDARRAY_PROTOTYPE)
|
||||
|
||||
/* ES2015 22.2.3.4 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_TYPEDARRAY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* Readonly accessor properties */
|
||||
/* ES2015 22.2.3.1 */
|
||||
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BUFFER,
|
||||
ecma_builtin_typedarray_prototype_buffer_getter,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
/* ES2015 22.2.3.2 */
|
||||
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL,
|
||||
ecma_builtin_typedarray_prototype_bytelength_getter,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
/* ES2015 22.2.3.3 */
|
||||
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_OFFSET_UL,
|
||||
ecma_builtin_typedarray_prototype_byteoffset_getter,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* ES2015 22.2.3.17 */
|
||||
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_LENGTH,
|
||||
ecma_builtin_typedarray_prototype_length_getter,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
#undef OBJECT_ID
|
||||
#undef SIMPLE_VALUE
|
||||
#undef NUMBER_VALUE
|
||||
#undef STRING_VALUE
|
||||
#undef OBJECT_VALUE
|
||||
#undef ROUTINE
|
||||
#undef ACCESSOR_READ_WRITE
|
||||
#undef ACCESSOR_READ_ONLY
|
||||
@@ -0,0 +1,124 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-typedarray-object.h"
|
||||
#include "ecma-try-catch-macro.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#ifndef CONFIG_DISABLE_TYPEDARRAY_BUILTIN
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-typedarray.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID typedarray
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmabuiltins
|
||||
* @{
|
||||
*
|
||||
* \addtogroup string ECMA %TypedArray% object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The %TypedArray%.from routine
|
||||
*
|
||||
* See also:
|
||||
* ES2015 22.2.2.1
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_typedarray_from (ecma_value_t this_arg, /**< 'this' argument */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_UNUSED (this_arg);
|
||||
JERRY_UNUSED (arguments_list_p);
|
||||
JERRY_UNUSED (arguments_list_len);
|
||||
|
||||
/* TODO: inplement 'from' */
|
||||
|
||||
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
|
||||
} /* ecma_builtin_typedarray_from */
|
||||
|
||||
/**
|
||||
* The %TypedArray%.of routine
|
||||
*
|
||||
* See also:
|
||||
* ES2015 22.2.2.2
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_typedarray_of (ecma_value_t this_arg, /**< 'this' argument */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_UNUSED (this_arg);
|
||||
JERRY_UNUSED (arguments_list_p);
|
||||
JERRY_UNUSED (arguments_list_len);
|
||||
|
||||
/* TODO: inplement 'of' */
|
||||
|
||||
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
|
||||
} /* ecma_builtin_typedarray_of */
|
||||
|
||||
/**
|
||||
* Handle calling [[Call]] of built-in %TypedArray% object
|
||||
*
|
||||
* ES2015 22.2.1 If %TypedArray% is directly called or
|
||||
* called as part of a new expression an exception is thrown
|
||||
*
|
||||
* @return ecma value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_typedarray_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("TypedArray intrinstic cannot be directly called"));
|
||||
} /* ecma_builtin_typedarray_dispatch_call */
|
||||
|
||||
/**
|
||||
* Handle calling [[Construct]] of built-in %TypedArray% object
|
||||
*
|
||||
* ES2015 22.2.1 If %TypedArray% is directly called or
|
||||
* called as part of a new expression an exception is thrown
|
||||
*
|
||||
* @return ecma value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_typedarray_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("TypedArray intrinstic cannot be called by a 'new' expression"));
|
||||
} /* ecma_builtin_typedarray_dispatch_construct */
|
||||
|
||||
#endif /* !CONFIG_DISABLE_TYPEDARRAY_BUILTIN */
|
||||
@@ -0,0 +1,75 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* %TypedArray% description
|
||||
*/
|
||||
|
||||
#ifndef OBJECT_ID
|
||||
# define OBJECT_ID(builtin_object_id)
|
||||
#endif /* !OBJECT_ID */
|
||||
|
||||
#ifndef NUMBER_VALUE
|
||||
# define NUMBER_VALUE(name, number_value, prop_attributes)
|
||||
#endif /* !NUMBER_VALUE */
|
||||
|
||||
#ifndef STRING_VALUE
|
||||
# define STRING_VALUE(name, magic_string_id, prop_attributes)
|
||||
#endif /* !STRING_VALUE */
|
||||
|
||||
#ifndef OBJECT_VALUE
|
||||
# define OBJECT_VALUE(name, obj_builtin_id, prop_attributes)
|
||||
#endif /* !OBJECT_VALUE */
|
||||
|
||||
#ifndef ROUTINE
|
||||
# define ROUTINE(name, c_function_name, args_number, length_prop_value)
|
||||
#endif /* !ROUTINE */
|
||||
|
||||
/* Object identifier */
|
||||
OBJECT_ID (ECMA_BUILTIN_ID_TYPEDARRAY)
|
||||
|
||||
|
||||
/* ES2015 22.2.2 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
3,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* ES2015 22.2.2 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_TYPED_ARRAY_UL,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* ES2015 22.2.2.3 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_TYPEDARRAY_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
|
||||
/* ES2015 22.2.2.1 */
|
||||
ROUTINE (LIT_MAGIC_STRING_FROM, ecma_builtin_typedarray_from, NON_FIXED, 1)
|
||||
|
||||
/* ES2015 22.2.2.2 */
|
||||
ROUTINE (LIT_MAGIC_STRING_OF, ecma_builtin_typedarray_of, NON_FIXED, 0)
|
||||
|
||||
#undef OBJECT_ID
|
||||
#undef SIMPLE_VALUE
|
||||
#undef NUMBER_VALUE
|
||||
#undef STRING_VALUE
|
||||
#undef OBJECT_VALUE
|
||||
#undef ROUTINE
|
||||
#undef ACCESSOR_READ_WRITE
|
||||
#undef ACCESSOR_READ_ONLY
|
||||
@@ -317,6 +317,40 @@ BUILTIN (ECMA_BUILTIN_ID_ARRAYBUFFER,
|
||||
arraybuffer)
|
||||
#endif /* !CONFIG_DISABLE_ARRAYBUFFER_BUILTIN */
|
||||
|
||||
#ifndef CONFIG_DISABLE_TYPEDARRAY_BUILTIN
|
||||
|
||||
/* The %TypedArrayPrototype% object (ES2015 24.2.3) */
|
||||
BUILTIN (ECMA_BUILTIN_ID_TYPEDARRAY_PROTOTYPE,
|
||||
ECMA_OBJECT_TYPE_GENERAL,
|
||||
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
typedarray_prototype)
|
||||
|
||||
/* The %TypedArray% intrinsic object (ES2015 22.2.1) */
|
||||
BUILTIN (ECMA_BUILTIN_ID_TYPEDARRAY,
|
||||
ECMA_OBJECT_TYPE_FUNCTION,
|
||||
ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
typedarray)
|
||||
|
||||
BUILTIN (ECMA_BUILTIN_ID_INT8ARRAY_PROTOTYPE,
|
||||
ECMA_OBJECT_TYPE_GENERAL,
|
||||
ECMA_BUILTIN_ID_TYPEDARRAY_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
int8array_prototype)
|
||||
|
||||
BUILTIN (ECMA_BUILTIN_ID_INT8ARRAY,
|
||||
ECMA_OBJECT_TYPE_FUNCTION,
|
||||
ECMA_BUILTIN_ID_TYPEDARRAY,
|
||||
true,
|
||||
true,
|
||||
int8array)
|
||||
|
||||
#endif /* !CONFIG_DISABLE_TYPEDARRAY_BUILTIN */
|
||||
|
||||
/* The Global object (15.1) */
|
||||
BUILTIN (ECMA_BUILTIN_ID_GLOBAL,
|
||||
ECMA_OBJECT_TYPE_GENERAL,
|
||||
|
||||
Reference in New Issue
Block a user