jerryscript
jerryscript copied to clipboard
Introduce 'ecma_is_value_nullish'
ecma_is_value_null and ecma_is_value_undefined is used together in multiple places in the source code. It would nice to have a new ecma_is_value_nullish function to make the code simpler and more readable. e.g:
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
ecma_is_value_nullish (ecma_value_t value) /**< ecma value */
{
return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_NULL) || ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_UNDEFINED);
} /* ecma_is_value_null */
Nullish naming can be a little bit confusing, because ECMAScript specification doesn't use this term. There are many places in the spec, where an expression should be checked if it is undefined or null. Maybe the ecma_is_value_null_or_undefined(...) would fit better to the ES spec terms.