Unify the usage of boolean value creations. (#2623)

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
This commit is contained in:
László Langó
2018-11-30 11:33:30 +01:00
committed by Zoltan Herczeg
parent 6dfa4efbfb
commit a08291eb12
9 changed files with 23 additions and 39 deletions
@@ -59,7 +59,7 @@ ecma_builtin_arraybuffer_object_is_view (ecma_value_t this_arg, /**< 'this' argu
/* TODO: if arg has [[ViewArrayBuffer]], return true */
return ecma_make_boolean_value (false);
return ECMA_VALUE_FALSE;
} /* ecma_builtin_arraybuffer_object_is_view */
/**
@@ -66,7 +66,7 @@ ecma_builtin_boolean_dispatch_call (const ecma_value_t *arguments_list_p, /**< a
arg_value = arguments_list_p[0];
}
return ecma_op_to_boolean (arg_value) ? ECMA_VALUE_TRUE : ECMA_VALUE_FALSE;
return ecma_make_boolean_value (ecma_op_to_boolean (arg_value));
} /* ecma_builtin_boolean_dispatch_call */
/**
@@ -532,9 +532,7 @@ ecma_builtin_global_object_is_nan (ecma_value_t this_arg, /**< this argument */
ECMA_OP_TO_NUMBER_TRY_CATCH (arg_num, arg, ret_value);
bool is_nan = ecma_number_is_nan (arg_num);
ret_value = is_nan ? ECMA_VALUE_TRUE : ECMA_VALUE_FALSE;
ret_value = ecma_make_boolean_value (ecma_number_is_nan (arg_num));
ECMA_OP_TO_NUMBER_FINALIZE (arg_num);
@@ -561,8 +559,7 @@ ecma_builtin_global_object_is_finite (ecma_value_t this_arg, /**< this argument
bool is_finite = !(ecma_number_is_nan (arg_num)
|| ecma_number_is_infinity (arg_num));
ret_value = is_finite ? ECMA_VALUE_TRUE : ECMA_VALUE_FALSE;
ret_value = ecma_make_boolean_value (is_finite);
ECMA_OP_TO_NUMBER_FINALIZE (arg_num);
@@ -192,7 +192,7 @@ ecma_builtin_object_prototype_object_is_prototype_of (ecma_value_t this_arg, /**
ecma_object_t *v_obj_p = ecma_get_object_from_value (v_obj_value);
bool is_prototype_of = ecma_op_object_is_prototype_of (obj_p, v_obj_p);
return_value = is_prototype_of ? ECMA_VALUE_TRUE : ECMA_VALUE_FALSE;
return_value = ecma_make_boolean_value (is_prototype_of);
ECMA_FINALIZE (v_obj_value);
ECMA_FINALIZE (obj_value);
@@ -512,17 +512,15 @@ ecma_builtin_object_frozen_or_sealed_helper (ecma_value_t this_arg, /**< 'this'
{
ecma_object_t *obj_p = ecma_get_object_from_value (arg);
bool is_sealed_or_frozen;
/* 3. */
if (ecma_get_object_extensible (obj_p))
{
is_sealed_or_frozen = false;
ret_value = ECMA_VALUE_FALSE;
}
else
{
/* the value can be updated in the loop below */
is_sealed_or_frozen = true;
ret_value = ECMA_VALUE_TRUE;
/* 2. */
ecma_collection_header_t *props_p = ecma_op_object_get_property_names (obj_p, ECMA_LIST_NO_OPTS);
@@ -545,23 +543,20 @@ ecma_builtin_object_frozen_or_sealed_helper (ecma_value_t this_arg, /**< 'this'
&& ECMA_PROPERTY_GET_TYPE (property) != ECMA_PROPERTY_TYPE_NAMEDACCESSOR
&& ecma_is_property_writable (property))
{
is_sealed_or_frozen = false;
ret_value = ECMA_VALUE_FALSE;
break;
}
/* 2.b for isSealed, 2.c for isFrozen */
if (ecma_is_property_configurable (property))
{
is_sealed_or_frozen = false;
ret_value = ECMA_VALUE_FALSE;
break;
}
}
ecma_free_values_collection (props_p, 0);
}
/* 4. */
ret_value = is_sealed_or_frozen ? ECMA_VALUE_TRUE : ECMA_VALUE_FALSE;
}
return ret_value;
@@ -613,22 +608,14 @@ ecma_builtin_object_object_is_extensible (ecma_value_t this_arg, /**< 'this' arg
ecma_value_t arg) /**< routine's argument */
{
JERRY_UNUSED (this_arg);
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
if (!ecma_is_value_object (arg))
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Argument is not an object."));
}
else
{
ecma_object_t *obj_p = ecma_get_object_from_value (arg);
bool extensible = ecma_get_object_extensible (obj_p);
ret_value = extensible ? ECMA_VALUE_TRUE : ECMA_VALUE_FALSE;
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument is not an object."));
}
return ret_value;
ecma_object_t *obj_p = ecma_get_object_from_value (arg);
return ecma_make_boolean_value (ecma_get_object_extensible (obj_p));
} /* ecma_builtin_object_object_is_extensible */
/**
@@ -341,7 +341,7 @@ ecma_builtin_promise_all_handler (const ecma_value_t function, /**< the function
/* 3. */
ecma_op_object_put (function_p,
already_called_str_p,
ecma_make_boolean_value (true),
ECMA_VALUE_TRUE,
false);
ecma_string_t *str_index_p = ecma_get_magic_string (LIT_INTERNAL_MAGIC_STRING_PROMISE_PROPERTY_INDEX);
@@ -500,7 +500,7 @@ ecma_builtin_promise_do_all (ecma_value_t array, /**< the array for all */
/* l. */
ecma_op_object_put (res_ele_p,
already_called_str_p,
ecma_make_boolean_value (false),
ECMA_VALUE_FALSE,
false);
/* m. */
ecma_op_object_put (res_ele_p,