Style fixes regarding 'empty' value: introducing ecma_is_empty_completion_value, reducing usage of the 'empty' value, listing possible usage cases of the 'empty' value in the comment to it's definition.

This commit is contained in:
Ruben Ayrapetyan
2014-07-28 21:21:31 +04:00
parent 177a2d1382
commit 3ee0e8a8a5
7 changed files with 81 additions and 60 deletions
+8 -2
View File
@@ -63,12 +63,18 @@ typedef enum {
* Simple ecma-values
*/
typedef enum {
ECMA_SIMPLE_VALUE_EMPTY, /**< empty value (see also: ECMA-262 v5, 8.9 Completion specification type) */
/**
* Empty value is implementation defined value, used for:
* - representing empty value in completion values (see also: ECMA-262 v5, 8.9 Completion specification type);
* - values of uninitialized immutable bindings;
* - values of empty register variables.
*/
ECMA_SIMPLE_VALUE_EMPTY,
ECMA_SIMPLE_VALUE_UNDEFINED, /**< undefined value */
ECMA_SIMPLE_VALUE_NULL, /**< null value */
ECMA_SIMPLE_VALUE_FALSE, /**< boolean false */
ECMA_SIMPLE_VALUE_TRUE, /**< boolean true */
ECMA_SIMPLE_VALUE_ARRAY_REDIRECT, /**< special value for an array's elements that exists,
ECMA_SIMPLE_VALUE_ARRAY_REDIRECT, /**< implementation defined value for an array's elements that exists,
but is stored directly in the array's property list
(used for array elements with non-default attribute values) */
ECMA_SIMPLE_VALUE__COUNT /** count of simple ecma-values */
+36 -4
View File
@@ -282,6 +282,24 @@ ecma_make_completion_value(ecma_completion_type_t type, /**< type */
return (ecma_completion_value_t) { .type = type, .value = value, .target = target };
} /* ecma_make_completion_value */
/**
* Simple normal completion value constructor
*
* @return completion value
*/
ecma_completion_value_t
ecma_make_simple_completion_value( ecma_simple_value_t simple_value) /**< simple ecma-value */
{
JERRY_ASSERT( simple_value == ECMA_SIMPLE_VALUE_UNDEFINED
|| simple_value == ECMA_SIMPLE_VALUE_NULL
|| simple_value == ECMA_SIMPLE_VALUE_FALSE
|| simple_value == ECMA_SIMPLE_VALUE_TRUE );
return ecma_make_completion_value( ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_simple_value( simple_value),
ECMA_TARGET_ID_RESERVED);
} /* ecma_make_simple_completion_value */
/**
* Throw completion value constructor.
*
@@ -308,8 +326,8 @@ ecma_completion_value_t
ecma_make_empty_completion_value( void)
{
return ecma_make_completion_value( ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_simple_value( ECMA_SIMPLE_VALUE_EMPTY),
ECMA_TARGET_ID_RESERVED);
ecma_make_simple_value( ECMA_SIMPLE_VALUE_EMPTY),
ECMA_TARGET_ID_RESERVED);
} /* ecma_make_empty_completion_value */
/**
@@ -321,8 +339,8 @@ ecma_completion_value_t
ecma_copy_completion_value( ecma_completion_value_t value) /**< completion value */
{
return ecma_make_completion_value( value.type,
ecma_copy_value( value.value),
value.target);
ecma_copy_value( value.value),
value.target);
} /* ecma_copy_completion_value */
/**
@@ -412,6 +430,20 @@ ecma_is_completion_value_normal_false( ecma_completion_value_t value) /**< compl
return ecma_is_completion_value_normal_simple_value( value, ECMA_SIMPLE_VALUE_FALSE);
} /* ecma_is_completion_value_normal_false */
/**
* Check if the completion value is normal empty value.
*
* @return true - if the completion type is normal and
* value contains empty simple value,
* false - otherwise.
*/
bool
ecma_is_empty_completion_value( ecma_completion_value_t value) /**< completion value */
{
return ( ecma_is_completion_value_normal( value)
&& ecma_is_value_empty( value.value) );
} /* ecma_is_empty_completion_value */
/**
* @}
* @}
+3 -1
View File
@@ -56,6 +56,7 @@ extern ecma_value_t ecma_copy_value( const ecma_value_t value);
extern void ecma_free_value( const ecma_value_t value);
extern ecma_completion_value_t ecma_make_completion_value( ecma_completion_type_t type, ecma_value_t value, uint8_t target);
extern ecma_completion_value_t ecma_make_simple_completion_value( ecma_simple_value_t simple_value);
extern ecma_completion_value_t ecma_make_throw_value( ecma_object_t *exception_p);
extern ecma_completion_value_t ecma_make_empty_completion_value( void);
extern ecma_completion_value_t ecma_copy_completion_value( ecma_completion_value_t value);
@@ -64,8 +65,9 @@ extern void ecma_free_completion_value( ecma_completion_value_t completion_value
extern bool ecma_is_completion_value_normal( ecma_completion_value_t value);
extern bool ecma_is_completion_value_throw( ecma_completion_value_t value);
extern bool ecma_is_completion_value_normal_simple_value( ecma_completion_value_t value, ecma_simple_value_t simple_value);
extern bool ecma_is_completion_value_normal_false( ecma_completion_value_t value);
extern bool ecma_is_completion_value_normal_true( ecma_completion_value_t value);
extern bool ecma_is_completion_value_normal_false( ecma_completion_value_t value);
extern bool ecma_is_empty_completion_value( ecma_completion_value_t value);
extern ecma_object_t* ecma_create_object( ecma_object_t *prototype_object_p, bool is_extensible);
extern ecma_object_t* ecma_create_lexical_environment( ecma_object_t *outer_lexical_environment_p, ecma_lexical_environment_type_t type);