Implementation of general objects' [[GetOwnProperty]], [[GetProperty]], [[CanPut]], [[HasProperty]], [[Delete]]; partial implementation of general objects' [[Get]], [[Put]], [[DefineOwnProperty]].

This commit is contained in:
Ruben Ayrapetyan
2014-07-29 14:32:01 +04:00
parent 5aaa853b9f
commit 299c94ee85
8 changed files with 681 additions and 193 deletions
+73
View File
@@ -74,6 +74,79 @@ ecma_op_check_object_coercible( ecma_value_t value) /**< ecma-value */
return ecma_make_empty_completion_value();
} /* ecma_op_check_object_coercible */
/**
* SameValue operation.
*
* See also:
* ECMA-262 v5, 9.12
*
* @return true - if the value are same according to ECMA-defined SameValue algorithm,
* false - otherwise.
*/
bool
ecma_op_same_value( ecma_value_t x, /**< ecma-value */
ecma_value_t y) /**< ecma-value */
{
const bool is_x_undefined = ecma_is_value_undefined( x);
const bool is_x_null = ecma_is_value_null( x);
const bool is_x_boolean = ecma_is_value_boolean( x);
const bool is_x_number = ( x.value_type == ECMA_TYPE_NUMBER );
const bool is_x_string = ( x.value_type == ECMA_TYPE_STRING );
const bool is_x_object = ( x.value_type == ECMA_TYPE_OBJECT );
const bool is_y_undefined = ecma_is_value_undefined( y);
const bool is_y_null = ecma_is_value_null( y);
const bool is_y_boolean = ecma_is_value_boolean( y);
const bool is_y_number = ( y.value_type == ECMA_TYPE_NUMBER );
const bool is_y_string = ( y.value_type == ECMA_TYPE_STRING );
const bool is_y_object = ( y.value_type == ECMA_TYPE_OBJECT );
const bool is_types_equal = ( ( is_x_undefined && is_y_undefined )
|| ( is_x_null && is_y_null )
|| ( is_x_boolean && is_y_boolean )
|| ( is_x_number && is_y_number )
|| ( is_x_string && is_y_string )
|| ( is_x_object && is_y_object ) );
if ( !is_types_equal )
{
return false;
}
if ( is_x_undefined
|| is_x_null )
{
return true;
}
if ( is_x_number )
{
TODO( Implement according to ECMA );
ecma_number_t *x_num_p = (ecma_number_t*)ecma_get_pointer( x.value);
ecma_number_t *y_num_p = (ecma_number_t*)ecma_get_pointer( y.value);
return ( *x_num_p == *y_num_p );
}
if ( is_x_string )
{
ecma_array_first_chunk_t* x_str_p = (ecma_array_first_chunk_t*)( ecma_get_pointer(x.value) );
ecma_array_first_chunk_t* y_str_p = (ecma_array_first_chunk_t*)( ecma_get_pointer(y.value) );
return ecma_compare_ecma_string_to_ecma_string( x_str_p, y_str_p);
}
if ( is_x_boolean )
{
return ( ecma_is_value_true( x) == ecma_is_value_true( y) );
}
JERRY_ASSERT( is_x_object );
return ( ecma_get_pointer( x.value) == ecma_get_pointer( y.value) );
} /* ecma_op_same_value */
/**
* ToPrimitive operation.
*