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:
@@ -44,25 +44,18 @@ ecma_op_check_object_coercible( ecma_value_t value) /**< ecma-value */
|
||||
{
|
||||
case ECMA_TYPE_SIMPLE:
|
||||
{
|
||||
switch ( (ecma_simple_value_t)value.value )
|
||||
{
|
||||
case ECMA_SIMPLE_VALUE_UNDEFINED:
|
||||
case ECMA_SIMPLE_VALUE_NULL:
|
||||
{
|
||||
return ecma_make_throw_value( ecma_new_standard_error( ECMA_ERROR_TYPE));
|
||||
}
|
||||
case ECMA_SIMPLE_VALUE_FALSE:
|
||||
case ECMA_SIMPLE_VALUE_TRUE:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case ECMA_SIMPLE_VALUE_EMPTY:
|
||||
case ECMA_SIMPLE_VALUE_ARRAY_REDIRECT:
|
||||
case ECMA_SIMPLE_VALUE__COUNT:
|
||||
{
|
||||
JERRY_UNREACHABLE();
|
||||
}
|
||||
}
|
||||
if ( ecma_is_value_undefined( value) )
|
||||
{
|
||||
return ecma_make_throw_value( ecma_new_standard_error( ECMA_ERROR_TYPE));
|
||||
}
|
||||
else if ( ecma_is_value_boolean( value) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_UNREACHABLE();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -130,8 +123,6 @@ ecma_op_to_primitive( ecma_value_t value, /**< ecma-value */
|
||||
ecma_completion_value_t
|
||||
ecma_op_to_boolean( ecma_value_t value) /**< ecma-value */
|
||||
{
|
||||
ecma_simple_value_t res = ECMA_SIMPLE_VALUE_EMPTY;
|
||||
|
||||
switch ( (ecma_type_t)value.value_type )
|
||||
{
|
||||
case ECMA_TYPE_NUMBER:
|
||||
@@ -139,8 +130,9 @@ ecma_op_to_boolean( ecma_value_t value) /**< ecma-value */
|
||||
ecma_number_t *num_p = ecma_get_pointer( value.value);
|
||||
|
||||
TODO( Implement according to ECMA );
|
||||
res = ( *num_p == 0 ) ? ECMA_SIMPLE_VALUE_FALSE:
|
||||
ECMA_SIMPLE_VALUE_TRUE;
|
||||
|
||||
return ecma_make_simple_completion_value( ( *num_p == 0 ) ? ECMA_SIMPLE_VALUE_FALSE
|
||||
: ECMA_SIMPLE_VALUE_TRUE );
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -148,11 +140,11 @@ ecma_op_to_boolean( ecma_value_t value) /**< ecma-value */
|
||||
{
|
||||
if ( ecma_is_value_boolean (value ) )
|
||||
{
|
||||
res = value.value;
|
||||
return ecma_make_simple_completion_value( value.value);
|
||||
} else if ( ecma_is_value_undefined (value)
|
||||
|| ecma_is_value_null( value) )
|
||||
{
|
||||
res = ECMA_SIMPLE_VALUE_FALSE;
|
||||
return ecma_make_simple_completion_value( ECMA_SIMPLE_VALUE_FALSE);
|
||||
} else
|
||||
{
|
||||
JERRY_UNREACHABLE();
|
||||
@@ -164,14 +156,14 @@ ecma_op_to_boolean( ecma_value_t value) /**< ecma-value */
|
||||
{
|
||||
ecma_array_first_chunk_t *str_p = ecma_get_pointer( value.value);
|
||||
|
||||
res = ( str_p->header.unit_number == 0 ) ? ECMA_SIMPLE_VALUE_FALSE:
|
||||
ECMA_SIMPLE_VALUE_TRUE;
|
||||
return ecma_make_simple_completion_value( ( str_p->header.unit_number == 0 ) ? ECMA_SIMPLE_VALUE_FALSE
|
||||
: ECMA_SIMPLE_VALUE_TRUE );
|
||||
|
||||
break;
|
||||
}
|
||||
case ECMA_TYPE_OBJECT:
|
||||
{
|
||||
res = ECMA_SIMPLE_VALUE_TRUE;
|
||||
return ecma_make_simple_completion_value( ECMA_SIMPLE_VALUE_TRUE);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -181,12 +173,7 @@ ecma_op_to_boolean( ecma_value_t value) /**< ecma-value */
|
||||
}
|
||||
}
|
||||
|
||||
JERRY_ASSERT( res == ECMA_SIMPLE_VALUE_FALSE
|
||||
|| res == ECMA_SIMPLE_VALUE_TRUE );
|
||||
|
||||
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
|
||||
ecma_make_simple_value( res),
|
||||
ECMA_TARGET_ID_RESERVED);
|
||||
JERRY_UNREACHABLE();
|
||||
} /* ecma_op_to_boolean */
|
||||
|
||||
/**
|
||||
|
||||
@@ -186,8 +186,7 @@ ecma_op_get_binding_value(ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
return ecma_make_completion_value( ECMA_COMPLETION_TYPE_NORMAL,
|
||||
ecma_copy_value( prop_value),
|
||||
ECMA_TARGET_ID_RESERVED);
|
||||
} else if ( prop_value.value_type == ECMA_TYPE_SIMPLE
|
||||
&& prop_value.value == ECMA_SIMPLE_VALUE_EMPTY )
|
||||
} else if ( ecma_is_value_empty( prop_value) )
|
||||
{
|
||||
/* unitialized immutable binding */
|
||||
if ( is_strict )
|
||||
@@ -318,13 +317,14 @@ ecma_op_create_immutable_binding(ecma_object_t *lex_env_p, /**< lexical environm
|
||||
* Whether immutable bindings are deletable seems not to be defined by ECMA v5.
|
||||
*/
|
||||
ecma_property_t *prop_p = ecma_create_named_property( lex_env_p,
|
||||
name_p,
|
||||
ECMA_PROPERTY_NOT_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_NOT_CONFIGURABLE);
|
||||
name_p,
|
||||
ECMA_PROPERTY_NOT_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_NOT_CONFIGURABLE);
|
||||
|
||||
JERRY_ASSERT( prop_p->u.named_data_property.value.value_type == ECMA_TYPE_SIMPLE );
|
||||
JERRY_ASSERT( ecma_is_value_undefined( prop_p->u.named_data_property.value ) );
|
||||
|
||||
prop_p->u.named_data_property.value.value_type = ECMA_TYPE_SIMPLE;
|
||||
prop_p->u.named_data_property.value.value = ECMA_SIMPLE_VALUE_EMPTY;
|
||||
}
|
||||
case ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND:
|
||||
@@ -358,8 +358,7 @@ ecma_op_initialize_immutable_binding(ecma_object_t *lex_env_p, /**< lexical envi
|
||||
|
||||
/* The binding must be unitialized immutable binding */
|
||||
JERRY_ASSERT( prop_p->u.named_data_property.writable == ECMA_PROPERTY_NOT_WRITABLE
|
||||
&& prop_p->u.named_data_property.value.value_type == ECMA_TYPE_SIMPLE
|
||||
&& prop_p->u.named_data_property.value.value == ECMA_SIMPLE_VALUE_EMPTY );
|
||||
&& ecma_is_value_empty( prop_p->u.named_data_property.value) );
|
||||
|
||||
prop_p->u.named_data_property.value = ecma_copy_value( value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user