Introducing ecma_get_[type]_from_value, ecma_get_[type]_from_completion_value and ecma_get_completion_value_value interfaces.

This commit is contained in:
Ruben Ayrapetyan
2014-11-27 14:19:53 +03:00
parent 22e1941050
commit 815309c7e9
35 changed files with 370 additions and 240 deletions
@@ -82,7 +82,7 @@ ecma_builtin_error_prototype_object_to_string (ecma_value_t this) /**< this argu
}
else
{
name_to_str_completion = ecma_op_to_string (name_get_completion.u.value);
name_to_str_completion = ecma_op_to_string (ecma_get_completion_value_value (name_get_completion));
}
if (unlikely (!ecma_is_completion_value_normal (name_to_str_completion)))
@@ -107,7 +107,7 @@ ecma_builtin_error_prototype_object_to_string (ecma_value_t this) /**< this argu
}
else
{
msg_to_str_completion = ecma_op_to_string (msg_get_completion.u.value);
msg_to_str_completion = ecma_op_to_string (ecma_get_completion_value_value (msg_get_completion));
}
if (unlikely (!ecma_is_completion_value_normal (msg_to_str_completion)))
@@ -116,11 +116,11 @@ ecma_builtin_error_prototype_object_to_string (ecma_value_t this) /**< this argu
}
else
{
JERRY_ASSERT (ecma_is_value_string (name_to_str_completion.u.value));
JERRY_ASSERT (ecma_is_value_string (msg_to_str_completion.u.value));
JERRY_ASSERT (ecma_is_value_string (ecma_get_completion_value_value (name_to_str_completion)));
JERRY_ASSERT (ecma_is_value_string (ecma_get_completion_value_value (msg_to_str_completion)));
ecma_string_t *name_string_p = ECMA_GET_NON_NULL_POINTER (name_to_str_completion.u.value.value);
ecma_string_t *msg_string_p = ECMA_GET_NON_NULL_POINTER (msg_to_str_completion.u.value.value);
ecma_string_t *name_string_p = ecma_get_string_from_completion_value (name_to_str_completion);
ecma_string_t *msg_string_p = ecma_get_string_from_completion_value (msg_to_str_completion);
ecma_string_t *ret_str_p;
+1 -1
View File
@@ -63,7 +63,7 @@ ecma_builtin_error_dispatch_call (ecma_value_t *arguments_list_p, /**< arguments
ecma_op_to_string (arguments_list_p[0]),
ret_value);
ecma_string_t *message_string_p = ECMA_GET_NON_NULL_POINTER (msg_to_str_completion.u.value.value);
ecma_string_t *message_string_p = ecma_get_string_from_completion_value (msg_to_str_completion);
ecma_object_t *new_error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_COMMON,
message_string_p);
ret_value = ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p));
+1 -1
View File
@@ -63,7 +63,7 @@ ecma_builtin_eval_error_dispatch_call (ecma_value_t *arguments_list_p, /**< argu
ecma_op_to_string (arguments_list_p[0]),
ret_value);
ecma_string_t *message_string_p = ECMA_GET_NON_NULL_POINTER (msg_to_str_completion.u.value.value);
ecma_string_t *message_string_p = ecma_get_string_from_completion_value (msg_to_str_completion);
ecma_object_t *new_error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_EVAL,
message_string_p);
ret_value = ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p));
+2 -2
View File
@@ -105,7 +105,7 @@ ecma_builtin_global_object_is_nan (ecma_value_t this_arg __unused, /**< this arg
ECMA_TRY_CATCH (num_value, ecma_op_to_number (arg), ret_value);
ecma_number_t *num_p = ECMA_GET_NON_NULL_POINTER (num_value.u.value.value);
ecma_number_t *num_p = ecma_get_number_from_completion_value (num_value);
bool is_nan = ecma_number_is_nan (*num_p);
@@ -134,7 +134,7 @@ ecma_builtin_global_object_is_finite (ecma_value_t this_arg __unused, /**< this
ECMA_TRY_CATCH (num_value, ecma_op_to_number (arg), ret_value);
ecma_number_t *num_p = ECMA_GET_NON_NULL_POINTER (num_value.u.value.value);
ecma_number_t *num_p = ecma_get_number_from_completion_value (num_value);
bool is_finite = !(ecma_number_is_nan (*num_p)
|| ecma_number_is_infinity (*num_p));
+9 -9
View File
@@ -66,7 +66,7 @@ ecma_builtin_math_object_abs (ecma_value_t this_arg __unused, /**< 'this' argume
ecma_number_t *num_p = ecma_alloc_number ();
const ecma_number_t arg_num = *(ecma_number_t*) ECMA_GET_NON_NULL_POINTER (arg_num_value.u.value.value);
const ecma_number_t arg_num = *ecma_get_number_from_completion_value (arg_num_value);
if (ecma_number_is_nan (arg_num))
{
@@ -202,7 +202,7 @@ ecma_builtin_math_object_exp (ecma_value_t this_arg __unused, /**< 'this' argume
ecma_number_t *num_p = ecma_alloc_number ();
const ecma_number_t arg_num = *(ecma_number_t*) ECMA_GET_NON_NULL_POINTER (arg_num_value.u.value.value);
const ecma_number_t arg_num = *ecma_get_number_from_completion_value (arg_num_value);
if (ecma_number_is_nan (arg_num))
{
@@ -272,7 +272,7 @@ ecma_builtin_math_object_log (ecma_value_t this_arg __unused, /**< 'this' argume
ecma_number_t *num_p = ecma_alloc_number ();
const ecma_number_t arg_num = *(ecma_number_t*) ECMA_GET_NON_NULL_POINTER (arg_num_value.u.value.value);
const ecma_number_t arg_num = *ecma_get_number_from_completion_value (arg_num_value);
if (ecma_number_is_nan (arg_num))
{
@@ -332,7 +332,7 @@ ecma_builtin_math_object_max (ecma_value_t this_arg __unused, /**< 'this' argume
if (!is_just_convert)
{
ecma_number_t arg_num = *(ecma_number_t*) ECMA_GET_NON_NULL_POINTER (arg_num_value.u.value.value);
ecma_number_t arg_num = *ecma_get_number_from_completion_value (arg_num_value);
if (unlikely (ecma_number_is_nan (arg_num)))
{
@@ -423,7 +423,7 @@ ecma_builtin_math_object_min (ecma_value_t this_arg __unused, /**< 'this' argume
if (!is_just_convert)
{
ecma_number_t arg_num = *(ecma_number_t*) ECMA_GET_NON_NULL_POINTER (arg_num_value.u.value.value);
ecma_number_t arg_num = *ecma_get_number_from_completion_value (arg_num_value);
if (unlikely (ecma_number_is_nan (arg_num)))
{
@@ -509,8 +509,8 @@ ecma_builtin_math_object_pow (ecma_value_t this_arg __unused, /**< 'this' argume
ecma_number_t *num_p = ecma_alloc_number ();
const ecma_number_t x = *(ecma_number_t*) ECMA_GET_NON_NULL_POINTER (arg1_num_value.u.value.value);
const ecma_number_t y = *(ecma_number_t*) ECMA_GET_NON_NULL_POINTER (arg2_num_value.u.value.value);
const ecma_number_t x = *ecma_get_number_from_completion_value (arg1_num_value);
const ecma_number_t y = *ecma_get_number_from_completion_value (arg2_num_value);
if (ecma_number_is_nan (y)
|| (ecma_number_is_nan (x)
@@ -787,7 +787,7 @@ ecma_builtin_math_object_round (ecma_value_t this_arg __unused, /**< 'this' argu
ecma_number_t *num_p = ecma_alloc_number ();
const ecma_number_t arg_num = *(ecma_number_t*) ECMA_GET_NON_NULL_POINTER (arg_num_value.u.value.value);
const ecma_number_t arg_num = *ecma_get_number_from_completion_value (arg_num_value);
if (ecma_number_is_nan (arg_num)
|| ecma_number_is_zero (arg_num)
@@ -859,7 +859,7 @@ ecma_builtin_math_object_sqrt (ecma_value_t this_arg __unused, /**< 'this' argum
ecma_op_to_number (arg),
ret_value);
const ecma_number_t arg_num = *(ecma_number_t*) ECMA_GET_NON_NULL_POINTER (arg_num_value.u.value.value);
const ecma_number_t arg_num = *ecma_get_number_from_completion_value (arg_num_value);
ecma_number_t ret_num;
if (ecma_number_is_nan (arg_num)
@@ -73,9 +73,9 @@ ecma_builtin_object_prototype_object_to_string (ecma_value_t this) /**< this arg
return obj_this;
}
JERRY_ASSERT (ecma_is_value_object (obj_this.u.value));
JERRY_ASSERT (ecma_is_value_object (ecma_get_completion_value_value (obj_this)));
ecma_object_t *obj_p = ECMA_GET_NON_NULL_POINTER (obj_this.u.value.value);
ecma_object_t *obj_p = ecma_get_object_from_completion_value (obj_this);
ecma_property_t *class_prop_p = ecma_get_internal_property (obj_p,
ECMA_INTERNAL_PROPERTY_CLASS);
+2 -2
View File
@@ -96,7 +96,7 @@ ecma_builtin_object_dispatch_construct (ecma_value_t *arguments_list_p, /**< arg
}
else
{
return ecma_make_normal_completion_value (new_obj_value.u.value);
return ecma_make_normal_completion_value (ecma_get_completion_value_value (new_obj_value));
}
}
} /* ecma_builtin_object_dispatch_construct */
@@ -325,7 +325,7 @@ ecma_builtin_object_object_define_property (ecma_value_t this_arg __unused, /**<
ecma_op_to_string (arg2),
ret_value);
ecma_string_t *name_str_p = ECMA_GET_NON_NULL_POINTER (name_str_value.u.value.value);
ecma_string_t *name_str_p = ecma_get_string_from_completion_value (name_str_value);
ecma_property_descriptor_t prop_desc;
@@ -63,7 +63,7 @@ ecma_builtin_range_error_dispatch_call (ecma_value_t *arguments_list_p, /**< arg
ecma_op_to_string (arguments_list_p[0]),
ret_value);
ecma_string_t *message_string_p = ECMA_GET_NON_NULL_POINTER (msg_to_str_completion.u.value.value);
ecma_string_t *message_string_p = ecma_get_string_from_completion_value (msg_to_str_completion);
ecma_object_t *new_error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_RANGE,
message_string_p);
ret_value = ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p));
@@ -63,7 +63,7 @@ ecma_builtin_reference_error_dispatch_call (ecma_value_t *arguments_list_p, /**<
ecma_op_to_string (arguments_list_p[0]),
ret_value);
ecma_string_t *message_string_p = ECMA_GET_NON_NULL_POINTER (msg_to_str_completion.u.value.value);
ecma_string_t *message_string_p = ecma_get_string_from_completion_value (msg_to_str_completion);
ecma_object_t *new_error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_REFERENCE,
message_string_p);
ret_value = ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p));
+2 -2
View File
@@ -74,8 +74,8 @@ ecma_builtin_string_object_from_char_code (ecma_value_t this_arg __unused, /**<
ecma_op_to_number (args[arg_index]),
ret_value);
JERRY_ASSERT (ecma_is_value_number (arg_num_value.u.value));
ecma_number_t *arg_num_p = ECMA_GET_NON_NULL_POINTER (arg_num_value.u.value.value);
JERRY_ASSERT (ecma_is_value_number (ecma_get_completion_value_value (arg_num_value)));
ecma_number_t *arg_num_p = ecma_get_number_from_completion_value (arg_num_value);
uint32_t uint32_char_code = ecma_number_to_uint32 (*arg_num_p);
uint16_t uint16_char_code = (uint16_t) uint32_char_code;
@@ -63,7 +63,7 @@ ecma_builtin_syntax_error_dispatch_call (ecma_value_t *arguments_list_p, /**< ar
ecma_op_to_string (arguments_list_p[0]),
ret_value);
ecma_string_t *message_string_p = ECMA_GET_NON_NULL_POINTER (msg_to_str_completion.u.value.value);
ecma_string_t *message_string_p = ecma_get_string_from_completion_value (msg_to_str_completion);
ecma_object_t *new_error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_SYNTAX,
message_string_p);
ret_value = ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p));
+1 -1
View File
@@ -63,7 +63,7 @@ ecma_builtin_type_error_dispatch_call (ecma_value_t *arguments_list_p, /**< argu
ecma_op_to_string (arguments_list_p[0]),
ret_value);
ecma_string_t *message_string_p = ECMA_GET_NON_NULL_POINTER (msg_to_str_completion.u.value.value);
ecma_string_t *message_string_p = ecma_get_string_from_completion_value (msg_to_str_completion);
ecma_object_t *new_error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_TYPE,
message_string_p);
ret_value = ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p));
+1 -1
View File
@@ -63,7 +63,7 @@ ecma_builtin_uri_error_dispatch_call (ecma_value_t *arguments_list_p, /**< argum
ecma_op_to_string (arguments_list_p[0]),
ret_value);
ecma_string_t *message_string_p = ECMA_GET_NON_NULL_POINTER (msg_to_str_completion.u.value.value);
ecma_string_t *message_string_p = ecma_get_string_from_completion_value (msg_to_str_completion);
ecma_object_t *new_error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_URI,
message_string_p);
ret_value = ecma_make_normal_completion_value (ecma_make_object_value (new_error_object_p));