Fix values of properties that reference intrinsic function objects (#4024)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
This commit is contained in:
@@ -768,14 +768,14 @@ ecma_op_array_species_create (ecma_object_t *original_array_p, /**< The object f
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_create_array_iterator (ecma_object_t *obj_p, /**< array object */
|
||||
ecma_array_iterator_type_t type) /**< array iterator type */
|
||||
ecma_iterator_kind_t kind) /**< array iterator kind */
|
||||
{
|
||||
ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_ARRAY_ITERATOR_PROTOTYPE);
|
||||
|
||||
return ecma_op_create_iterator_object (ecma_make_object_value (obj_p),
|
||||
prototype_obj_p,
|
||||
ECMA_PSEUDO_ARRAY_ITERATOR,
|
||||
(uint8_t) type);
|
||||
kind);
|
||||
} /* ecma_op_create_array_iterator */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
@@ -1196,6 +1196,50 @@ ecma_array_get_length (ecma_object_t *array_p) /**< array object */
|
||||
return ((ecma_extended_object_t *) array_p)->u.array.length;
|
||||
} /* ecma_array_get_length */
|
||||
|
||||
/**
|
||||
* The Array.prototype and %TypedArray%.prototype objects' 'toString' routine.
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v5, 15.4.4.2
|
||||
* ECMA-262 v6, 22.1.3.7
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_array_object_to_string (ecma_value_t this_arg) /**< this argument */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_object (this_arg));
|
||||
|
||||
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
|
||||
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
/* 2. */
|
||||
ecma_value_t join_value = ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_JOIN);
|
||||
if (ECMA_IS_VALUE_ERROR (join_value))
|
||||
{
|
||||
return join_value;
|
||||
}
|
||||
|
||||
if (!ecma_op_is_callable (join_value))
|
||||
{
|
||||
/* 3. */
|
||||
ret_value = ecma_builtin_helper_object_to_string (this_arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 4. */
|
||||
ecma_object_t *join_func_obj_p = ecma_get_object_from_value (join_value);
|
||||
|
||||
ret_value = ecma_op_function_call (join_func_obj_p, this_arg, NULL, 0);
|
||||
}
|
||||
|
||||
ecma_free_value (join_value);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_array_object_to_string */
|
||||
|
||||
/**
|
||||
* List names of a String object's lazy instantiated properties
|
||||
*
|
||||
|
||||
@@ -106,7 +106,7 @@ ecma_op_array_species_create (ecma_object_t *original_array_p,
|
||||
|
||||
ecma_value_t
|
||||
ecma_op_create_array_iterator (ecma_object_t *obj_p,
|
||||
ecma_array_iterator_type_t type);
|
||||
ecma_iterator_kind_t kind);
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
ecma_value_t
|
||||
@@ -118,6 +118,9 @@ ecma_op_array_object_define_own_property (ecma_object_t *object_p, ecma_string_t
|
||||
|
||||
uint32_t ecma_array_get_length (ecma_object_t *array_p);
|
||||
|
||||
ecma_value_t
|
||||
ecma_array_object_to_string (ecma_value_t this_arg);
|
||||
|
||||
void
|
||||
ecma_op_array_list_lazy_property_names (ecma_object_t *obj_p,
|
||||
uint32_t opts,
|
||||
|
||||
@@ -974,17 +974,16 @@ ecma_op_container_remove_weak_entry (ecma_object_t *object_p, /**< internal cont
|
||||
* @return Map/Set iterator object, if success
|
||||
* error - otherwise
|
||||
*/
|
||||
ecma_value_t
|
||||
inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_op_container_create_iterator (ecma_value_t this_arg, /**< this argument */
|
||||
uint8_t type, /**< any combination of
|
||||
* ecma_iterator_type_t bits */
|
||||
ecma_builtin_id_t proto_id, /**< prototype builtin id */
|
||||
ecma_pseudo_array_type_t iterator_type) /**< type of the iterator */
|
||||
ecma_pseudo_array_type_t iterator_type, /**< iterator type */
|
||||
ecma_iterator_kind_t kind) /**< iterator kind */
|
||||
{
|
||||
return ecma_op_create_iterator_object (this_arg,
|
||||
ecma_builtin_get (proto_id),
|
||||
(uint8_t) iterator_type,
|
||||
type);
|
||||
iterator_type,
|
||||
kind);
|
||||
} /* ecma_op_container_create_iterator */
|
||||
|
||||
/**
|
||||
@@ -1129,7 +1128,7 @@ ecma_op_container_iterator_next (ecma_value_t this_val, /**< this argument */
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (iterator_kind == ECMA_ITERATOR_KEYS_VALUES);
|
||||
JERRY_ASSERT (iterator_kind == ECMA_ITERATOR_ENTRIES);
|
||||
|
||||
ecma_value_t entry_array_value;
|
||||
entry_array_value = ecma_create_array_from_iter_element (value_arg, key_arg);
|
||||
@@ -1216,12 +1215,12 @@ ecma_builtin_container_dispatch_routine (uint16_t builtin_routine_id, /**< built
|
||||
iterator_type = ECMA_PSEUDO_SET_ITERATOR;
|
||||
}
|
||||
|
||||
uint8_t mode = (uint8_t) (builtin_routine_id - ECMA_CONTAINER_ROUTINE_KEYS);
|
||||
ecma_iterator_kind_t kind = (ecma_iterator_kind_t) (builtin_routine_id - ECMA_CONTAINER_ROUTINE_KEYS);
|
||||
|
||||
return ecma_op_container_create_iterator (this_arg,
|
||||
mode,
|
||||
builtin_iterator_prototype,
|
||||
iterator_type);
|
||||
iterator_type,
|
||||
kind);
|
||||
}
|
||||
default:
|
||||
{
|
||||
|
||||
@@ -70,8 +70,10 @@ ecma_value_t ecma_op_container_delete_weak (ecma_extended_object_t *map_object_p
|
||||
void ecma_op_container_unref_weak (ecma_object_t *object_p, ecma_value_t ref_holder);
|
||||
void ecma_op_container_remove_weak_entry (ecma_object_t *container_p, ecma_value_t key_arg);
|
||||
void ecma_op_container_free_entries (ecma_object_t *object_p);
|
||||
ecma_value_t ecma_op_container_create_iterator (ecma_value_t this_arg, uint8_t type,
|
||||
ecma_builtin_id_t proto_id, ecma_pseudo_array_type_t iterator_type);
|
||||
ecma_value_t ecma_op_container_create_iterator (ecma_value_t this_arg,
|
||||
ecma_builtin_id_t proto_id,
|
||||
ecma_pseudo_array_type_t iterator_type,
|
||||
ecma_iterator_kind_t kind);
|
||||
ecma_value_t ecma_op_container_iterator_next (ecma_value_t this_val, ecma_pseudo_array_type_t iterator_type);
|
||||
ecma_value_t ecma_builtin_container_dispatch_routine (uint16_t builtin_routine_id, ecma_value_t this_arg,
|
||||
const ecma_value_t arguments_list_p[],
|
||||
|
||||
@@ -135,11 +135,13 @@ ecma_create_iter_result_object (ecma_value_t value, /**< value */
|
||||
ecma_value_t
|
||||
ecma_op_create_iterator_object (ecma_value_t iterated_value, /**< value from create iterator */
|
||||
ecma_object_t *prototype_obj_p, /**< prototype object */
|
||||
uint8_t iterator_type, /**< iterator type, see ecma_pseudo_array_type_t */
|
||||
uint8_t extra_info) /**< extra information */
|
||||
ecma_pseudo_array_type_t iterator_type, /**< iterator type */
|
||||
ecma_iterator_kind_t kind) /**< iterator kind*/
|
||||
{
|
||||
/* 1. */
|
||||
JERRY_ASSERT (iterator_type >= ECMA_PSEUDO_ARRAY_ITERATOR && iterator_type <= ECMA_PSEUDO_ARRAY__MAX);
|
||||
JERRY_ASSERT (iterator_type >= ECMA_PSEUDO_ARRAY_ITERATOR
|
||||
&& iterator_type <= ECMA_PSEUDO_ARRAY__MAX
|
||||
&& kind < ECMA_ITERATOR__COUNT);
|
||||
|
||||
/* 2. */
|
||||
ecma_object_t *object_p = ecma_create_object (prototype_obj_p,
|
||||
@@ -147,14 +149,14 @@ ecma_op_create_iterator_object (ecma_value_t iterated_value, /**< value from cre
|
||||
ECMA_OBJECT_TYPE_PSEUDO_ARRAY);
|
||||
|
||||
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) object_p;
|
||||
ext_obj_p->u.pseudo_array.type = iterator_type;
|
||||
ext_obj_p->u.pseudo_array.type = (uint8_t) iterator_type;
|
||||
|
||||
/* 3. */
|
||||
ext_obj_p->u.pseudo_array.u2.iterated_value = iterated_value;
|
||||
/* 4. */
|
||||
ext_obj_p->u.pseudo_array.u1.iterator_index = 0;
|
||||
/* 5. */
|
||||
ext_obj_p->u.pseudo_array.extra_info = extra_info;
|
||||
ext_obj_p->u.pseudo_array.extra_info = (uint8_t) kind;
|
||||
|
||||
/* 6. */
|
||||
return ecma_make_object_value (object_p);
|
||||
|
||||
@@ -44,8 +44,10 @@ typedef enum
|
||||
#define ECMA_ITERATOR_INDEX_LIMIT UINT16_MAX
|
||||
|
||||
ecma_value_t
|
||||
ecma_op_create_iterator_object (ecma_value_t iterated_value, ecma_object_t *prototype_obj_p,
|
||||
uint8_t iterator_type, uint8_t extra_info);
|
||||
ecma_op_create_iterator_object (ecma_value_t iterated_value,
|
||||
ecma_object_t *prototype_obj_p,
|
||||
ecma_pseudo_array_type_t iterator_type,
|
||||
ecma_iterator_kind_t kind);
|
||||
|
||||
ecma_value_t
|
||||
ecma_create_iter_result_object (ecma_value_t value, ecma_value_t done);
|
||||
|
||||
@@ -1221,6 +1221,39 @@ ecma_op_create_typedarray (const ecma_value_t *arguments_list_p, /**< the arg li
|
||||
return ret;
|
||||
} /* ecma_op_create_typedarray */
|
||||
|
||||
/**
|
||||
* Helper function for typedArray.prototype object's {'keys', 'values', 'entries', '@@iterator'}
|
||||
* routines common parts.
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 22.2.3.15
|
||||
* ECMA-262 v6, 22.2.3.29
|
||||
* ECMA-262 v6, 22.2.3.6
|
||||
* ECMA-262 v6, 22.1.3.30
|
||||
*
|
||||
* Note:
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*
|
||||
* @return iterator result object, if success
|
||||
* error - otherwise
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_typedarray_iterators_helper (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_iterator_kind_t kind) /**< iterator kind */
|
||||
{
|
||||
if (!ecma_is_typedarray (this_arg))
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a TypedArray."));
|
||||
}
|
||||
|
||||
ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_ARRAY_ITERATOR_PROTOTYPE);
|
||||
|
||||
return ecma_op_create_iterator_object (this_arg,
|
||||
prototype_obj_p,
|
||||
ECMA_PSEUDO_ARRAY_ITERATOR,
|
||||
kind);
|
||||
} /* ecma_typedarray_iterators_helper */
|
||||
|
||||
/**
|
||||
* Check if the object is typedarray
|
||||
*
|
||||
|
||||
@@ -58,6 +58,9 @@ 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);
|
||||
ecma_value_t
|
||||
ecma_typedarray_iterators_helper (ecma_value_t this_arg, ecma_iterator_kind_t kind);
|
||||
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user