Introduce ecma_op_object_get_length and ecma_op_object_get_by_index operations (#3245)

These two functions helps to reduce code duplication, also invokes the elimination of several ECMA_TRY_CATCH macros.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2019-10-29 10:07:20 +01:00
committed by GitHub
parent 11818f1cb0
commit 42ab062441
23 changed files with 679 additions and 776 deletions
@@ -1088,6 +1088,19 @@ ecma_op_array_object_define_own_property (ecma_object_t *object_p, /**< the arra
return ECMA_VALUE_TRUE;
} /* ecma_op_array_object_define_own_property */
/**
* Get the length of the an array object
*
* @return the array length
*/
extern inline uint32_t JERRY_ATTR_ALWAYS_INLINE
ecma_array_get_length (ecma_object_t *array_p) /**< array object */
{
JERRY_ASSERT (ecma_get_object_type (array_p) == ECMA_OBJECT_TYPE_ARRAY);
return ((ecma_extended_object_t *) array_p)->u.array.length;
} /* ecma_array_get_length */
/**
* List names of a String object's lazy instantiated properties
*
@@ -88,6 +88,8 @@ ecma_value_t
ecma_op_array_object_define_own_property (ecma_object_t *object_p, ecma_string_t *property_name_p,
const ecma_property_descriptor_t *property_desc_p);
uint32_t ecma_array_get_length (ecma_object_t *array_p);
void
ecma_op_array_list_lazy_property_names (ecma_object_t *obj_p, bool separate_enumerable,
ecma_collection_t *main_collection_p,
@@ -129,7 +129,7 @@ ecma_op_container_create (const ecma_value_t *arguments_list_p, /**< arguments l
ecma_object_t *next_object_p = ecma_get_object_from_value (next_value);
ecma_value_t key = ecma_op_object_get (next_object_p, ecma_new_ecma_string_from_uint32 (0));
ecma_value_t key = ecma_op_object_get_by_uint32_index (next_object_p, 0);
if (ECMA_IS_VALUE_ERROR (key))
{
@@ -141,7 +141,7 @@ ecma_op_container_create (const ecma_value_t *arguments_list_p, /**< arguments l
return key;
}
ecma_value_t value = ecma_op_object_get (next_object_p, ecma_new_ecma_string_from_uint32 (1));
ecma_value_t value = ecma_op_object_get_by_uint32_index (next_object_p, 1);
if (ECMA_IS_VALUE_ERROR (value))
{
@@ -50,6 +50,22 @@ ecma_is_normal_or_arrow_function (ecma_object_type_t type) /**< object type */
#endif /* ENABLED (JERRY_ES2015) */
} /* ecma_is_normal_or_arrow_function */
/**
* IsCallable operation.
*
* See also: ECMA-262 v5, 9.11
*
* @return true - if the given object is callable;
* false - otherwise
*/
inline bool JERRY_ATTR_ALWAYS_INLINE
ecma_op_object_is_callable (ecma_object_t *obj_p) /**< ecma object */
{
JERRY_ASSERT (!ecma_is_lexical_environment (obj_p));
return ecma_get_object_type (obj_p) >= ECMA_OBJECT_TYPE_FUNCTION;
} /* ecma_op_object_is_callable */
/**
* IsCallable operation.
*
@@ -61,25 +77,30 @@ ecma_is_normal_or_arrow_function (ecma_object_type_t type) /**< object type */
bool
ecma_op_is_callable (ecma_value_t value) /**< ecma value */
{
if (!ecma_is_value_object (value))
{
return false;
}
return (ecma_is_value_object (value)
&& ecma_op_object_is_callable (ecma_get_object_from_value (value)));
} /* ecma_op_is_callable */
ecma_object_t *obj_p = ecma_get_object_from_value (value);
JERRY_ASSERT (obj_p != NULL);
/**
* Checks whether the given object implements [[Construct]].
*
* @return true - if the given object is constructor;
* false - otherwise
*/
inline bool JERRY_ATTR_ALWAYS_INLINE
ecma_object_is_constructor (ecma_object_t *obj_p) /**< ecma object */
{
JERRY_ASSERT (!ecma_is_lexical_environment (obj_p));
ecma_object_type_t type = ecma_get_object_type (obj_p);
return (type == ECMA_OBJECT_TYPE_FUNCTION
#if ENABLED (JERRY_ES2015)
|| type == ECMA_OBJECT_TYPE_ARROW_FUNCTION
#endif /* ENABLED (JERRY_ES2015) */
|| type == ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION
|| type == ECMA_OBJECT_TYPE_BOUND_FUNCTION);
} /* ecma_op_is_callable */
if (type == ECMA_OBJECT_TYPE_FUNCTION)
{
return (!ecma_get_object_is_builtin (obj_p) || !ecma_builtin_function_is_routine (obj_p));
}
return (type >= ECMA_OBJECT_TYPE_BOUND_FUNCTION);
} /* ecma_object_is_constructor */
/**
* Checks whether the value is Object that implements [[Construct]].
@@ -90,24 +111,8 @@ ecma_op_is_callable (ecma_value_t value) /**< ecma value */
bool
ecma_is_constructor (ecma_value_t value) /**< ecma value */
{
if (!ecma_is_value_object (value))
{
return false;
}
ecma_object_t *obj_p = ecma_get_object_from_value (value);
JERRY_ASSERT (obj_p != NULL);
JERRY_ASSERT (!ecma_is_lexical_environment (obj_p));
if (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_FUNCTION)
{
return (!ecma_get_object_is_builtin (obj_p)
|| !ecma_builtin_function_is_routine (obj_p));
}
return (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_BOUND_FUNCTION
|| ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION);
return (ecma_is_value_object (value)
&& ecma_object_is_constructor (ecma_get_object_from_value (value)));
} /* ecma_is_constructor */
/**
@@ -29,7 +29,9 @@
bool ecma_is_normal_or_arrow_function (ecma_object_type_t type);
bool ecma_op_is_callable (ecma_value_t value);
bool ecma_op_object_is_callable (ecma_object_t *obj_p);
bool ecma_is_constructor (ecma_value_t value);
bool ecma_object_is_constructor (ecma_object_t *obj_p);
ecma_object_t *
ecma_op_create_function_object (ecma_object_t *scope_p, const ecma_compiled_code_t *bytecode_data_p);
+62 -5
View File
@@ -171,7 +171,7 @@ ecma_op_object_get_own_property (ecma_object_t *object_p, /**< the object */
case ECMA_OBJECT_TYPE_PSEUDO_ARRAY:
{
/* ES2015 9.4.5.1 */
if (ecma_is_typedarray (ecma_make_object_value (object_p)))
if (ecma_object_is_typedarray (object_p))
{
#if ENABLED (JERRY_ES2015)
if (ecma_prop_name_is_symbol (property_name_p))
@@ -540,7 +540,7 @@ ecma_op_object_find_own (ecma_value_t base_value, /**< base value */
}
#if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY)
/* ES2015 9.4.5.4 */
if (ecma_is_typedarray (ecma_make_object_value (object_p)))
if (ecma_object_is_typedarray (object_p))
{
#if ENABLED (JERRY_ES2015)
if (ecma_prop_name_is_symbol (property_name_p))
@@ -826,6 +826,63 @@ ecma_op_object_get (ecma_object_t *object_p, /**< the object */
return ECMA_VALUE_UNDEFINED;
} /* ecma_op_object_get */
/**
* [[Get]] operation of ecma object specified for uint32_t property index
*
* @return ecma value
* Returned value must be freed with ecma_free_value
*/
ecma_value_t
ecma_op_object_get_by_uint32_index (ecma_object_t *object_p, /**< the object */
uint32_t index) /**< property index */
{
if (JERRY_LIKELY (index <= ECMA_DIRECT_STRING_MAX_IMM))
{
return ecma_op_object_get (object_p, ECMA_CREATE_DIRECT_UINT32_STRING (index));
}
ecma_string_t *index_str_p = ecma_new_non_direct_string_from_uint32 (index);
ecma_value_t ret_value = ecma_op_object_get (object_p, index_str_p);
ecma_deref_ecma_string (index_str_p);
return ret_value;
} /* ecma_op_object_get_by_uint32_index */
/**
* Perform ToLength(O.[[Get]]("length")) operation
*
* The property is converted to uint32 during the operation
*
* @return ECMA_VALUE_ERROR - if there was any error during the operation
* ECMA_VALUE_EMPTY - otherwise
*/
ecma_value_t
ecma_op_object_get_length (ecma_object_t *object_p, /**< the object */
uint32_t *length_p) /**< [out] length value converted to uint32 */
{
if (JERRY_LIKELY (ecma_get_object_type (object_p) == ECMA_OBJECT_TYPE_ARRAY))
{
*length_p = ecma_array_get_length (object_p);
return ECMA_VALUE_EMPTY;
}
#if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY)
if (ecma_object_is_typedarray (object_p))
{
*length_p = ecma_typedarray_get_length (object_p);
return ECMA_VALUE_EMPTY;
}
#endif /* ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */
ecma_value_t len_value = ecma_op_object_get_by_magic_id (object_p, LIT_MAGIC_STRING_LENGTH);
ecma_value_t len_number = ecma_op_to_length (len_value, length_p);
ecma_free_value (len_value);
JERRY_ASSERT (ECMA_IS_VALUE_ERROR (len_number) || ecma_is_value_empty (len_number));
return len_number;
} /* ecma_op_object_get_length */
/**
* [[Get]] operation of ecma object where the property name is a magic string
*
@@ -1070,7 +1127,7 @@ ecma_op_object_put (ecma_object_t *object_p, /**< the object */
}
#if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY)
/* ES2015 9.4.5.5 */
if (ecma_is_typedarray (ecma_make_object_value (object_p)))
if (ecma_object_is_typedarray (object_p))
{
#if ENABLED (JERRY_ES2015)
if (ecma_prop_name_is_symbol (property_name_p))
@@ -1483,7 +1540,7 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
#if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY)
}
/* ES2015 9.4.5.3 */
if (ecma_is_typedarray (ecma_make_object_value (obj_p)))
if (ecma_object_is_typedarray (obj_p))
{
#if ENABLED (JERRY_ES2015)
if (ecma_prop_name_is_symbol (property_name_p))
@@ -1755,7 +1812,7 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
case ECMA_OBJECT_TYPE_PSEUDO_ARRAY:
{
#if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY)
if (ecma_is_typedarray (ecma_make_object_value (obj_p)))
if (ecma_object_is_typedarray (obj_p))
{
ecma_op_typedarray_list_lazy_property_names (obj_p, prop_names_p);
}
@@ -36,6 +36,8 @@ ecma_value_t ecma_op_object_find_by_uint32_index (ecma_object_t *object_p, uint3
ecma_value_t ecma_op_object_find_by_number_index (ecma_object_t *object_p, ecma_number_t index);
ecma_value_t ecma_op_object_get_own_data_prop (ecma_object_t *object_p, ecma_string_t *property_name_p);
ecma_value_t ecma_op_object_get (ecma_object_t *object_p, ecma_string_t *property_name_p);
ecma_value_t ecma_op_object_get_length (ecma_object_t *object_p, uint32_t *length_p);
ecma_value_t ecma_op_object_get_by_uint32_index (ecma_object_t *object_p, uint32_t index);
ecma_value_t ecma_op_object_get_by_magic_id (ecma_object_t *object_p, lit_magic_string_id_t property_id);
#if ENABLED (JERRY_ES2015)
ecma_value_t ecma_op_object_get_by_symbol_id (ecma_object_t *object_p, lit_magic_string_id_t property_id);
@@ -466,7 +466,7 @@ ecma_typedarray_helper_get_prototype_id (ecma_typedarray_type_t typedarray_id) /
ecma_typedarray_type_t
ecma_get_typedarray_id (ecma_object_t *obj_p) /**< typedarray object **/
{
JERRY_ASSERT (ecma_is_typedarray (ecma_make_object_value (obj_p)));
JERRY_ASSERT (ecma_object_is_typedarray (obj_p));
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
@@ -659,8 +659,6 @@ ecma_op_typedarray_from (ecma_value_t items_val, /**< the source array-like obje
uint8_t element_size_shift, /**< the size shift of the element length */
ecma_typedarray_type_t typedarray_id) /**< id of the typedarray */
{
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
/* 3 */
JERRY_ASSERT (ecma_op_is_callable (map_fn_val) || ecma_is_value_undefined (map_fn_val));
@@ -671,20 +669,25 @@ ecma_op_typedarray_from (ecma_value_t items_val, /**< the source array-like obje
}
/* 10 */
ECMA_TRY_CATCH (arraylike_object_val,
ecma_op_to_object (items_val),
ret_value);
ecma_value_t arraylike_object_val = ecma_op_to_object (items_val);
if (ECMA_IS_VALUE_ERROR (arraylike_object_val))
{
return arraylike_object_val;
}
ecma_object_t *arraylike_object_p = ecma_get_object_from_value (arraylike_object_val);
/* 12 */
ECMA_TRY_CATCH (len_value,
ecma_op_object_get_by_magic_id (arraylike_object_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
uint32_t len;
ecma_value_t len_value = ecma_op_object_get_length (arraylike_object_p, &len);
ECMA_OP_TO_NUMBER_TRY_CATCH (len_number, len_value, ret_value);
uint32_t len = ecma_number_to_uint32 (len_number);
ecma_value_t ret_value = ECMA_VALUE_ERROR;
if (ECMA_IS_VALUE_ERROR (len_value))
{
ecma_deref_object (arraylike_object_p);
return len_value;
}
/* 14 */
ecma_value_t new_typedarray = ecma_typedarray_create_object_with_length (len,
@@ -694,91 +697,77 @@ ecma_op_typedarray_from (ecma_value_t items_val, /**< the source array-like obje
if (ECMA_IS_VALUE_ERROR (new_typedarray))
{
ret_value = new_typedarray;
ecma_deref_object (arraylike_object_p);
return new_typedarray;
}
else
ecma_object_t *new_typedarray_p = ecma_get_object_from_value (new_typedarray);
ecma_typedarray_info_t info = ecma_typedarray_get_info (new_typedarray_p);
ecma_typedarray_setter_fn_t setter_cb = ecma_get_typedarray_setter_fn (info.id);
ecma_number_t num_var;
/* 17 */
for (uint32_t index = 0; index < len; index++)
{
ecma_object_t *new_typedarray_p = ecma_get_object_from_value (new_typedarray);
ecma_typedarray_info_t info = ecma_typedarray_get_info (new_typedarray_p);
ecma_typedarray_setter_fn_t setter_cb = ecma_get_typedarray_setter_fn (info.id);
ecma_value_t error = ECMA_VALUE_EMPTY;
ecma_number_t num_var;
/* 17.b */
ecma_value_t current_value = ecma_op_object_find_by_uint32_index (arraylike_object_p, index);
/* 17 */
ecma_value_t current_index;
for (uint32_t index = 0; index < len && ecma_is_value_empty (ret_value); index++)
if (ECMA_IS_VALUE_ERROR (current_value))
{
/* 17.a */
ecma_string_t *index_str_p = ecma_new_ecma_string_from_uint32 (index);
goto cleanup;
}
/* 17.b */
ECMA_TRY_CATCH (current_value, ecma_op_object_find (arraylike_object_p, index_str_p), ret_value);
if (ecma_is_value_found (current_value))
if (ecma_is_value_found (current_value))
{
ecma_value_t mapped_value;
if (func_object_p != NULL)
{
if (func_object_p != NULL)
/* 17.d 17.f */
ecma_value_t current_index = ecma_make_uint32_value (index);
ecma_value_t call_args[] = { current_value, current_index };
ecma_value_t cb_value = ecma_op_function_call (func_object_p, this_val, call_args, 2);
ecma_free_value (current_index);
ecma_free_value (current_value);
if (ECMA_IS_VALUE_ERROR (cb_value))
{
/* 17.d 17.f */
current_index = ecma_make_uint32_value (index);
ecma_value_t call_args[] = { current_value, current_index};
ECMA_TRY_CATCH (mapped_value, ecma_op_function_call (func_object_p, this_val, call_args, 2), ret_value);
error = ecma_get_number (mapped_value, &num_var);
if (ECMA_IS_VALUE_ERROR (error))
{
ret_value = ECMA_VALUE_ERROR;
}
if (index >= info.length)
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Invalid argument type."));
}
ecma_length_t byte_pos = index << info.shift;
setter_cb (info.buffer_p + byte_pos, num_var);
ECMA_FINALIZE (mapped_value);
goto cleanup;
}
else
{
error = ecma_get_number (current_value, &num_var);
if (ECMA_IS_VALUE_ERROR (error))
{
ret_value = ECMA_VALUE_ERROR;
}
if (index >= info.length)
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Invalid argument type."));
}
ecma_length_t byte_pos = index << info.shift;
setter_cb (info.buffer_p + byte_pos, num_var);
}
mapped_value = cb_value;
}
else
{
mapped_value = current_value;
}
ECMA_FINALIZE (current_value);
ecma_value_t mapped_number = ecma_get_number (mapped_value, &num_var);
ecma_free_value (mapped_value);
ecma_deref_ecma_string (index_str_p);
}
if (ECMA_IS_VALUE_ERROR (mapped_number))
{
goto cleanup;
}
if (ecma_is_value_empty (ret_value))
{
ret_value = ecma_make_object_value (new_typedarray_p);
}
else
{
ecma_deref_object (new_typedarray_p);
if (index >= info.length)
{
ecma_raise_type_error (ECMA_ERR_MSG ("Invalid argument type."));
goto cleanup;
}
ecma_length_t byte_pos = (index << info.shift);
setter_cb (info.buffer_p + byte_pos, num_var);
}
}
ECMA_OP_TO_NUMBER_FINALIZE (len_number);
ECMA_FINALIZE (len_value);
ECMA_FINALIZE (arraylike_object_val);
ecma_ref_object (new_typedarray_p);
ret_value = ecma_make_object_value (new_typedarray_p);
cleanup:
ecma_deref_object (new_typedarray_p);
ecma_deref_object (arraylike_object_p);
return ret_value;
} /* ecma_op_typedarray_from */
@@ -791,7 +780,7 @@ ecma_op_typedarray_from (ecma_value_t items_val, /**< the source array-like obje
inline ecma_object_t * JERRY_ATTR_ALWAYS_INLINE
ecma_typedarray_get_arraybuffer (ecma_object_t *typedarray_p) /**< the pointer to the typedarray object */
{
JERRY_ASSERT (ecma_is_typedarray (ecma_make_object_value (typedarray_p)));
JERRY_ASSERT (ecma_object_is_typedarray (typedarray_p));
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) typedarray_p;
@@ -806,7 +795,7 @@ ecma_typedarray_get_arraybuffer (ecma_object_t *typedarray_p) /**< the pointer t
uint8_t
ecma_typedarray_get_element_size_shift (ecma_object_t *typedarray_p) /**< the pointer to the typedarray object */
{
JERRY_ASSERT (ecma_is_typedarray (ecma_make_object_value (typedarray_p)));
JERRY_ASSERT (ecma_object_is_typedarray (typedarray_p));
return ecma_typedarray_helper_get_shift_size (ecma_get_typedarray_id (typedarray_p));
} /* ecma_typedarray_get_element_size_shift */
@@ -820,7 +809,7 @@ ecma_typedarray_get_element_size_shift (ecma_object_t *typedarray_p) /**< the po
ecma_length_t
ecma_typedarray_get_length (ecma_object_t *typedarray_p) /**< the pointer to the typedarray object */
{
JERRY_ASSERT (ecma_is_typedarray (ecma_make_object_value (typedarray_p)));
JERRY_ASSERT (ecma_object_is_typedarray (typedarray_p));
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) typedarray_p;
@@ -852,7 +841,7 @@ ecma_typedarray_get_length (ecma_object_t *typedarray_p) /**< the pointer to the
ecma_length_t
ecma_typedarray_get_offset (ecma_object_t *typedarray_p) /**< the pointer to the typedarray object */
{
JERRY_ASSERT (ecma_is_typedarray (ecma_make_object_value (typedarray_p)));
JERRY_ASSERT (ecma_object_is_typedarray (typedarray_p));
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) typedarray_p;
@@ -940,19 +929,20 @@ ecma_op_create_typedarray (const ecma_value_t *arguments_list_p, /**< the arg li
}
else if (ecma_is_value_object (arguments_list_p[0]))
{
if (ecma_is_typedarray (arguments_list_p[0]))
ecma_object_t *obj_p = ecma_get_object_from_value (arguments_list_p[0]);
if (ecma_object_is_typedarray (obj_p))
{
/* 22.2.1.3 */
ecma_object_t *typedarray_p = ecma_get_object_from_value (arguments_list_p[0]);
ecma_object_t *typedarray_p = obj_p;
ret = ecma_typedarray_create_object_with_typedarray (typedarray_p,
proto_p,
element_size_shift,
typedarray_id);
}
else if (ecma_is_arraybuffer (arguments_list_p[0]))
else if (ecma_object_class_is (obj_p, LIT_MAGIC_STRING_ARRAY_BUFFER_UL))
{
/* 22.2.1.5 */
ecma_object_t *arraybuffer_p = ecma_get_object_from_value (arguments_list_p[0]);
ecma_object_t *arraybuffer_p = obj_p;
ecma_value_t arg2 = ((arguments_list_len > 1) ? arguments_list_p[1]
: ECMA_VALUE_UNDEFINED);
@@ -1043,6 +1033,28 @@ ecma_op_create_typedarray (const ecma_value_t *arguments_list_p, /**< the arg li
return ret;
} /* ecma_op_create_typedarray */
/**
* Check if the object is typedarray
*
* @return true - if object is a TypedArray object
* false - otherwise
*/
bool
ecma_object_is_typedarray (ecma_object_t *obj_p) /**< the target object need to be checked */
{
JERRY_ASSERT (!ecma_is_lexical_environment (obj_p));
if (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_PSEUDO_ARRAY)
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
return ((ext_object_p->u.pseudo_array.type == ECMA_PSEUDO_ARRAY_TYPEDARRAY)
|| (ext_object_p->u.pseudo_array.type == ECMA_PSEUDO_ARRAY_TYPEDARRAY_WITH_INFO));
}
return false;
} /* ecma_object_is_typedarray */
/**
* Check if the value is typedarray
*
@@ -1057,17 +1069,7 @@ ecma_is_typedarray (ecma_value_t value) /**< the target need to be checked */
return false;
}
ecma_object_t *obj_p = ecma_get_object_from_value (value);
if (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_PSEUDO_ARRAY)
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
return ((ext_object_p->u.pseudo_array.type == ECMA_PSEUDO_ARRAY_TYPEDARRAY)
|| (ext_object_p->u.pseudo_array.type == ECMA_PSEUDO_ARRAY_TYPEDARRAY_WITH_INFO));
}
return false;
return ecma_object_is_typedarray (ecma_get_object_from_value (value));
} /* ecma_is_typedarray */
/**
@@ -1079,7 +1081,7 @@ void
ecma_op_typedarray_list_lazy_property_names (ecma_object_t *obj_p, /**< a TypedArray object */
ecma_collection_t *main_collection_p) /**< 'main' collection */
{
JERRY_ASSERT (ecma_is_typedarray (ecma_make_object_value (obj_p)));
JERRY_ASSERT (ecma_object_is_typedarray (obj_p));
ecma_length_t array_length = ecma_typedarray_get_length (obj_p);
@@ -1104,7 +1106,7 @@ ecma_op_typedarray_define_index_prop (ecma_object_t *obj_p, /**< a TypedArray ob
const ecma_property_descriptor_t *property_desc_p) /**< the description of
the prop */
{
JERRY_ASSERT (ecma_is_typedarray (ecma_make_object_value (obj_p)));
JERRY_ASSERT (ecma_object_is_typedarray (obj_p));
ecma_length_t array_length = ecma_typedarray_get_length (obj_p);
@@ -1155,13 +1157,12 @@ ecma_op_create_typedarray_with_type_and_length (ecma_object_t *obj_p, /**< Typed
* indicates the type */
ecma_length_t array_length) /**< length of the typedarray */
{
JERRY_ASSERT (ecma_is_typedarray (ecma_make_object_value (obj_p)));
JERRY_ASSERT (ecma_object_is_typedarray (obj_p));
#if ENABLED (JERRY_ES2015)
ecma_value_t constructor_value = ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_CONSTRUCTOR);
if (ECMA_IS_VALUE_ERROR (constructor_value)
|| !ecma_is_value_object (constructor_value)
|| !ecma_is_constructor (constructor_value))
{
ecma_free_value (constructor_value);
@@ -57,6 +57,7 @@ ecma_value_t ecma_op_create_typedarray (const ecma_value_t *arguments_list_p,
ecma_object_t *proto_p,
uint8_t element_size_shift,
ecma_typedarray_type_t typedarray_id);
bool ecma_object_is_typedarray (ecma_object_t *obj_p);
bool ecma_is_typedarray (ecma_value_t target);
void ecma_op_typedarray_list_lazy_property_names (ecma_object_t *obj_p,
ecma_collection_t *main_collection_p);