Update ToLength operation to conform ES6 spec (#4007)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
@@ -652,7 +652,7 @@ ecma_op_create_array_object (const ecma_value_t *arguments_list_p, /**< list of
|
||||
ecma_value_t
|
||||
ecma_op_array_species_create (ecma_object_t *original_array_p, /**< The object from whom the new array object
|
||||
* is being created */
|
||||
uint32_t length) /**< length of the array */
|
||||
ecma_length_t length) /**< length of the array */
|
||||
{
|
||||
ecma_value_t constructor = ECMA_VALUE_UNDEFINED;
|
||||
ecma_value_t original_array = ecma_make_object_value (original_array_p);
|
||||
@@ -698,7 +698,7 @@ ecma_op_array_species_create (ecma_object_t *original_array_p, /**< The object f
|
||||
|
||||
if (ecma_is_value_undefined (constructor))
|
||||
{
|
||||
ecma_value_t length_val = ecma_make_uint32_value (length);
|
||||
ecma_value_t length_val = ecma_make_length_value (length);
|
||||
ecma_value_t new_array = ecma_op_create_array_object (&length_val, 1, true);
|
||||
ecma_free_value (length_val);
|
||||
|
||||
@@ -711,7 +711,7 @@ ecma_op_array_species_create (ecma_object_t *original_array_p, /**< The object f
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Invalid species constructor"));
|
||||
}
|
||||
|
||||
ecma_value_t len_val = ecma_make_uint32_value (length);
|
||||
ecma_value_t len_val = ecma_make_length_value (length);
|
||||
ecma_object_t *ctor_object_p = ecma_get_object_from_value (constructor);
|
||||
ecma_value_t ret_val = ecma_op_function_construct (ctor_object_p,
|
||||
ctor_object_p,
|
||||
|
||||
@@ -102,7 +102,7 @@ ecma_op_create_array_object (const ecma_value_t *arguments_list_p, uint32_t argu
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ecma_value_t
|
||||
ecma_op_array_species_create (ecma_object_t *original_array_p,
|
||||
uint32_t length);
|
||||
ecma_length_t length);
|
||||
|
||||
ecma_value_t
|
||||
ecma_op_create_array_iterator (ecma_object_t *obj_p,
|
||||
|
||||
@@ -494,7 +494,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 (result);
|
||||
|
||||
result = ecma_op_object_get_by_uint32_index (next_object_p, 0);
|
||||
result = ecma_op_object_get_by_index (next_object_p, 0);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (result))
|
||||
{
|
||||
@@ -505,7 +505,7 @@ ecma_op_container_create (const ecma_value_t *arguments_list_p, /**< arguments l
|
||||
|
||||
const ecma_value_t key = result;
|
||||
|
||||
result = ecma_op_object_get_by_uint32_index (next_object_p, 1);
|
||||
result = ecma_op_object_get_by_index (next_object_p, 1);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (result))
|
||||
{
|
||||
|
||||
@@ -946,7 +946,7 @@ ecma_op_to_integer (ecma_value_t value, /**< ecma value */
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_to_length (ecma_value_t value, /**< ecma value */
|
||||
uint32_t *length) /**< [out] ecma number */
|
||||
ecma_length_t *length) /**< [out] ecma number */
|
||||
{
|
||||
/* 1 */
|
||||
if (ECMA_IS_VALUE_ERROR (value))
|
||||
@@ -973,14 +973,14 @@ ecma_op_to_length (ecma_value_t value, /**< ecma value */
|
||||
}
|
||||
|
||||
/* 5 */
|
||||
if (num >= (ecma_number_t) UINT32_MAX)
|
||||
if (num >= ECMA_NUMBER_MAX_SAFE_INTEGER)
|
||||
{
|
||||
*length = UINT32_MAX;
|
||||
*length = (ecma_length_t) ECMA_NUMBER_MAX_SAFE_INTEGER;
|
||||
return ECMA_VALUE_EMPTY;
|
||||
}
|
||||
|
||||
/* 6 */
|
||||
*length = (uint32_t) num;
|
||||
*length = (ecma_length_t) num;
|
||||
return ECMA_VALUE_EMPTY;
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
/* In the case of ES5, ToLength(ES6) operation is the same as ToUint32(ES5) */
|
||||
@@ -1026,7 +1026,7 @@ ecma_op_create_list_from_array_like (ecma_value_t arr, /**< array value */
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (arr);
|
||||
|
||||
/* 4. 5. */
|
||||
uint32_t len;
|
||||
ecma_length_t len;
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_op_object_get_length (obj_p, &len)))
|
||||
{
|
||||
return NULL;
|
||||
@@ -1036,9 +1036,9 @@ ecma_op_create_list_from_array_like (ecma_value_t arr, /**< array value */
|
||||
ecma_collection_t *list_ptr = ecma_new_collection ();
|
||||
|
||||
/* 7. 8. */
|
||||
for (uint32_t idx = 0; idx < len; idx++)
|
||||
for (ecma_length_t idx = 0; idx < len; idx++)
|
||||
{
|
||||
ecma_value_t next = ecma_op_object_get_by_uint32_index (obj_p, idx);
|
||||
ecma_value_t next = ecma_op_object_get_by_index (obj_p, idx);
|
||||
if (ECMA_IS_VALUE_ERROR (next))
|
||||
{
|
||||
ecma_collection_free (list_ptr);
|
||||
|
||||
@@ -50,7 +50,7 @@ ecma_string_t *ecma_op_to_string (ecma_value_t value);
|
||||
ecma_string_t *ecma_op_to_property_key (ecma_value_t value);
|
||||
ecma_value_t ecma_op_to_object (ecma_value_t value);
|
||||
ecma_value_t ecma_op_to_integer (ecma_value_t value, ecma_number_t *number_p);
|
||||
ecma_value_t ecma_op_to_length (ecma_value_t value, uint32_t *length);
|
||||
ecma_value_t ecma_op_to_length (ecma_value_t value, ecma_length_t *length);
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ecma_collection_t *ecma_op_create_list_from_array_like (ecma_value_t arr, bool prop_names_only);
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
@@ -105,11 +105,12 @@ ecma_op_dataview_create (const ecma_value_t *arguments_list_p, /**< arguments li
|
||||
}
|
||||
|
||||
/* 11 - 12. */
|
||||
uint32_t viewByteLength;
|
||||
uint32_t view_byte_length;
|
||||
if (arguments_list_len > 2 && !ecma_is_value_undefined (arguments_list_p[2]))
|
||||
{
|
||||
/* 12.a */
|
||||
ecma_value_t byte_length_value = ecma_op_to_length (arguments_list_p[2], &viewByteLength);
|
||||
ecma_length_t view_byte_to_length;
|
||||
ecma_value_t byte_length_value = ecma_op_to_length (arguments_list_p[2], &view_byte_to_length);
|
||||
|
||||
/* 12.b */
|
||||
if (ECMA_IS_VALUE_ERROR (byte_length_value))
|
||||
@@ -118,15 +119,18 @@ ecma_op_dataview_create (const ecma_value_t *arguments_list_p, /**< arguments li
|
||||
}
|
||||
|
||||
/* 12.c */
|
||||
if ((ecma_number_t) offset + viewByteLength > buffer_byte_length)
|
||||
if ((ecma_number_t) offset + (ecma_number_t) view_byte_to_length > buffer_byte_length)
|
||||
{
|
||||
return ecma_raise_range_error (ECMA_ERR_MSG ("Start offset is outside the bounds of the buffer."));
|
||||
}
|
||||
|
||||
JERRY_ASSERT (view_byte_to_length <= UINT32_MAX);
|
||||
view_byte_length = (uint32_t) view_byte_to_length;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 11.a */
|
||||
viewByteLength = (uint32_t) (buffer_byte_length - offset);
|
||||
view_byte_length = (uint32_t) (buffer_byte_length - offset);
|
||||
}
|
||||
|
||||
/* 13. */
|
||||
@@ -143,7 +147,7 @@ ecma_op_dataview_create (const ecma_value_t *arguments_list_p, /**< arguments li
|
||||
|
||||
ecma_dataview_object_t *dataview_obj_p = (ecma_dataview_object_t *) object_p;
|
||||
dataview_obj_p->header.u.class_prop.class_id = LIT_MAGIC_STRING_DATAVIEW_UL;
|
||||
dataview_obj_p->header.u.class_prop.u.length = viewByteLength;
|
||||
dataview_obj_p->header.u.class_prop.u.length = view_byte_length;
|
||||
dataview_obj_p->buffer_p = buffer_p;
|
||||
dataview_obj_p->byte_offset = (uint32_t) offset;
|
||||
|
||||
|
||||
@@ -671,7 +671,7 @@ ecma_op_object_find_own (ecma_value_t base_value, /**< base value */
|
||||
} /* ecma_op_object_find_own */
|
||||
|
||||
/**
|
||||
* Search the value corresponding to an uint32_t property index
|
||||
* Search the value corresponding to a property index
|
||||
*
|
||||
* Note: this method falls back to the general ecma_op_object_find
|
||||
*
|
||||
@@ -680,40 +680,20 @@ ecma_op_object_find_own (ecma_value_t base_value, /**< base value */
|
||||
* Returned value must be freed with ecma_free_value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_object_find_by_uint32_index (ecma_object_t *object_p, /**< the object */
|
||||
uint32_t index) /**< property index */
|
||||
ecma_op_object_find_by_index (ecma_object_t *object_p, /**< the object */
|
||||
ecma_length_t index) /**< property index */
|
||||
{
|
||||
if (JERRY_LIKELY (index <= ECMA_DIRECT_STRING_MAX_IMM))
|
||||
{
|
||||
return ecma_op_object_find (object_p, ECMA_CREATE_DIRECT_UINT32_STRING (index));
|
||||
}
|
||||
|
||||
ecma_string_t *index_str_p = ecma_new_non_direct_string_from_uint32 (index);
|
||||
ecma_string_t *index_str_p = ecma_new_ecma_string_from_length (index);
|
||||
ecma_value_t ret_value = ecma_op_object_find (object_p, index_str_p);
|
||||
ecma_deref_ecma_string (index_str_p);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_op_object_find_by_uint32_index */
|
||||
|
||||
/**
|
||||
* Search the value corresponding to an ecma_number_t property index
|
||||
*
|
||||
* Note: this method falls back to the general ecma_op_object_find
|
||||
*
|
||||
* @return ecma value if property is found
|
||||
* ECMA_VALUE_NOT_FOUND if property is not found
|
||||
* Returned value must be freed with ecma_free_value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_object_find_by_number_index (ecma_object_t *object_p, /**< the object */
|
||||
ecma_number_t index) /**< property index */
|
||||
{
|
||||
ecma_string_t *index_str_p = ecma_new_ecma_string_from_number (index);
|
||||
ecma_value_t ret_value = ecma_op_object_find (object_p, index_str_p);
|
||||
ecma_deref_ecma_string (index_str_p);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_op_object_find_by_number_index */
|
||||
} /* ecma_op_object_find_by_index */
|
||||
|
||||
/**
|
||||
* Search the value corresponding to a property name
|
||||
@@ -827,26 +807,26 @@ ecma_op_object_get_with_receiver (ecma_object_t *object_p, /**< the object */
|
||||
} /* ecma_op_object_get_with_receiver */
|
||||
|
||||
/**
|
||||
* [[Get]] operation of ecma object specified for uint32_t property index
|
||||
* [[Get]] operation of ecma object specified for 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 */
|
||||
ecma_op_object_get_by_index (ecma_object_t *object_p, /**< the object */
|
||||
ecma_length_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_string_t *index_str_p = ecma_new_ecma_string_from_length (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 */
|
||||
} /* ecma_op_object_get_by_index */
|
||||
|
||||
/**
|
||||
* Perform ToLength(O.[[Get]]("length")) operation
|
||||
@@ -858,11 +838,11 @@ ecma_op_object_get_by_uint32_index (ecma_object_t *object_p, /**< the object */
|
||||
*/
|
||||
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 */
|
||||
ecma_length_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);
|
||||
*length_p = (ecma_length_t) ecma_array_get_length (object_p);
|
||||
return ECMA_VALUE_EMPTY;
|
||||
}
|
||||
|
||||
@@ -1023,7 +1003,7 @@ ecma_op_get_method_by_magic_id (ecma_value_t value, /**< ecma value */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* [[Put]] ecma general object's operation specialized for uint32_ property index
|
||||
* [[Put]] ecma general object's operation specialized for property index
|
||||
*
|
||||
* Note: This function falls back to the general ecma_op_object_put
|
||||
*
|
||||
@@ -1031,10 +1011,10 @@ ecma_op_get_method_by_magic_id (ecma_value_t value, /**< ecma value */
|
||||
* The returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_object_put_by_uint32_index (ecma_object_t *object_p, /**< the object */
|
||||
uint32_t index, /**< property index */
|
||||
ecma_value_t value, /**< ecma value */
|
||||
bool is_throw) /**< flag that controls failure handling */
|
||||
ecma_op_object_put_by_index (ecma_object_t *object_p, /**< the object */
|
||||
ecma_length_t index, /**< property index */
|
||||
ecma_value_t value, /**< ecma value */
|
||||
bool is_throw) /**< flag that controls failure handling */
|
||||
{
|
||||
if (JERRY_LIKELY (index <= ECMA_DIRECT_STRING_MAX_IMM))
|
||||
{
|
||||
@@ -1044,33 +1024,12 @@ ecma_op_object_put_by_uint32_index (ecma_object_t *object_p, /**< the object */
|
||||
is_throw);
|
||||
}
|
||||
|
||||
ecma_string_t *index_str_p = ecma_new_non_direct_string_from_uint32 (index);
|
||||
ecma_string_t *index_str_p = ecma_new_ecma_string_from_length (index);
|
||||
ecma_value_t ret_value = ecma_op_object_put (object_p, index_str_p, value, is_throw);
|
||||
ecma_deref_ecma_string (index_str_p);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_op_object_put_by_uint32_index */
|
||||
|
||||
/**
|
||||
* [[Put]] ecma general object's operation specialized for ecma_number_ property index
|
||||
*
|
||||
* Note: This function falls back to the general ecma_op_object_put
|
||||
*
|
||||
* @return ecma value
|
||||
* The returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_object_put_by_number_index (ecma_object_t *object_p, /**< the object */
|
||||
ecma_number_t index, /**< property index */
|
||||
ecma_value_t value, /**< ecma value */
|
||||
bool is_throw) /**< flag that controls failure handling */
|
||||
{
|
||||
ecma_string_t *index_str_p = ecma_new_ecma_string_from_number (index);
|
||||
ecma_value_t ret_value = ecma_op_object_put (object_p, index_str_p, value, is_throw);
|
||||
ecma_deref_ecma_string (index_str_p);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_op_object_put_by_number_index */
|
||||
} /* ecma_op_object_put_by_index */
|
||||
|
||||
/**
|
||||
* [[Put]] ecma general object's operation
|
||||
@@ -1568,7 +1527,7 @@ ecma_op_object_put_with_receiver (ecma_object_t *object_p, /**< the object */
|
||||
} /* ecma_op_object_put_with_receiver */
|
||||
|
||||
/**
|
||||
* [[Delete]] ecma object's operation specialized for uint32_t property index
|
||||
* [[Delete]] ecma object's operation specialized for property index
|
||||
*
|
||||
* Note:
|
||||
* This method falls back to the general ecma_op_object_delete
|
||||
@@ -1577,42 +1536,21 @@ ecma_op_object_put_with_receiver (ecma_object_t *object_p, /**< the object */
|
||||
* false - or type error otherwise (based in 'is_throw')
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_object_delete_by_uint32_index (ecma_object_t *obj_p, /**< the object */
|
||||
uint32_t index, /**< property index */
|
||||
bool is_throw) /**< flag that controls failure handling */
|
||||
ecma_op_object_delete_by_index (ecma_object_t *obj_p, /**< the object */
|
||||
ecma_length_t index, /**< property index */
|
||||
bool is_throw) /**< flag that controls failure handling */
|
||||
{
|
||||
if (JERRY_LIKELY (index <= ECMA_DIRECT_STRING_MAX_IMM))
|
||||
{
|
||||
return ecma_op_object_delete (obj_p, ECMA_CREATE_DIRECT_UINT32_STRING (index), is_throw);
|
||||
return ecma_op_object_delete (obj_p, ECMA_CREATE_DIRECT_UINT32_STRING (index), is_throw);;
|
||||
}
|
||||
|
||||
ecma_string_t *index_str_p = ecma_new_non_direct_string_from_uint32 (index);
|
||||
ecma_string_t *index_str_p = ecma_new_ecma_string_from_length (index);
|
||||
ecma_value_t ret_value = ecma_op_object_delete (obj_p, index_str_p, is_throw);
|
||||
ecma_deref_ecma_string (index_str_p);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_op_object_delete_by_uint32_index */
|
||||
|
||||
/**
|
||||
* [[Delete]] ecma object's operation specialized for ecma_number_t property index
|
||||
*
|
||||
* Note:
|
||||
* This method falls back to the general ecma_op_object_delete
|
||||
*
|
||||
* @return true - if deleted successfully
|
||||
* false - or type error otherwise (based in 'is_throw')
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_object_delete_by_number_index (ecma_object_t *obj_p, /**< the object */
|
||||
ecma_number_t index, /**< property index */
|
||||
bool is_throw) /**< flag that controls failure handling */
|
||||
{
|
||||
ecma_string_t *index_str_p = ecma_new_ecma_string_from_number (index);
|
||||
ecma_value_t ret_value = ecma_op_object_delete (obj_p, index_str_p, is_throw);
|
||||
ecma_deref_ecma_string (index_str_p);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_op_object_delete_by_number_index */
|
||||
} /* ecma_op_object_delete_by_index */
|
||||
|
||||
/**
|
||||
* [[Delete]] ecma object's operation
|
||||
|
||||
@@ -33,13 +33,12 @@ bool ecma_op_ordinary_object_has_own_property (ecma_object_t *object_p, ecma_str
|
||||
ecma_value_t ecma_op_object_has_property (ecma_object_t *object_p, ecma_string_t *property_name_p);
|
||||
ecma_value_t ecma_op_object_find_own (ecma_value_t base_value, ecma_object_t *object_p, ecma_string_t *property_name_p);
|
||||
ecma_value_t ecma_op_object_find (ecma_object_t *object_p, ecma_string_t *property_name_p);
|
||||
ecma_value_t ecma_op_object_find_by_uint32_index (ecma_object_t *object_p, uint32_t index);
|
||||
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_find_by_index (ecma_object_t *object_p, ecma_length_t index);
|
||||
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_with_receiver (ecma_object_t *object_p, ecma_string_t *property_name_p,
|
||||
ecma_value_t receiver);
|
||||
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_length (ecma_object_t *object_p, ecma_length_t *length_p);
|
||||
ecma_value_t ecma_op_object_get_by_index (ecma_object_t *object_p, ecma_length_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_ESNEXT)
|
||||
ecma_string_t *ecma_op_get_global_symbol (lit_magic_string_id_t property_id);
|
||||
@@ -53,13 +52,10 @@ ecma_value_t ecma_op_object_put (ecma_object_t *object_p, ecma_string_t *propert
|
||||
bool is_throw);
|
||||
ecma_value_t ecma_op_object_put_with_receiver (ecma_object_t *object_p, ecma_string_t *property_name_p,
|
||||
ecma_value_t value, ecma_value_t receiver, bool is_throw);
|
||||
ecma_value_t ecma_op_object_put_by_uint32_index (ecma_object_t *object_p, uint32_t index,
|
||||
ecma_value_t value, bool is_throw);
|
||||
ecma_value_t ecma_op_object_put_by_number_index (ecma_object_t *object_p, ecma_number_t index,
|
||||
ecma_value_t value, bool is_throw);
|
||||
ecma_value_t ecma_op_object_put_by_index (ecma_object_t *object_p, ecma_length_t index,
|
||||
ecma_value_t value, bool is_throw);
|
||||
ecma_value_t ecma_op_object_delete (ecma_object_t *obj_p, ecma_string_t *property_name_p, bool is_throw);
|
||||
ecma_value_t ecma_op_object_delete_by_uint32_index (ecma_object_t *obj_p, uint32_t index, bool is_throw);
|
||||
ecma_value_t ecma_op_object_delete_by_number_index (ecma_object_t *obj_p, ecma_number_t index, bool is_throw);
|
||||
ecma_value_t ecma_op_object_delete_by_index (ecma_object_t *obj_p, ecma_length_t index, bool is_throw);
|
||||
ecma_value_t ecma_op_object_default_value (ecma_object_t *obj_p, ecma_preferred_type_hint_t hint);
|
||||
ecma_value_t ecma_op_object_define_own_property (ecma_object_t *obj_p, ecma_string_t *property_name_p,
|
||||
const ecma_property_descriptor_t *property_desc_p);
|
||||
|
||||
@@ -598,10 +598,10 @@ ecma_promise_all_handler_cb (const ecma_value_t function_obj, /**< the function
|
||||
}
|
||||
|
||||
/* 8. */
|
||||
ecma_op_object_put_by_uint32_index (ecma_get_object_from_value (executor_p->values),
|
||||
(uint32_t) (executor_p->index - 1),
|
||||
args_p[0],
|
||||
false);
|
||||
ecma_op_object_put_by_index (ecma_get_object_from_value (executor_p->values),
|
||||
(uint32_t) (executor_p->index - 1),
|
||||
args_p[0],
|
||||
false);
|
||||
/* 3. */
|
||||
executor_p->index = 0;
|
||||
|
||||
|
||||
@@ -1762,7 +1762,7 @@ ecma_regexp_exec_helper (ecma_object_t *regexp_object_p, /**< RegExp object */
|
||||
input_end_p);
|
||||
|
||||
/* 4. */
|
||||
uint32_t index = 0;
|
||||
ecma_length_t index = 0;
|
||||
ecma_value_t lastindex_value = ecma_op_object_get_by_magic_id (regexp_object_p, LIT_MAGIC_STRING_LASTINDEX_UL);
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
@@ -1908,11 +1908,11 @@ match_found:
|
||||
goto cleanup_context;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (index <= input_length);
|
||||
|
||||
/* 15. */
|
||||
if (re_ctx.flags & (RE_FLAG_GLOBAL | RE_FLAG_STICKY))
|
||||
{
|
||||
JERRY_ASSERT (index <= input_length);
|
||||
|
||||
/* 13-14. */
|
||||
lit_utf8_size_t match_length;
|
||||
const lit_utf8_byte_t *match_begin_p = re_ctx.captures_p[0].begin_p;
|
||||
@@ -1930,7 +1930,7 @@ match_found:
|
||||
|
||||
ret_value = ecma_op_object_put (regexp_object_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL),
|
||||
ecma_make_uint32_value (index + match_length),
|
||||
ecma_make_uint32_value ((uint32_t) index + match_length),
|
||||
true);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (ret_value))
|
||||
@@ -1942,7 +1942,7 @@ match_found:
|
||||
}
|
||||
|
||||
/* 16-27. */
|
||||
ret_value = ecma_regexp_create_result_object (&re_ctx, input_string_p, index);
|
||||
ret_value = ecma_regexp_create_result_object (&re_ctx, input_string_p, (uint32_t) index);
|
||||
|
||||
cleanup_context:
|
||||
ecma_regexp_cleanup_context (&re_ctx);
|
||||
@@ -2202,7 +2202,7 @@ ecma_regexp_split_helper (ecma_value_t this_arg, /**< this value */
|
||||
ecma_object_t *const splitter_obj_p = ecma_get_object_from_value (splitter);
|
||||
|
||||
/* 17. */
|
||||
uint32_t limit = UINT32_MAX;
|
||||
uint32_t limit = UINT32_MAX - 1;
|
||||
if (!ecma_is_value_undefined (limit_arg))
|
||||
{
|
||||
/* ECMA-262 v11, 21.2.5.13 13 */
|
||||
@@ -2299,7 +2299,7 @@ ecma_regexp_split_helper (ecma_value_t this_arg, /**< this value */
|
||||
goto cleanup_array;
|
||||
}
|
||||
|
||||
uint32_t end_index;
|
||||
ecma_length_t end_index;
|
||||
const ecma_value_t length_value = ecma_op_to_length (result, &end_index);
|
||||
ecma_free_value (result);
|
||||
|
||||
@@ -2343,10 +2343,11 @@ ecma_regexp_split_helper (ecma_value_t this_arg, /**< this value */
|
||||
}
|
||||
|
||||
/* 24.f.iv.6. */
|
||||
previous_index = end_index;
|
||||
JERRY_ASSERT (end_index <= UINT32_MAX);
|
||||
previous_index = (uint32_t) end_index;
|
||||
|
||||
/* 24.f.iv.7-8. */
|
||||
uint32_t match_length;
|
||||
ecma_length_t match_length;
|
||||
result = ecma_op_object_get_length (match_array_p, &match_length);
|
||||
if (ECMA_IS_VALUE_ERROR (result))
|
||||
{
|
||||
@@ -2357,11 +2358,11 @@ ecma_regexp_split_helper (ecma_value_t this_arg, /**< this value */
|
||||
/* 24.f.iv.9. */
|
||||
match_length = (match_length > 0) ? match_length - 1 : match_length;
|
||||
|
||||
uint32_t match_index = 1;
|
||||
ecma_length_t match_index = 1;
|
||||
while (match_index <= match_length)
|
||||
{
|
||||
/* 24.f.iv.11.a-b. */
|
||||
result = ecma_op_object_get_by_uint32_index (match_array_p, match_index++);
|
||||
result = ecma_op_object_get_by_index (match_array_p, match_index++);
|
||||
if (ECMA_IS_VALUE_ERROR (result))
|
||||
{
|
||||
ecma_deref_object (match_array_p);
|
||||
@@ -2388,7 +2389,8 @@ ecma_regexp_split_helper (ecma_value_t this_arg, /**< this value */
|
||||
}
|
||||
|
||||
/* 24.f.iv.12. */
|
||||
current_index = end_index;
|
||||
JERRY_ASSERT (end_index <= UINT32_MAX);
|
||||
current_index = (uint32_t) end_index;
|
||||
|
||||
ecma_deref_object (match_array_p);
|
||||
}
|
||||
@@ -2412,7 +2414,7 @@ cleanup_string:
|
||||
ecma_deref_ecma_string (string_p);
|
||||
|
||||
return result;
|
||||
#else /* ENABLED (JERRY_ESNEXT) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
ecma_value_t result = ECMA_VALUE_ERROR;
|
||||
|
||||
/* 2. */
|
||||
@@ -2625,7 +2627,7 @@ ecma_regexp_replace_helper_fast (ecma_replace_context_t *ctx_p, /**<replace cont
|
||||
const lit_utf8_byte_t *matched_p = NULL;
|
||||
const lit_utf8_byte_t *current_p = ctx_p->string_p;
|
||||
const lit_utf8_byte_t *last_append_p = current_p;
|
||||
lit_utf8_size_t index;
|
||||
ecma_length_t index;
|
||||
|
||||
ecma_regexp_ctx_t re_ctx;
|
||||
ecma_regexp_initialize_context (&re_ctx,
|
||||
@@ -2671,7 +2673,7 @@ ecma_regexp_replace_helper_fast (ecma_replace_context_t *ctx_p, /**<replace cont
|
||||
}
|
||||
else
|
||||
{
|
||||
lit_utf8_size_t counter = index;
|
||||
ecma_length_t counter = index;
|
||||
while (counter--)
|
||||
{
|
||||
lit_utf8_incr (¤t_p);
|
||||
@@ -2722,7 +2724,7 @@ ecma_regexp_replace_helper_fast (ecma_replace_context_t *ctx_p, /**<replace cont
|
||||
ecma_collection_push_back (arguments_p, capture);
|
||||
}
|
||||
|
||||
ecma_collection_push_back (arguments_p, ecma_make_uint32_value (index));
|
||||
ecma_collection_push_back (arguments_p, ecma_make_length_value (index));
|
||||
ecma_ref_ecma_string (string_p);
|
||||
ecma_collection_push_back (arguments_p, ecma_make_string_value (string_p));
|
||||
ecma_object_t *function_p = ecma_get_object_from_value (replace_arg);
|
||||
@@ -2768,7 +2770,7 @@ ecma_regexp_replace_helper_fast (ecma_replace_context_t *ctx_p, /**<replace cont
|
||||
{
|
||||
result = ecma_op_object_put ((ecma_object_t *) re_obj_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL),
|
||||
ecma_make_uint32_value (index),
|
||||
ecma_make_length_value (index),
|
||||
true);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (result))
|
||||
@@ -3031,7 +3033,7 @@ ecma_regexp_replace_helper (ecma_value_t this_arg, /**< this argument */
|
||||
}
|
||||
|
||||
/* 13.d.iii.1 */
|
||||
result = ecma_op_object_get_by_uint32_index (ecma_get_object_from_value (result), 0);
|
||||
result = ecma_op_object_get_by_index (ecma_get_object_from_value (result), 0);
|
||||
if (ECMA_IS_VALUE_ERROR (result))
|
||||
{
|
||||
goto cleanup_results;
|
||||
@@ -3058,7 +3060,7 @@ ecma_regexp_replace_helper (ecma_value_t this_arg, /**< this argument */
|
||||
goto cleanup_results;
|
||||
}
|
||||
|
||||
uint32_t index;
|
||||
ecma_length_t index;
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_op_to_length (result, &index)))
|
||||
{
|
||||
ecma_free_value (result);
|
||||
@@ -3073,7 +3075,7 @@ ecma_regexp_replace_helper (ecma_value_t this_arg, /**< this argument */
|
||||
/* 10.d.iii.3.c */
|
||||
result = ecma_op_object_put (this_obj_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL),
|
||||
ecma_make_uint32_value (index),
|
||||
ecma_make_length_value (index),
|
||||
true);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (result))
|
||||
@@ -3117,7 +3119,7 @@ ecma_regexp_replace_helper (ecma_value_t this_arg, /**< this argument */
|
||||
/* 16.a */
|
||||
ecma_object_t *current_object_p = ecma_get_object_from_value (*current_p);
|
||||
|
||||
uint32_t capture_count;
|
||||
ecma_length_t capture_count;
|
||||
result = ecma_op_object_get_length (current_object_p, &capture_count);
|
||||
if (ECMA_IS_VALUE_ERROR (result))
|
||||
{
|
||||
@@ -3128,7 +3130,7 @@ ecma_regexp_replace_helper (ecma_value_t this_arg, /**< this argument */
|
||||
capture_count = (capture_count > 0) ? capture_count - 1 : capture_count;
|
||||
|
||||
/* 16.d */
|
||||
result = ecma_op_object_get_by_uint32_index (current_object_p, 0);
|
||||
result = ecma_op_object_get_by_index (current_object_p, 0);
|
||||
if (ECMA_IS_VALUE_ERROR (result))
|
||||
{
|
||||
goto cleanup_builder;
|
||||
@@ -3172,10 +3174,10 @@ ecma_regexp_replace_helper (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_collection_push_back (arguments_p, ecma_make_string_value (matched_str_p));
|
||||
|
||||
/* 16.j, l */
|
||||
uint32_t n = 1;
|
||||
ecma_length_t n = 1;
|
||||
while (n <= capture_count)
|
||||
{
|
||||
result = ecma_op_object_get_by_uint32_index (current_object_p, n);
|
||||
result = ecma_op_object_get_by_index (current_object_p, n);
|
||||
if (ECMA_IS_VALUE_ERROR (result))
|
||||
{
|
||||
ecma_collection_free (arguments_p);
|
||||
@@ -3435,7 +3437,7 @@ ecma_regexp_match_helper (ecma_value_t this_arg, /**< this argument */
|
||||
}
|
||||
|
||||
ecma_object_t *result_value_p = ecma_get_object_from_value (result_value);
|
||||
ecma_value_t match_value = ecma_op_object_get_by_uint32_index (result_value_p, 0);
|
||||
ecma_value_t match_value = ecma_op_object_get_by_index (result_value_p, 0);
|
||||
|
||||
ecma_deref_object (result_value_p);
|
||||
|
||||
@@ -3472,7 +3474,7 @@ ecma_regexp_match_helper (ecma_value_t this_arg, /**< this argument */
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
uint32_t index;
|
||||
ecma_length_t index;
|
||||
ecma_value_t length_value = ecma_op_to_length (this_index, &index);
|
||||
|
||||
ecma_free_value (this_index);
|
||||
|
||||
@@ -894,8 +894,8 @@ ecma_op_typedarray_from (ecma_value_t items_val, /**< the source array-like obje
|
||||
ecma_object_t *arraylike_object_p = ecma_get_object_from_value (arraylike_object_val);
|
||||
|
||||
/* 12 */
|
||||
uint32_t len;
|
||||
ecma_value_t len_value = ecma_op_object_get_length (arraylike_object_p, &len);
|
||||
ecma_length_t length_index;
|
||||
ecma_value_t len_value = ecma_op_object_get_length (arraylike_object_p, &length_index);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (len_value))
|
||||
{
|
||||
@@ -903,6 +903,14 @@ ecma_op_typedarray_from (ecma_value_t items_val, /**< the source array-like obje
|
||||
return len_value;
|
||||
}
|
||||
|
||||
if (length_index >= UINT32_MAX)
|
||||
{
|
||||
ecma_deref_object (arraylike_object_p);
|
||||
return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid TypedArray length"));
|
||||
}
|
||||
|
||||
uint32_t len = (uint32_t) length_index;
|
||||
|
||||
/* 14 */
|
||||
ecma_value_t new_typedarray = ecma_typedarray_create_object_with_length (len,
|
||||
NULL,
|
||||
@@ -924,7 +932,7 @@ ecma_op_typedarray_from (ecma_value_t items_val, /**< the source array-like obje
|
||||
/* 17 */
|
||||
for (uint32_t index = 0; index < len; index++)
|
||||
{
|
||||
ecma_value_t current_value = ecma_op_object_find_by_uint32_index (arraylike_object_p, index);
|
||||
ecma_value_t current_value = ecma_op_object_find_by_index (arraylike_object_p, index);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (current_value))
|
||||
{
|
||||
@@ -1173,7 +1181,7 @@ ecma_op_create_typedarray (const ecma_value_t *arguments_list_p, /**< the arg li
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t new_length;
|
||||
ecma_length_t new_length;
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_op_to_length (arg3, &new_length)))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
|
||||
Reference in New Issue
Block a user