Cleanup toNumber and toNumeric abstract operations (#4034)
JerryScript-DCO-1.0-Signed-off-by: Virag Orkenyi orkvi@inf.u-szeged.hu
This commit is contained in:
@@ -291,7 +291,8 @@ ecma_builtin_string_object_from_code_point (ecma_value_t this_arg, /**< 'this' a
|
||||
|
||||
for (uint32_t index = 0; index < args_number; index++)
|
||||
{
|
||||
ecma_value_t to_number_value = ecma_op_to_number (args[index], ECMA_TO_NUMERIC_NO_OPTS);
|
||||
ecma_number_t to_number_num;
|
||||
ecma_value_t to_number_value = ecma_op_to_number (args[index], &to_number_num);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (to_number_value))
|
||||
{
|
||||
@@ -299,25 +300,21 @@ ecma_builtin_string_object_from_code_point (ecma_value_t this_arg, /**< 'this' a
|
||||
return to_number_value;
|
||||
}
|
||||
|
||||
ecma_number_t to_number_num = ecma_get_number_from_value (to_number_value);
|
||||
ecma_free_value (to_number_value);
|
||||
|
||||
ecma_number_t to_int_num;
|
||||
ecma_value_t to_int_value = ecma_op_to_integer (to_number_value, &to_int_num);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (to_int_value))
|
||||
if (!ecma_op_is_integer (to_number_num))
|
||||
{
|
||||
ecma_stringbuilder_destroy (&builder);
|
||||
return to_int_value;
|
||||
return ecma_raise_range_error ("Error: Invalid code point");
|
||||
}
|
||||
|
||||
if (to_number_num != to_int_num || to_int_num < 0 || to_int_num > LIT_UNICODE_CODE_POINT_MAX)
|
||||
ecma_free_value (to_number_value);
|
||||
|
||||
if (to_number_num < 0 || to_number_num > LIT_UNICODE_CODE_POINT_MAX)
|
||||
{
|
||||
ecma_stringbuilder_destroy (&builder);
|
||||
return ecma_raise_range_error (ECMA_ERR_MSG ("Error: Invalid code point"));
|
||||
}
|
||||
|
||||
lit_code_point_t code_point = (lit_code_point_t) to_int_num;
|
||||
lit_code_point_t code_point = (lit_code_point_t) to_number_num;
|
||||
|
||||
ecma_char_t converted_cp[2];
|
||||
uint8_t encoded_size = lit_utf16_encode_code_point (code_point, converted_cp);
|
||||
|
||||
Reference in New Issue
Block a user