Styles fixes in libecmaobjects, libecmaoperations: indentation and braces rules.

This commit is contained in:
Ruben Ayrapetyan
2014-08-11 22:04:53 +04:00
parent 38c6c2357d
commit 48cff24f08
15 changed files with 1676 additions and 1632 deletions
+36 -36
View File
@@ -36,7 +36,7 @@
*/
bool
ecma_op_abstract_equality_compare (ecma_value_t x, /**< first operand */
ecma_value_t y) /**< second operand */
ecma_value_t y) /**< second operand */
{
const bool is_x_undefined = ecma_is_value_undefined (x);
const bool is_x_null = ecma_is_value_null (x);
@@ -53,18 +53,18 @@ ecma_op_abstract_equality_compare (ecma_value_t x, /**< first operand */
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));
|| (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)
{
// 1.
if (is_x_undefined
|| is_x_null)
|| is_x_null)
{
// a., b.
return true;
@@ -92,7 +92,7 @@ ecma_op_abstract_equality_compare (ecma_value_t x, /**< first operand */
return (x.value == y.value);
}
} else if ((is_x_null && is_y_undefined)
|| (is_x_undefined && is_y_null))
|| (is_x_undefined && is_y_null))
{ // 2., 3.
return true;
} else
@@ -111,8 +111,8 @@ ecma_op_abstract_equality_compare (ecma_value_t x, /**< first operand */
*/
ecma_completion_value_t
ecma_op_abstract_relational_compare (ecma_value_t x, /**< first operand */
ecma_value_t y, /**< second operand */
bool left_first) /**< 'LeftFirst' flag */
ecma_value_t y, /**< second operand */
bool left_first) /**< 'LeftFirst' flag */
{
ecma_completion_value_t ret_value, px, py;
@@ -134,38 +134,38 @@ ecma_op_abstract_relational_compare (ecma_value_t x, /**< first operand */
const bool is_py_string = (py.value.value_type == ECMA_TYPE_STRING);
if (!(is_px_string && is_py_string))
{ // 3.
// a.
ECMA_TRY_CATCH(nx, ecma_op_to_number (px.value), ret_value);
{ // 3.
// a.
ECMA_TRY_CATCH(nx, ecma_op_to_number (px.value), ret_value);
// b.
ECMA_TRY_CATCH(ny, ecma_op_to_number (py.value), ret_value);
// b.
ECMA_TRY_CATCH(ny, ecma_op_to_number (py.value), ret_value);
ecma_number_t* num_x_p = (ecma_number_t*)ECMA_GET_POINTER(nx.value.value);
ecma_number_t* num_y_p = (ecma_number_t*)ECMA_GET_POINTER(ny.value.value);
ecma_number_t* num_x_p = (ecma_number_t*)ECMA_GET_POINTER(nx.value.value);
ecma_number_t* num_y_p = (ecma_number_t*)ECMA_GET_POINTER(ny.value.value);
TODO(/* Implement according to ECMA */);
TODO(/* Implement according to ECMA */);
if (*num_x_p >= *num_y_p)
{
ret_value = ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE),
ECMA_TARGET_ID_RESERVED);
}
else
{
ret_value = ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_simple_value (ECMA_SIMPLE_VALUE_TRUE),
ECMA_TARGET_ID_RESERVED);
}
ECMA_FINALIZE(ny);
ECMA_FINALIZE(nx);
if (*num_x_p >= *num_y_p)
{
ret_value = ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE),
ECMA_TARGET_ID_RESERVED);
}
else
{
ret_value = ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_simple_value (ECMA_SIMPLE_VALUE_TRUE),
ECMA_TARGET_ID_RESERVED);
}
ECMA_FINALIZE(ny);
ECMA_FINALIZE(nx);
}
else
{ // 4.
JERRY_UNIMPLEMENTED();
}
{ // 4.
JERRY_UNIMPLEMENTED();
}
ECMA_FINALIZE(prim_second_converted_value);
ECMA_FINALIZE(prim_first_converted_value);
+113 -109
View File
@@ -43,32 +43,34 @@ ecma_op_check_object_coercible (ecma_value_t value) /**< ecma-value */
switch ((ecma_type_t)value.value_type)
{
case ECMA_TYPE_SIMPLE:
{
if (ecma_is_value_undefined (value))
{
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;
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
}
case ECMA_TYPE_NUMBER:
case ECMA_TYPE_STRING:
case ECMA_TYPE_OBJECT:
else if (ecma_is_value_boolean (value))
{
break;
}
case ECMA_TYPE__COUNT:
else
{
JERRY_UNREACHABLE();
}
break;
}
case ECMA_TYPE_NUMBER:
case ECMA_TYPE_STRING:
case ECMA_TYPE_OBJECT:
{
break;
}
case ECMA_TYPE__COUNT:
{
JERRY_UNREACHABLE();
}
}
return ecma_make_empty_completion_value ();
@@ -102,45 +104,45 @@ ecma_op_same_value (ecma_value_t x, /**< ecma-value */
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));
|| (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;
}
{
return false;
}
if (is_x_undefined
|| is_x_null)
{
return true;
}
|| is_x_null)
{
return true;
}
if (is_x_number)
{
TODO(Implement according to ECMA);
{
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);
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);
}
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));
{
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);
}
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));
}
{
return (ecma_is_value_true (x) == ecma_is_value_true (y));
}
JERRY_ASSERT(is_x_object);
@@ -165,19 +167,21 @@ ecma_op_to_primitive (ecma_value_t value, /**< ecma-value */
case ECMA_TYPE_SIMPLE:
case ECMA_TYPE_NUMBER:
case ECMA_TYPE_STRING:
{
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_copy_value (value, true),
ECMA_TARGET_ID_RESERVED);
}
{
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_copy_value (value, true),
ECMA_TARGET_ID_RESERVED);
}
case ECMA_TYPE_OBJECT:
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(preferred_type);
}
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(preferred_type);
}
case ECMA_TYPE__COUNT:
{
JERRY_UNREACHABLE();
}
{
JERRY_UNREACHABLE();
}
}
JERRY_UNREACHABLE();
@@ -199,51 +203,51 @@ ecma_op_to_boolean (ecma_value_t value) /**< ecma-value */
switch ((ecma_type_t)value.value_type)
{
case ECMA_TYPE_NUMBER:
{
ecma_number_t *num_p = ECMA_GET_POINTER(value.value);
{
ecma_number_t *num_p = ECMA_GET_POINTER(value.value);
TODO(Implement according to ECMA);
TODO(Implement according to ECMA);
return ecma_make_simple_completion_value ((*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;
}
break;
}
case ECMA_TYPE_SIMPLE:
{
if (ecma_is_value_boolean (value))
{
if (ecma_is_value_boolean (value))
{
return ecma_make_simple_completion_value (value.value);
} else if (ecma_is_value_undefined (value)
|| ecma_is_value_null (value))
{
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE);
} else
{
JERRY_UNREACHABLE();
}
break;
}
case ECMA_TYPE_STRING:
return ecma_make_simple_completion_value (value.value);
} else if (ecma_is_value_undefined (value)
|| ecma_is_value_null (value))
{
ecma_array_first_chunk_t *str_p = ECMA_GET_POINTER(value.value);
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:
{
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
break;
}
case ECMA_TYPE__COUNT:
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE);
} else
{
JERRY_UNREACHABLE();
}
break;
}
case ECMA_TYPE_STRING:
{
ecma_array_first_chunk_t *str_p = ECMA_GET_POINTER(value.value);
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:
{
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
break;
}
case ECMA_TYPE__COUNT:
{
JERRY_UNREACHABLE();
}
}
JERRY_UNREACHABLE();
@@ -264,30 +268,30 @@ ecma_op_to_number (ecma_value_t value) /**< ecma-value */
switch ((ecma_type_t)value.value_type)
{
case ECMA_TYPE_NUMBER:
{
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_copy_value (value, true),
ECMA_TARGET_ID_RESERVED);
}
{
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_copy_value (value, true),
ECMA_TARGET_ID_RESERVED);
}
case ECMA_TYPE_SIMPLE:
case ECMA_TYPE_STRING:
{
JERRY_UNIMPLEMENTED();
}
{
JERRY_UNIMPLEMENTED();
}
case ECMA_TYPE_OBJECT:
{
ecma_completion_value_t completion_to_primitive = ecma_op_to_primitive (value, ECMA_PREFERRED_TYPE_NUMBER);
JERRY_ASSERT(ecma_is_completion_value_normal (completion_to_primitive));
{
ecma_completion_value_t completion_to_primitive = ecma_op_to_primitive (value, ECMA_PREFERRED_TYPE_NUMBER);
JERRY_ASSERT(ecma_is_completion_value_normal (completion_to_primitive));
ecma_completion_value_t completion_to_number = ecma_op_to_number (completion_to_primitive.value);
ecma_free_completion_value (completion_to_primitive);
ecma_completion_value_t completion_to_number = ecma_op_to_number (completion_to_primitive.value);
ecma_free_completion_value (completion_to_primitive);
return completion_to_number;
}
return completion_to_number;
}
case ECMA_TYPE__COUNT:
{
JERRY_UNREACHABLE();
}
{
JERRY_UNREACHABLE();
}
}
JERRY_UNREACHABLE();
+116 -116
View File
@@ -45,9 +45,9 @@ ecma_pack_code_internal_property_value (bool is_strict, /**< is code strict? */
JERRY_ASSERT(((value) & (1u << is_strict_bit_offset)) == 0);
if (is_strict)
{
value |= (1u << is_strict_bit_offset);
}
{
value |= (1u << is_strict_bit_offset);
}
return value;
} /* ecma_pack_code_internal_property_value */
@@ -86,9 +86,9 @@ bool
ecma_op_is_callable (ecma_value_t value) /**< ecma-value */
{
if (value.value_type != ECMA_TYPE_OBJECT)
{
return false;
}
{
return false;
}
ecma_object_t *obj_p = ECMA_GET_POINTER(value.value);
@@ -96,7 +96,7 @@ ecma_op_is_callable (ecma_value_t value) /**< ecma-value */
JERRY_ASSERT(!obj_p->is_lexical_environment);
return (obj_p->u.object.type == ECMA_OBJECT_TYPE_FUNCTION
|| obj_p->u.object.type == ECMA_OBJECT_TYPE_BOUND_FUNCTION);
|| obj_p->u.object.type == ECMA_OBJECT_TYPE_BOUND_FUNCTION);
} /* ecma_op_is_callable */
/**
@@ -137,9 +137,9 @@ ecma_op_create_function_object (const ecma_char_t* formal_parameter_list_p[], /*
// 10., 11., 14., 15.
if (formal_parameters_number != 0)
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(formal_parameter_list_p);
}
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(formal_parameter_list_p);
}
// 12.
ecma_property_t *code_prop_p = ecma_create_internal_property (f, ECMA_INTERNAL_PROPERTY_CODE);
@@ -152,19 +152,19 @@ ecma_op_create_function_object (const ecma_char_t* formal_parameter_list_p[], /*
// 17.
ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor ();
{
prop_desc.is_value_defined = true;
prop_desc.value = ecma_make_object_value (f);
{
prop_desc.is_value_defined = true;
prop_desc.value = ecma_make_object_value (f);
prop_desc.is_writable_defined = true;
prop_desc.writable = ECMA_PROPERTY_WRITABLE;
prop_desc.is_writable_defined = true;
prop_desc.writable = ECMA_PROPERTY_WRITABLE;
prop_desc.is_enumerable_defined = true;
prop_desc.enumerable = ECMA_PROPERTY_NOT_ENUMERABLE;
prop_desc.is_enumerable_defined = true;
prop_desc.enumerable = ECMA_PROPERTY_NOT_ENUMERABLE;
prop_desc.is_configurable_defined = true;
prop_desc.configurable = ECMA_PROPERTY_CONFIGURABLE;
}
prop_desc.is_configurable_defined = true;
prop_desc.configurable = ECMA_PROPERTY_CONFIGURABLE;
}
ecma_op_object_define_own_property (proto_p,
ecma_get_magic_string (ECMA_MAGIC_STRING_CONSTRUCTOR),
@@ -183,37 +183,37 @@ ecma_op_create_function_object (const ecma_char_t* formal_parameter_list_p[], /*
// 19.
if (is_strict)
{
ecma_object_t *thrower_p = ecma_op_get_throw_type_error ();
prop_desc = ecma_make_empty_property_descriptor ();
{
ecma_object_t *thrower_p = ecma_op_get_throw_type_error ();
prop_desc.is_enumerable_defined = true;
prop_desc.enumerable = ECMA_PROPERTY_NOT_ENUMERABLE;
prop_desc = ecma_make_empty_property_descriptor ();
{
prop_desc.is_enumerable_defined = true;
prop_desc.enumerable = ECMA_PROPERTY_NOT_ENUMERABLE;
prop_desc.is_configurable_defined = true;
prop_desc.configurable = ECMA_PROPERTY_NOT_CONFIGURABLE;
prop_desc.is_configurable_defined = true;
prop_desc.configurable = ECMA_PROPERTY_NOT_CONFIGURABLE;
prop_desc.is_get_defined = true;
prop_desc.get_p = thrower_p;
prop_desc.is_get_defined = true;
prop_desc.get_p = thrower_p;
prop_desc.is_set_defined = true;
prop_desc.set_p = thrower_p;
}
ecma_op_object_define_own_property (f,
ecma_get_magic_string (ECMA_MAGIC_STRING_CALLER),
prop_desc,
false);
ecma_op_object_define_own_property (f,
ecma_get_magic_string (ECMA_MAGIC_STRING_ARGUMENTS),
prop_desc,
false);
ecma_deref_object (thrower_p);
prop_desc.is_set_defined = true;
prop_desc.set_p = thrower_p;
}
ecma_op_object_define_own_property (f,
ecma_get_magic_string (ECMA_MAGIC_STRING_CALLER),
prop_desc,
false);
ecma_op_object_define_own_property (f,
ecma_get_magic_string (ECMA_MAGIC_STRING_ARGUMENTS),
prop_desc,
false);
ecma_deref_object (thrower_p);
}
return f;
} /* ecma_op_create_function_object */
@@ -236,81 +236,81 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */
JERRY_ASSERT(arguments_list_len == 0 || arguments_list_p != NULL);
if (func_obj_p->u.object.type == ECMA_OBJECT_TYPE_FUNCTION)
{
ecma_completion_value_t ret_value;
/* Entering Function Code (ECMA-262 v5, 10.4.3) */
ecma_property_t *scope_prop_p = ecma_get_internal_property (func_obj_p, ECMA_INTERNAL_PROPERTY_SCOPE);
ecma_property_t *code_prop_p = ecma_get_internal_property (func_obj_p, ECMA_INTERNAL_PROPERTY_CODE);
ecma_object_t *scope_p = ECMA_GET_POINTER(scope_prop_p->u.internal_property.value);
uint32_t code_prop_value = code_prop_p->u.internal_property.value;
bool is_strict;
// 8.
opcode_counter_t code_first_opcode_idx = ecma_unpack_code_internal_property_value (code_prop_value, &is_strict);
ecma_value_t this_binding;
// 1.
if (is_strict)
{
ecma_completion_value_t ret_value;
/* Entering Function Code (ECMA-262 v5, 10.4.3) */
ecma_property_t *scope_prop_p = ecma_get_internal_property (func_obj_p, ECMA_INTERNAL_PROPERTY_SCOPE);
ecma_property_t *code_prop_p = ecma_get_internal_property (func_obj_p, ECMA_INTERNAL_PROPERTY_CODE);
ecma_object_t *scope_p = ECMA_GET_POINTER(scope_prop_p->u.internal_property.value);
uint32_t code_prop_value = code_prop_p->u.internal_property.value;
bool is_strict;
// 8.
opcode_counter_t code_first_opcode_idx = ecma_unpack_code_internal_property_value (code_prop_value, &is_strict);
ecma_value_t this_binding;
// 1.
if (is_strict)
{
this_binding = ecma_copy_value (this_arg_value, true);
}
else if (ecma_is_value_undefined (this_arg_value)
|| ecma_is_value_null (this_arg_value))
{
// 2.
FIXME(Assign Global object when it will be implemented);
this_binding = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
}
else
{
// 3., 4.
ecma_completion_value_t completion = ecma_op_to_object (this_arg_value);
JERRY_ASSERT(ecma_is_completion_value_normal (completion));
this_binding = completion.value;
}
// 5.
ecma_object_t *local_env_p = ecma_create_decl_lex_env (scope_p);
// 9.
/* Declaration binding instantiation (ECMA-262 v5, 10.5), block 4 */
TODO(Perform declaration binding instantion when [[FormalParameters]] list will be supported);
if (arguments_list_len != 0)
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(arguments_list_p);
}
ecma_completion_value_t completion = run_int_from_pos (code_first_opcode_idx,
this_binding,
local_env_p,
is_strict);
if (ecma_is_completion_value_normal (completion))
{
JERRY_ASSERT(ecma_is_empty_completion_value (completion));
ret_value = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
}
else
{
ret_value = completion;
}
ecma_deref_object (local_env_p);
ecma_free_value (this_binding, true);
return ret_value;
this_binding = ecma_copy_value (this_arg_value, true);
}
else if (ecma_is_value_undefined (this_arg_value)
|| ecma_is_value_null (this_arg_value))
{
// 2.
FIXME(Assign Global object when it will be implemented);
this_binding = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
}
else
{
// 3., 4.
ecma_completion_value_t completion = ecma_op_to_object (this_arg_value);
JERRY_ASSERT(ecma_is_completion_value_normal (completion));
this_binding = completion.value;
}
// 5.
ecma_object_t *local_env_p = ecma_create_decl_lex_env (scope_p);
// 9.
/* Declaration binding instantiation (ECMA-262 v5, 10.5), block 4 */
TODO(Perform declaration binding instantion when [[FormalParameters]] list will be supported);
if (arguments_list_len != 0)
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(arguments_list_p);
}
ecma_completion_value_t completion = run_int_from_pos (code_first_opcode_idx,
this_binding,
local_env_p,
is_strict);
if (ecma_is_completion_value_normal (completion))
{
JERRY_ASSERT(ecma_is_empty_completion_value (completion));
ret_value = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
}
else
{
ret_value = completion;
}
ecma_deref_object (local_env_p);
ecma_free_value (this_binding, true);
return ret_value;
}
else
{
JERRY_ASSERT(func_obj_p->u.object.type == ECMA_OBJECT_TYPE_BOUND_FUNCTION);
{
JERRY_ASSERT(func_obj_p->u.object.type == ECMA_OBJECT_TYPE_BOUND_FUNCTION);
JERRY_UNIMPLEMENTED();
}
JERRY_UNIMPLEMENTED();
}
} /* ecma_op_function_call */
/**
+94 -94
View File
@@ -46,10 +46,10 @@ ecma_op_get_value (ecma_reference_t ref) /**< ECMA-reference */
const ecma_value_t base = ref.base;
const bool is_unresolvable_reference = ecma_is_value_undefined (base);
const bool has_primitive_base = (ecma_is_value_boolean (base)
|| base.value_type == ECMA_TYPE_NUMBER
|| base.value_type == ECMA_TYPE_STRING);
|| base.value_type == ECMA_TYPE_NUMBER
|| base.value_type == ECMA_TYPE_STRING);
const bool has_object_base = (base.value_type == ECMA_TYPE_OBJECT
&& !((ecma_object_t*)ECMA_GET_POINTER(base.value))->is_lexical_environment);
&& !((ecma_object_t*)ECMA_GET_POINTER(base.value))->is_lexical_environment);
const bool is_property_reference = has_primitive_base || has_object_base;
// GetValue_3
@@ -72,31 +72,31 @@ ecma_op_get_value (ecma_reference_t ref) /**< ECMA-reference */
} else
{ // GetValue_4.b case 2
/*
ecma_object_t *obj_p = ecma_ToObject (base);
JERRY_ASSERT(obj_p != NULL && !obj_p->is_lexical_environment);
ecma_property_t *property = obj_p->[[GetProperty]](ref.referenced_name_p);
if (property->Type == ECMA_PROPERTY_NAMEDDATA)
{
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_copy_value (property->u.named_data_property.value),
ECMA_TARGET_ID_RESERVED);
} else
{
JERRY_ASSERT(property->Type == ECMA_PROPERTY_NAMEDACCESSOR);
ecma_object_t *getter = ECMA_GET_POINTER(property->u.named_accessor_property.get_p);
if (getter == NULL)
{
ecma_object_t *obj_p = ecma_ToObject (base);
JERRY_ASSERT(obj_p != NULL && !obj_p->is_lexical_environment);
ecma_property_t *property = obj_p->[[GetProperty]](ref.referenced_name_p);
if (property->Type == ECMA_PROPERTY_NAMEDDATA)
{
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
ECMA_TARGET_ID_RESERVED);
} else
{
ecma_copy_value (property->u.named_data_property.value),
ECMA_TARGET_ID_RESERVED);
} else
{
JERRY_ASSERT(property->Type == ECMA_PROPERTY_NAMEDACCESSOR);
ecma_object_t *getter = ECMA_GET_POINTER(property->u.named_accessor_property.get_p);
if (getter == NULL)
{
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
ECMA_TARGET_ID_RESERVED);
} else
{
return [[Call]](getter, base as this);
}
}
*/
}
}
*/
JERRY_UNIMPLEMENTED();
}
} else
@@ -120,15 +120,15 @@ ecma_op_get_value (ecma_reference_t ref) /**< ECMA-reference */
*/
ecma_completion_value_t
ecma_op_put_value (ecma_reference_t ref, /**< ECMA-reference */
ecma_value_t value) /**< ECMA-value */
ecma_value_t value) /**< ECMA-value */
{
const ecma_value_t base = ref.base;
const bool is_unresolvable_reference = ecma_is_value_undefined (base);
const bool has_primitive_base = (ecma_is_value_boolean (base)
|| base.value_type == ECMA_TYPE_NUMBER
|| base.value_type == ECMA_TYPE_STRING);
|| base.value_type == ECMA_TYPE_NUMBER
|| base.value_type == ECMA_TYPE_STRING);
const bool has_object_base = (base.value_type == ECMA_TYPE_OBJECT
&& !((ecma_object_t*)ECMA_GET_POINTER(base.value))->is_lexical_environment);
&& !((ecma_object_t*)ECMA_GET_POINTER(base.value))->is_lexical_environment);
const bool is_property_reference = has_primitive_base || has_object_base;
if (is_unresolvable_reference) // PutValue_3
@@ -138,19 +138,19 @@ ecma_op_put_value (ecma_reference_t ref, /**< ECMA-reference */
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_REFERENCE));
} else // PutValue_3.b
{
ecma_object_t *global_object_p = ecma_get_global_object ();
ecma_object_t *global_object_p = ecma_get_global_object ();
ecma_completion_value_t completion = ecma_op_object_put (global_object_p,
ref.referenced_name_p,
value,
false);
ecma_completion_value_t completion = ecma_op_object_put (global_object_p,
ref.referenced_name_p,
value,
false);
ecma_deref_object (global_object_p);
ecma_deref_object (global_object_p);
JERRY_ASSERT(ecma_is_completion_value_normal_true (completion)
|| ecma_is_completion_value_normal_false (completion));
JERRY_ASSERT(ecma_is_completion_value_normal_true (completion)
|| ecma_is_completion_value_normal_false (completion));
return ecma_make_empty_completion_value ();
return ecma_make_empty_completion_value ();
}
} else if (is_property_reference) // PutValue_4
{
@@ -165,68 +165,68 @@ ecma_op_put_value (ecma_reference_t ref, /**< ECMA-reference */
// PutValue_4.b case 2
/*
// PutValue_sub_1
ecma_object_t *obj_p = ecma_ToObject (base);
JERRY_ASSERT(obj_p != NULL && !obj_p->is_lexical_environment);
// PutValue_sub_1
ecma_object_t *obj_p = ecma_ToObject (base);
JERRY_ASSERT(obj_p != NULL && !obj_p->is_lexical_environment);
// PutValue_sub_2
if (!obj_p->[[CanPut]](ref.referenced_name_p))
{
// PutValue_sub_2.a
if (ref.is_strict)
{
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
} else
{ // PutValue_sub_2.b
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY),
ECMA_TARGET_ID_RESERVED);
}
}
// PutValue_sub_2
if (!obj_p->[[CanPut]](ref.referenced_name_p))
{
// PutValue_sub_2.a
if (ref.is_strict)
{
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
} else
{ // PutValue_sub_2.b
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY),
ECMA_TARGET_ID_RESERVED);
}
}
// PutValue_sub_3
ecma_property_t *own_prop = obj_p->[[GetOwnProperty]](ref.referenced_name_p);
// PutValue_sub_3
ecma_property_t *own_prop = obj_p->[[GetOwnProperty]](ref.referenced_name_p);
// PutValue_sub_4
if (ecma_OpIsDataDescriptor (own_prop))
{
// PutValue_sub_4.a
if (ref.is_strict)
{
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
} else
{ // PutValue_sub_4.b
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY),
ECMA_TARGET_ID_RESERVED);
}
}
// PutValue_sub_4
if (ecma_OpIsDataDescriptor (own_prop))
{
// PutValue_sub_4.a
if (ref.is_strict)
{
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
} else
{ // PutValue_sub_4.b
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY),
ECMA_TARGET_ID_RESERVED);
}
}
// PutValue_sub_5
ecma_property_t *prop = obj_p->[[GetProperty]](ref.referenced_name_p);
// PutValue_sub_5
ecma_property_t *prop = obj_p->[[GetProperty]](ref.referenced_name_p);
// PutValue_sub_6
if (ecma_OpIsAccessorDescriptor (prop))
{
// PutValue_sub_6.a
ecma_object_t *setter = ECMA_GET_POINTER(property->u.named_accessor_property.set_p);
JERRY_ASSERT(setter != NULL);
// PutValue_sub_6
if (ecma_OpIsAccessorDescriptor (prop))
{
// PutValue_sub_6.a
ecma_object_t *setter = ECMA_GET_POINTER(property->u.named_accessor_property.set_p);
JERRY_ASSERT(setter != NULL);
// PutValue_sub_6.b
return [[Call]](setter, base as this, value);
} else // PutValue_sub_7
{
// PutValue_sub_7.a
if (ref.is_strict)
{
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
}
}
// PutValue_sub_6.b
return [[Call]](setter, base as this, value);
} else // PutValue_sub_7
{
// PutValue_sub_7.a
if (ref.is_strict)
{
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
}
}
// PutValue_sub_8
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY),
ECMA_TARGET_ID_RESERVED);
// PutValue_sub_8
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY),
ECMA_TARGET_ID_RESERVED);
*/
JERRY_UNIMPLEMENTED();
+119 -115
View File
@@ -40,12 +40,12 @@ static ecma_object_t*
ecma_get_lex_env_binding_object (ecma_object_t* obj_lex_env_p) /**< object lexical environment */
{
JERRY_ASSERT(obj_lex_env_p != NULL
&& obj_lex_env_p->is_lexical_environment
&& obj_lex_env_p->u.lexical_environment.type == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND);
&& obj_lex_env_p->is_lexical_environment
&& obj_lex_env_p->u.lexical_environment.type == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND);
ecma_property_t *binding_obj_prop_p = ECMA_GET_POINTER(obj_lex_env_p->properties_p);
JERRY_ASSERT(binding_obj_prop_p != NULL
&& binding_obj_prop_p->u.internal_property.type == ECMA_INTERNAL_PROPERTY_BINDING_OBJECT);
&& binding_obj_prop_p->u.internal_property.type == ECMA_INTERNAL_PROPERTY_BINDING_OBJECT);
return ECMA_GET_POINTER(binding_obj_prop_p->u.internal_property.value);
} /* ecma_get_lex_env_binding_object */
@@ -61,7 +61,7 @@ ecma_get_lex_env_binding_object (ecma_object_t* obj_lex_env_p) /**< object lexic
*/
ecma_completion_value_t
ecma_op_has_binding (ecma_object_t *lex_env_p, /**< lexical environment */
const ecma_char_t *name_p) /**< argument N */
const ecma_char_t *name_p) /**< argument N */
{
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
@@ -73,8 +73,7 @@ ecma_op_has_binding (ecma_object_t *lex_env_p, /**< lexical environment */
{
ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p);
has_binding = (property_p != NULL) ? ECMA_SIMPLE_VALUE_TRUE
: ECMA_SIMPLE_VALUE_FALSE;
has_binding = (property_p != NULL) ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE;
break;
}
@@ -82,16 +81,22 @@ ecma_op_has_binding (ecma_object_t *lex_env_p, /**< lexical environment */
{
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
has_binding = ecma_op_object_has_property (binding_obj_p, name_p) ? ECMA_SIMPLE_VALUE_TRUE
: ECMA_SIMPLE_VALUE_FALSE;
if (ecma_op_object_has_property (binding_obj_p, name_p))
{
has_binding = ECMA_SIMPLE_VALUE_TRUE;
}
else
{
has_binding = ECMA_SIMPLE_VALUE_FALSE;
}
break;
}
}
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_simple_value (has_binding),
ECMA_TARGET_ID_RESERVED);
ecma_make_simple_value (has_binding),
ECMA_TARGET_ID_RESERVED);
} /* ecma_op_has_binding */
/**
@@ -104,8 +109,8 @@ ecma_op_has_binding (ecma_object_t *lex_env_p, /**< lexical environment */
*/
ecma_completion_value_t
ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment */
const ecma_char_t *name_p, /**< argument N */
bool is_deletable) /**< argument D */
const ecma_char_t *name_p, /**< argument N */
bool is_deletable) /**< argument D */
{
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
JERRY_ASSERT(name_p != NULL);
@@ -121,7 +126,7 @@ ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environme
ECMA_PROPERTY_WRITABLE,
ECMA_PROPERTY_NOT_ENUMERABLE,
is_deletable ? ECMA_PROPERTY_CONFIGURABLE
: ECMA_PROPERTY_NOT_CONFIGURABLE);
: ECMA_PROPERTY_NOT_CONFIGURABLE);
break;
@@ -133,20 +138,19 @@ ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environme
JERRY_ASSERT(!ecma_op_object_has_property (binding_obj_p, name_p));
ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor ();
{
prop_desc.is_value_defined = true;
prop_desc.value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
{
prop_desc.is_value_defined = true;
prop_desc.value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
prop_desc.is_writable_defined = true;
prop_desc.writable = ECMA_PROPERTY_WRITABLE;
prop_desc.is_writable_defined = true;
prop_desc.writable = ECMA_PROPERTY_WRITABLE;
prop_desc.is_enumerable_defined = true;
prop_desc.enumerable = ECMA_PROPERTY_ENUMERABLE;
prop_desc.is_enumerable_defined = true;
prop_desc.enumerable = ECMA_PROPERTY_ENUMERABLE;
prop_desc.is_configurable_defined = true;
prop_desc.configurable = is_deletable ? ECMA_PROPERTY_CONFIGURABLE
: ECMA_PROPERTY_NOT_CONFIGURABLE;
}
prop_desc.is_configurable_defined = true;
prop_desc.configurable = is_deletable ? ECMA_PROPERTY_CONFIGURABLE : ECMA_PROPERTY_NOT_CONFIGURABLE;
}
ecma_completion_value_t completion = ecma_op_object_define_own_property (binding_obj_p,
name_p,
@@ -154,12 +158,12 @@ ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environme
true);
if (!(ecma_is_completion_value_normal_true (completion)
|| ecma_is_completion_value_normal_false (completion)))
{
JERRY_ASSERT(ecma_is_completion_value_throw (completion));
|| ecma_is_completion_value_normal_false (completion)))
{
JERRY_ASSERT(ecma_is_completion_value_throw (completion));
return completion;
}
return completion;
}
}
}
@@ -176,9 +180,9 @@ ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environme
*/
ecma_completion_value_t
ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment */
const ecma_char_t *name_p, /**< argument N */
ecma_value_t value, /**< argument V */
bool is_strict) /**< argument S */
const ecma_char_t *name_p, /**< argument N */
ecma_value_t value, /**< argument V */
bool is_strict) /**< argument S */
{
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
JERRY_ASSERT(name_p != NULL);
@@ -192,16 +196,16 @@ ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment
ecma_property_t *property_p = ecma_get_named_data_property (lex_env_p, name_p);
if (property_p->u.named_data_property.writable == ECMA_PROPERTY_WRITABLE)
{
ecma_free_value (property_p->u.named_data_property.value, false);
property_p->u.named_data_property.value = ecma_copy_value (value, false);
{
ecma_free_value (property_p->u.named_data_property.value, false);
property_p->u.named_data_property.value = ecma_copy_value (value, false);
ecma_gc_update_may_ref_younger_object_flag_by_value (lex_env_p, value);
}
ecma_gc_update_may_ref_younger_object_flag_by_value (lex_env_p, value);
}
else if (is_strict)
{
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
}
{
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
}
break;
}
@@ -214,12 +218,12 @@ ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment
value,
is_strict);
if (!(ecma_is_completion_value_normal_true (completion)
|| ecma_is_completion_value_normal_false (completion)))
{
JERRY_ASSERT(ecma_is_completion_value_throw (completion));
|| ecma_is_completion_value_normal_false (completion)))
{
JERRY_ASSERT(ecma_is_completion_value_throw (completion));
return completion;
}
return completion;
}
break;
}
@@ -238,8 +242,8 @@ ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment
*/
ecma_completion_value_t
ecma_op_get_binding_value (ecma_object_t *lex_env_p, /**< lexical environment */
const ecma_char_t *name_p, /**< argument N */
bool is_strict) /**< argument S */
const ecma_char_t *name_p, /**< argument N */
bool is_strict) /**< argument S */
{
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
JERRY_ASSERT(name_p != NULL);
@@ -281,16 +285,16 @@ ecma_op_get_binding_value (ecma_object_t *lex_env_p, /**< lexical environment */
bool has_prop = ecma_op_object_has_property (binding_obj_p, name_p);
if (!has_prop)
{
if (is_strict)
{
if (is_strict)
{
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_REFERENCE));
}
else
{
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
}
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_REFERENCE));
}
else
{
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
}
}
return ecma_op_object_get (binding_obj_p, name_p);
}
@@ -310,7 +314,7 @@ ecma_op_get_binding_value (ecma_object_t *lex_env_p, /**< lexical environment */
*/
ecma_completion_value_t
ecma_op_delete_binding (ecma_object_t *lex_env_p, /**< lexical environment */
const ecma_char_t *name_p) /**< argument N */
const ecma_char_t *name_p) /**< argument N */
{
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
JERRY_ASSERT(name_p != NULL);
@@ -318,32 +322,32 @@ ecma_op_delete_binding (ecma_object_t *lex_env_p, /**< lexical environment */
switch ((ecma_lexical_environment_type_t) lex_env_p->u.lexical_environment.type)
{
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
{
ecma_property_t *prop_p = ecma_find_named_property (lex_env_p, name_p);
ecma_simple_value_t ret_val;
{
ecma_property_t *prop_p = ecma_find_named_property (lex_env_p, name_p);
ecma_simple_value_t ret_val;
if (prop_p == NULL)
if (prop_p == NULL)
{
ret_val = ECMA_SIMPLE_VALUE_TRUE;
} else
{
JERRY_ASSERT(prop_p->type == ECMA_PROPERTY_NAMEDDATA);
if (prop_p->u.named_data_property.configurable == ECMA_PROPERTY_NOT_CONFIGURABLE)
{
ret_val = ECMA_SIMPLE_VALUE_TRUE;
ret_val = ECMA_SIMPLE_VALUE_FALSE;
} else
{
JERRY_ASSERT(prop_p->type == ECMA_PROPERTY_NAMEDDATA);
ecma_delete_property (lex_env_p, prop_p);
if (prop_p->u.named_data_property.configurable == ECMA_PROPERTY_NOT_CONFIGURABLE)
{
ret_val = ECMA_SIMPLE_VALUE_FALSE;
} else
{
ecma_delete_property (lex_env_p, prop_p);
ret_val = ECMA_SIMPLE_VALUE_TRUE;
}
ret_val = ECMA_SIMPLE_VALUE_TRUE;
}
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_simple_value (ret_val),
ECMA_TARGET_ID_RESERVED);
}
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_simple_value (ret_val),
ECMA_TARGET_ID_RESERVED);
}
case ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND:
{
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
@@ -371,9 +375,9 @@ ecma_op_implicit_this_value (ecma_object_t *lex_env_p) /**< lexical environment
switch ((ecma_lexical_environment_type_t) lex_env_p->u.lexical_environment.type)
{
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
{
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
}
{
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
}
case ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND:
{
ecma_property_t *provide_this_prop_p = ecma_get_internal_property (lex_env_p,
@@ -382,18 +386,18 @@ ecma_op_implicit_this_value (ecma_object_t *lex_env_p) /**< lexical environment
bool provide_this = provide_this_prop_p->u.internal_property.value;
if (provide_this)
{
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
ecma_ref_object (binding_obj_p);
{
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
ecma_ref_object (binding_obj_p);
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_object_value (binding_obj_p),
ECMA_TARGET_ID_RESERVED);
}
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_object_value (binding_obj_p),
ECMA_TARGET_ID_RESERVED);
}
else
{
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
}
{
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
}
}
}
@@ -407,31 +411,31 @@ ecma_op_implicit_this_value (ecma_object_t *lex_env_p) /**< lexical environment
*/
void
ecma_op_create_immutable_binding (ecma_object_t *lex_env_p, /**< lexical environment */
const ecma_char_t *name_p) /**< argument N */
const ecma_char_t *name_p) /**< argument N */
{
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
switch ((ecma_lexical_environment_type_t) lex_env_p->u.lexical_environment.type)
{
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
{
JERRY_ASSERT(ecma_is_completion_value_normal_false (ecma_op_has_binding (lex_env_p, name_p)));
{
JERRY_ASSERT(ecma_is_completion_value_normal_false (ecma_op_has_binding (lex_env_p, name_p)));
/*
* Warning:
* Whether immutable bindings are deletable seems not to be defined by ECMA v5.
*/
ecma_property_t *prop_p = ecma_create_named_data_property (lex_env_p,
name_p,
ECMA_PROPERTY_NOT_WRITABLE,
ECMA_PROPERTY_NOT_ENUMERABLE,
ECMA_PROPERTY_NOT_CONFIGURABLE);
/*
* Warning:
* Whether immutable bindings are deletable seems not to be defined by ECMA v5.
*/
ecma_property_t *prop_p = ecma_create_named_data_property (lex_env_p,
name_p,
ECMA_PROPERTY_NOT_WRITABLE,
ECMA_PROPERTY_NOT_ENUMERABLE,
ECMA_PROPERTY_NOT_CONFIGURABLE);
JERRY_ASSERT(ecma_is_value_undefined (prop_p->u.named_data_property.value));
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;
}
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:
{
JERRY_UNREACHABLE();
@@ -448,27 +452,27 @@ ecma_op_create_immutable_binding (ecma_object_t *lex_env_p, /**< lexical environ
*/
void
ecma_op_initialize_immutable_binding (ecma_object_t *lex_env_p, /**< lexical environment */
const ecma_char_t *name_p, /**< argument N */
ecma_value_t value) /**< argument V */
const ecma_char_t *name_p, /**< argument N */
ecma_value_t value) /**< argument V */
{
JERRY_ASSERT(lex_env_p != NULL && lex_env_p->is_lexical_environment);
switch ((ecma_lexical_environment_type_t) lex_env_p->u.lexical_environment.type)
{
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
{
JERRY_ASSERT(ecma_is_completion_value_normal_true (ecma_op_has_binding (lex_env_p, name_p)));
{
JERRY_ASSERT(ecma_is_completion_value_normal_true (ecma_op_has_binding (lex_env_p, name_p)));
ecma_property_t *prop_p = ecma_get_named_data_property (lex_env_p, name_p);
ecma_property_t *prop_p = ecma_get_named_data_property (lex_env_p, name_p);
/* The binding must be unitialized immutable binding */
JERRY_ASSERT(prop_p->u.named_data_property.writable == ECMA_PROPERTY_NOT_WRITABLE
&& ecma_is_value_empty (prop_p->u.named_data_property.value));
/* The binding must be unitialized immutable binding */
JERRY_ASSERT(prop_p->u.named_data_property.writable == ECMA_PROPERTY_NOT_WRITABLE
&& ecma_is_value_empty (prop_p->u.named_data_property.value));
prop_p->u.named_data_property.value = ecma_copy_value (value, false);
prop_p->u.named_data_property.value = ecma_copy_value (value, false);
ecma_gc_update_may_ref_younger_object_flag_by_value (lex_env_p, value);
}
ecma_gc_update_may_ref_younger_object_flag_by_value (lex_env_p, value);
}
case ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND:
{
JERRY_UNREACHABLE();
+8 -14
View File
@@ -33,20 +33,14 @@ ecma_get_magic_string (ecma_magic_string_id_t id) /**< magic string id */
TODO(Support UTF-16);
switch (id)
{
case ECMA_MAGIC_STRING_ARGUMENTS:
return (ecma_char_t*) "arguments";
case ECMA_MAGIC_STRING_EVAL:
return (ecma_char_t*) "eval";
case ECMA_MAGIC_STRING_PROTOTYPE:
return (ecma_char_t*) "prototype";
case ECMA_MAGIC_STRING_CONSTRUCTOR:
return (ecma_char_t*) "constructor";
case ECMA_MAGIC_STRING_CALLER:
return (ecma_char_t*) "caller";
case ECMA_MAGIC_STRING_UNDEFINED:
return (ecma_char_t*) "undefined";
}
{
case ECMA_MAGIC_STRING_ARGUMENTS: return (ecma_char_t*) "arguments";
case ECMA_MAGIC_STRING_EVAL: return (ecma_char_t*) "eval";
case ECMA_MAGIC_STRING_PROTOTYPE: return (ecma_char_t*) "prototype";
case ECMA_MAGIC_STRING_CONSTRUCTOR: return (ecma_char_t*) "constructor";
case ECMA_MAGIC_STRING_CALLER: return (ecma_char_t*) "caller";
case ECMA_MAGIC_STRING_UNDEFINED: return (ecma_char_t*) "undefined";
}
JERRY_UNREACHABLE();
} /* ecma_get_magic_string */
@@ -35,7 +35,7 @@
*/
ecma_number_t
ecma_op_number_add (ecma_number_t left_num, /**< left operand */
ecma_number_t right_num) /**< right operand */
ecma_number_t right_num) /**< right operand */
{
TODO(Implement according to ECMA);
@@ -52,7 +52,7 @@ ecma_op_number_add (ecma_number_t left_num, /**< left operand */
*/
ecma_number_t
ecma_op_number_substract (ecma_number_t left_num, /**< left operand */
ecma_number_t right_num) /**< right operand */
ecma_number_t right_num) /**< right operand */
{
return ecma_op_number_add (left_num, ecma_op_number_negate (right_num));
} /* ecma_op_number_substract */
@@ -67,7 +67,7 @@ ecma_op_number_substract (ecma_number_t left_num, /**< left operand */
*/
ecma_number_t
ecma_op_number_multiply (ecma_number_t left_num, /**< left operand */
ecma_number_t right_num) /**< right operand */
ecma_number_t right_num) /**< right operand */
{
TODO(Implement according to ECMA);
@@ -84,7 +84,7 @@ ecma_op_number_multiply (ecma_number_t left_num, /**< left operand */
*/
ecma_number_t
ecma_op_number_divide (ecma_number_t left_num, /**< left operand */
ecma_number_t right_num) /**< right operand */
ecma_number_t right_num) /**< right operand */
{
TODO(Implement according to ECMA);
@@ -101,13 +101,13 @@ ecma_op_number_divide (ecma_number_t left_num, /**< left operand */
*/
ecma_number_t
ecma_op_number_remainder (ecma_number_t left_num, /**< left operand */
ecma_number_t right_num) /**< right operand */
ecma_number_t right_num) /**< right operand */
{
TODO(Implement according to ECMA);
ecma_number_t n = left_num, d = right_num;
return (n - d * (ecma_number_t)((int32_t)(n / d)));
return (n - d * (ecma_number_t) ((int32_t) (n / d)));
} /* ecma_op_number_remainder */
/**
+358 -358
View File
@@ -36,13 +36,13 @@ static ecma_completion_value_t
ecma_reject (bool is_throw) /**< Throw flag */
{
if (is_throw)
{
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
}
{
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
}
else
{
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE);
}
{
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE);
}
} /* ecma_reject */
/**
@@ -72,35 +72,35 @@ ecma_op_object_get (ecma_object_t *obj_p, /**< the object */
// 2.
if (prop_p == NULL)
{
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
}
{
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
}
// 3.
if (prop_p->type == ECMA_PROPERTY_NAMEDDATA)
{
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_copy_value (prop_p->u.named_data_property.value, true),
ECMA_TARGET_ID_RESERVED);
}
{
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_copy_value (prop_p->u.named_data_property.value, true),
ECMA_TARGET_ID_RESERVED);
}
else
{
// 4.
ecma_object_t *getter = ECMA_GET_POINTER(prop_p->u.named_accessor_property.get_p);
{
// 4.
ecma_object_t *getter = ECMA_GET_POINTER(prop_p->u.named_accessor_property.get_p);
// 5.
if (getter == NULL)
{
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
}
else
{
/*
* Return result of O.[[Call]];
*/
JERRY_UNIMPLEMENTED();
}
// 5.
if (getter == NULL)
{
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
}
else
{
/*
* Return result of O.[[Call]];
*/
JERRY_UNIMPLEMENTED();
}
}
JERRY_UNREACHABLE();
} /* ecma_op_object_get */
@@ -157,22 +157,22 @@ ecma_op_object_get_property (ecma_object_t *obj_p, /**< the object */
// 2.
if (prop_p != NULL)
{
return prop_p;
}
{
return prop_p;
}
// 3.
ecma_object_t *prototype_p = ECMA_GET_POINTER(obj_p->u.object.prototype_object_p);
// 4., 5.
if (prototype_p != NULL)
{
return ecma_op_object_get_property (prototype_p, property_name_p);
}
{
return ecma_op_object_get_property (prototype_p, property_name_p);
}
else
{
return NULL;
}
{
return NULL;
}
} /* ecma_op_object_get_property */
/**
@@ -195,85 +195,85 @@ ecma_op_object_put (ecma_object_t *obj_p, /**< the object */
// 1.
if (!ecma_op_object_can_put (obj_p, property_name_p))
{
if (is_throw)
{
if (is_throw)
{
// a.
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
}
else
{
// b.
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE);
}
// a.
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
}
else
{
// b.
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE);
}
}
// 2.
ecma_property_t *own_desc_p = ecma_op_object_get_own_property (obj_p, property_name_p);
// 3.
if (own_desc_p != NULL
&& own_desc_p->type == ECMA_PROPERTY_NAMEDDATA)
&& own_desc_p->type == ECMA_PROPERTY_NAMEDDATA)
{
// a.
ecma_property_descriptor_t value_desc = ecma_make_empty_property_descriptor ();
{
// a.
ecma_property_descriptor_t value_desc = ecma_make_empty_property_descriptor ();
{
value_desc.is_value_defined = true;
value_desc.value = value;
}
// b., c.
return ecma_op_object_define_own_property (obj_p,
property_name_p,
value_desc,
is_throw);
value_desc.is_value_defined = true;
value_desc.value = value;
}
// b., c.
return ecma_op_object_define_own_property (obj_p,
property_name_p,
value_desc,
is_throw);
}
// 4.
ecma_property_t *desc_p = ecma_op_object_get_property (obj_p, property_name_p);
// 5.
if (desc_p != NULL
&& desc_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
{
// a.
ecma_object_t *setter_p = ECMA_GET_POINTER(desc_p->u.named_accessor_property.set_p);
&& desc_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
{
// a.
ecma_object_t *setter_p = ECMA_GET_POINTER(desc_p->u.named_accessor_property.set_p);
JERRY_ASSERT(setter_p != NULL);
JERRY_ASSERT(setter_p != NULL);
// b.
/*
* setter_p->[[Call]](obj_p, value);
*/
JERRY_UNIMPLEMENTED();
}
// b.
/*
* setter_p->[[Call]](obj_p, value);
*/
JERRY_UNIMPLEMENTED();
}
else
{
// 6.
// a.
ecma_property_descriptor_t new_desc = ecma_make_empty_property_descriptor ();
{
// 6.
new_desc.is_value_defined = true;
new_desc.value = value;
// a.
ecma_property_descriptor_t new_desc = ecma_make_empty_property_descriptor ();
{
new_desc.is_value_defined = true;
new_desc.value = value;
new_desc.is_writable_defined = true;
new_desc.writable = ECMA_PROPERTY_WRITABLE;
new_desc.is_writable_defined = true;
new_desc.writable = ECMA_PROPERTY_WRITABLE;
new_desc.is_enumerable_defined = true;
new_desc.enumerable = ECMA_PROPERTY_ENUMERABLE;
new_desc.is_enumerable_defined = true;
new_desc.enumerable = ECMA_PROPERTY_ENUMERABLE;
new_desc.is_configurable_defined = true;
new_desc.configurable = ECMA_PROPERTY_CONFIGURABLE;
}
// b.
return ecma_op_object_define_own_property (obj_p,
property_name_p,
new_desc,
is_throw);
new_desc.is_configurable_defined = true;
new_desc.configurable = ECMA_PROPERTY_CONFIGURABLE;
}
// b.
return ecma_op_object_define_own_property (obj_p,
property_name_p,
new_desc,
is_throw);
}
JERRY_UNREACHABLE();
} /* ecma_op_object_put */
@@ -304,79 +304,79 @@ ecma_op_object_can_put (ecma_object_t *obj_p, /**< the object */
// 2.
if (prop_p != NULL)
{
// a.
if (prop_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
{
// a.
if (prop_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
{
ecma_object_t *setter_p = ECMA_GET_POINTER(prop_p->u.named_accessor_property.set_p);
ecma_object_t *setter_p = ECMA_GET_POINTER(prop_p->u.named_accessor_property.set_p);
// i.
if (setter_p == NULL)
{
return false;
}
// i.
if (setter_p == NULL)
{
return false;
}
// ii.
return true;
}
else
{
// b.
JERRY_ASSERT(prop_p->type == ECMA_PROPERTY_NAMEDDATA);
return (prop_p->u.named_data_property.writable == ECMA_PROPERTY_WRITABLE);
}
// ii.
return true;
}
else
{
// b.
JERRY_ASSERT(prop_p->type == ECMA_PROPERTY_NAMEDDATA);
return (prop_p->u.named_data_property.writable == ECMA_PROPERTY_WRITABLE);
}
}
// 3.
ecma_object_t *proto_p = ECMA_GET_POINTER(obj_p->u.object.prototype_object_p);
// 4.
if (proto_p == NULL)
{
return obj_p->u.object.extensible;
}
{
return obj_p->u.object.extensible;
}
// 5.
ecma_property_t *inherited_p = ecma_op_object_get_property (proto_p, property_name_p);
// 6.
if (inherited_p == NULL)
{
return obj_p->u.object.extensible;
}
{
return obj_p->u.object.extensible;
}
// 7.
if (inherited_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
{
ecma_object_t *setter_p = ECMA_GET_POINTER(inherited_p->u.named_accessor_property.set_p);
// a.
if (setter_p == NULL)
{
ecma_object_t *setter_p = ECMA_GET_POINTER(inherited_p->u.named_accessor_property.set_p);
// a.
if (setter_p == NULL)
{
return false;
}
// b.
return true;
return false;
}
// b.
return true;
}
else
{
// 8.
JERRY_ASSERT(inherited_p->type == ECMA_PROPERTY_NAMEDDATA);
{
// 8.
JERRY_ASSERT(inherited_p->type == ECMA_PROPERTY_NAMEDDATA);
// a.
if (!obj_p->u.object.extensible)
{
return false;
}
else
{
// b.
return (inherited_p->u.named_data_property.writable == ECMA_PROPERTY_WRITABLE);
}
// a.
if (!obj_p->u.object.extensible)
{
return false;
}
else
{
// b.
return (inherited_p->u.named_data_property.writable == ECMA_PROPERTY_WRITABLE);
}
}
JERRY_UNREACHABLE();
} /* ecma_op_object_can_put */
@@ -436,41 +436,41 @@ ecma_op_object_delete (ecma_object_t *obj_p, /**< the object */
// 2.
if (desc_p == NULL)
{
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
}
{
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
}
// 3.
bool is_configurable;
if (desc_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
{
is_configurable = desc_p->u.named_accessor_property.configurable;
}
{
is_configurable = desc_p->u.named_accessor_property.configurable;
}
else
{
JERRY_ASSERT(desc_p->type == ECMA_PROPERTY_NAMEDDATA);
{
JERRY_ASSERT(desc_p->type == ECMA_PROPERTY_NAMEDDATA);
is_configurable = desc_p->u.named_data_property.configurable;
}
is_configurable = desc_p->u.named_data_property.configurable;
}
if (is_configurable)
{
// a.
ecma_delete_property (obj_p, desc_p);
{
// a.
ecma_delete_property (obj_p, desc_p);
// b.
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
}
// b.
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
}
else if (is_throw)
{
// 4.
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
}
{
// 4.
return ecma_make_throw_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
}
else
{
// 5.
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE);
}
{
// 5.
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE);
}
JERRY_UNREACHABLE();
} /* ecma_op_object_delete */
@@ -512,13 +512,13 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
JERRY_ASSERT(property_name_p != NULL);
const bool is_property_desc_generic_descriptor = (!property_desc.is_value_defined
&& !property_desc.is_writable_defined
&& !property_desc.is_get_defined
&& !property_desc.is_set_defined);
&& !property_desc.is_writable_defined
&& !property_desc.is_get_defined
&& !property_desc.is_set_defined);
const bool is_property_desc_data_descriptor = (property_desc.is_value_defined
|| property_desc.is_writable_defined);
|| property_desc.is_writable_defined);
const bool is_property_desc_accessor_descriptor = (property_desc.is_get_defined
|| property_desc.is_set_defined);
|| property_desc.is_set_defined);
// 1.
ecma_property_t *current_p = ecma_op_object_get_own_property (obj_p, property_name_p);
@@ -527,55 +527,55 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
bool extensible = obj_p->u.object.extensible;
if (current_p == NULL)
{
// 3.
if (!extensible)
{
// 3.
if (!extensible)
{
return ecma_reject (is_throw);
}
else
{
// 4.
// a.
if (is_property_desc_generic_descriptor
|| is_property_desc_data_descriptor)
{
ecma_property_t *new_prop_p = ecma_create_named_data_property (obj_p,
property_name_p,
property_desc.writable,
property_desc.enumerable,
property_desc.configurable);
new_prop_p->u.named_data_property.value = ecma_copy_value (property_desc.value, false);
ecma_gc_update_may_ref_younger_object_flag_by_value (obj_p, property_desc.value);
}
else
{
// b.
JERRY_ASSERT(is_property_desc_accessor_descriptor);
ecma_create_named_accessor_property (obj_p,
property_name_p,
property_desc.get_p,
property_desc.set_p,
property_desc.enumerable,
property_desc.configurable);
}
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
}
return ecma_reject (is_throw);
}
else
{
// 4.
// a.
if (is_property_desc_generic_descriptor
|| is_property_desc_data_descriptor)
{
ecma_property_t *new_prop_p = ecma_create_named_data_property (obj_p,
property_name_p,
property_desc.writable,
property_desc.enumerable,
property_desc.configurable);
new_prop_p->u.named_data_property.value = ecma_copy_value (property_desc.value, false);
ecma_gc_update_may_ref_younger_object_flag_by_value (obj_p, property_desc.value);
}
else
{
// b.
JERRY_ASSERT(is_property_desc_accessor_descriptor);
ecma_create_named_accessor_property (obj_p,
property_name_p,
property_desc.get_p,
property_desc.set_p,
property_desc.enumerable,
property_desc.configurable);
}
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
}
}
// 5.
if (is_property_desc_generic_descriptor
&& !property_desc.is_enumerable_defined
&& !property_desc.is_configurable_defined)
{
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
}
&& !property_desc.is_enumerable_defined
&& !property_desc.is_configurable_defined)
{
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
}
// 6.
const bool is_current_data_descriptor = (current_p->type == ECMA_PROPERTY_NAMEDDATA);
@@ -583,226 +583,226 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
const ecma_property_enumerable_value_t current_enumerable =
is_current_data_descriptor ? current_p->u.named_data_property.enumerable
: current_p->u.named_accessor_property.enumerable;
: current_p->u.named_accessor_property.enumerable;
const ecma_property_configurable_value_t current_configurable =
is_current_data_descriptor ? current_p->u.named_data_property.configurable
: current_p->u.named_accessor_property.configurable;
: current_p->u.named_accessor_property.configurable;
JERRY_ASSERT(is_current_data_descriptor || is_current_accessor_descriptor);
bool is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = true;
if (property_desc.is_value_defined)
{
if (!is_current_data_descriptor
|| !ecma_op_same_value (property_desc.value,
current_p->u.named_data_property.value))
{
if (!is_current_data_descriptor
|| !ecma_op_same_value (property_desc.value,
current_p->u.named_data_property.value))
{
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
}
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
}
}
if (property_desc.is_writable_defined)
{
if (!is_current_data_descriptor
|| property_desc.writable != current_p->u.named_data_property.writable)
{
if (!is_current_data_descriptor
|| property_desc.writable != current_p->u.named_data_property.writable)
{
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
}
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
}
}
if (property_desc.is_get_defined)
{
if (!is_current_accessor_descriptor
|| property_desc.get_p != ECMA_GET_POINTER(current_p->u.named_accessor_property.get_p))
{
if (!is_current_accessor_descriptor
|| property_desc.get_p != ECMA_GET_POINTER(current_p->u.named_accessor_property.get_p))
{
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
}
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
}
}
if (property_desc.is_set_defined)
{
if (!is_current_accessor_descriptor
|| property_desc.set_p != ECMA_GET_POINTER(current_p->u.named_accessor_property.set_p))
{
if (!is_current_accessor_descriptor
|| property_desc.set_p != ECMA_GET_POINTER(current_p->u.named_accessor_property.set_p))
{
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
}
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
}
}
if (property_desc.is_enumerable_defined)
{
if (property_desc.enumerable != current_enumerable)
{
if (property_desc.enumerable != current_enumerable)
{
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
}
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
}
}
if (property_desc.is_configurable_defined)
{
if (property_desc.configurable != current_configurable)
{
if (property_desc.configurable != current_configurable)
{
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
}
is_every_field_in_desc_also_occurs_in_current_desc_with_same_value = false;
}
}
if (is_every_field_in_desc_also_occurs_in_current_desc_with_same_value)
{
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
}
{
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
}
// 7.
if (current_p->u.named_accessor_property.configurable == ECMA_PROPERTY_NOT_CONFIGURABLE)
{
if (property_desc.configurable == ECMA_PROPERTY_CONFIGURABLE
|| (property_desc.is_enumerable_defined
&& property_desc.enumerable != current_enumerable))
{
if (property_desc.configurable == ECMA_PROPERTY_CONFIGURABLE
|| (property_desc.is_enumerable_defined
&& property_desc.enumerable != current_enumerable))
{
// a., b.
return ecma_reject (is_throw);
}
// a., b.
return ecma_reject (is_throw);
}
}
// 8.
if (is_property_desc_generic_descriptor)
{
// no action required
}
{
// no action required
}
else if (is_property_desc_data_descriptor != is_current_data_descriptor)
{
// 9.
if (current_configurable == ECMA_PROPERTY_NOT_CONFIGURABLE)
{
// 9.
if (current_configurable == ECMA_PROPERTY_NOT_CONFIGURABLE)
// a.
return ecma_reject (is_throw);
}
ecma_delete_property (obj_p, current_p);
if (is_current_data_descriptor)
{
// b.
current_p = ecma_create_named_accessor_property (obj_p,
property_name_p,
NULL,
NULL,
current_enumerable,
current_configurable);
}
else
{
// c.
current_p = ecma_create_named_data_property (obj_p,
property_name_p,
ECMA_PROPERTY_NOT_WRITABLE,
current_enumerable,
current_configurable);
}
}
else if (is_property_desc_data_descriptor && is_current_data_descriptor)
{
// 10.
if (current_configurable == ECMA_PROPERTY_NOT_CONFIGURABLE)
{
// a.
if (current_p->u.named_data_property.writable == ECMA_PROPERTY_NOT_WRITABLE)
{
// i.
if (property_desc.writable == ECMA_PROPERTY_WRITABLE)
{
// a.
return ecma_reject (is_throw);
}
ecma_delete_property (obj_p, current_p);
if (is_current_data_descriptor)
// ii.
if (property_desc.is_value_defined
&& !ecma_op_same_value (property_desc.value,
current_p->u.named_data_property.value))
{
// b.
current_p = ecma_create_named_accessor_property (obj_p,
property_name_p,
NULL,
NULL,
current_enumerable,
current_configurable);
}
else
{
// c.
current_p = ecma_create_named_data_property (obj_p,
property_name_p,
ECMA_PROPERTY_NOT_WRITABLE,
current_enumerable,
current_configurable);
}
}
else if (is_property_desc_data_descriptor && is_current_data_descriptor)
{
// 10.
if (current_configurable == ECMA_PROPERTY_NOT_CONFIGURABLE)
{
// a.
if (current_p->u.named_data_property.writable == ECMA_PROPERTY_NOT_WRITABLE)
{
// i.
if (property_desc.writable == ECMA_PROPERTY_WRITABLE)
{
return ecma_reject (is_throw);
}
// ii.
if (property_desc.is_value_defined
&& !ecma_op_same_value (property_desc.value,
current_p->u.named_data_property.value))
{
return ecma_reject (is_throw);
}
}
return ecma_reject (is_throw);
}
}
}
}
else
{
JERRY_ASSERT(is_property_desc_accessor_descriptor && is_current_accessor_descriptor);
// 11.
if (current_configurable == ECMA_PROPERTY_NOT_CONFIGURABLE)
{
JERRY_ASSERT(is_property_desc_accessor_descriptor && is_current_accessor_descriptor);
// a.
// 11.
if (current_configurable == ECMA_PROPERTY_NOT_CONFIGURABLE)
{
// a.
if ((property_desc.is_get_defined
&& property_desc.get_p != ECMA_GET_POINTER(current_p->u.named_accessor_property.get_p))
|| (property_desc.is_set_defined
&& property_desc.set_p != ECMA_GET_POINTER(current_p->u.named_accessor_property.set_p)))
{
// i., ii.
return ecma_reject (is_throw);
}
}
if ((property_desc.is_get_defined
&& property_desc.get_p != ECMA_GET_POINTER(current_p->u.named_accessor_property.get_p))
|| (property_desc.is_set_defined
&& property_desc.set_p != ECMA_GET_POINTER(current_p->u.named_accessor_property.set_p)))
{
// i., ii.
return ecma_reject (is_throw);
}
}
}
// 12.
if (property_desc.is_value_defined)
{
JERRY_ASSERT(is_current_data_descriptor);
{
JERRY_ASSERT(is_current_data_descriptor);
ecma_free_value (current_p->u.named_data_property.value, false);
current_p->u.named_data_property.value = ecma_copy_value (property_desc.value, false);
ecma_free_value (current_p->u.named_data_property.value, false);
current_p->u.named_data_property.value = ecma_copy_value (property_desc.value, false);
ecma_gc_update_may_ref_younger_object_flag_by_value (obj_p, property_desc.value);
}
ecma_gc_update_may_ref_younger_object_flag_by_value (obj_p, property_desc.value);
}
if (property_desc.is_writable_defined)
{
JERRY_ASSERT(is_current_data_descriptor);
{
JERRY_ASSERT(is_current_data_descriptor);
current_p->u.named_data_property.writable = property_desc.writable;
}
current_p->u.named_data_property.writable = property_desc.writable;
}
if (property_desc.is_get_defined)
{
JERRY_ASSERT(is_current_accessor_descriptor);
{
JERRY_ASSERT(is_current_accessor_descriptor);
ECMA_SET_POINTER(current_p->u.named_accessor_property.get_p, property_desc.get_p);
ECMA_SET_POINTER(current_p->u.named_accessor_property.get_p, property_desc.get_p);
ecma_gc_update_may_ref_younger_object_flag_by_object (obj_p, property_desc.get_p);
}
ecma_gc_update_may_ref_younger_object_flag_by_object (obj_p, property_desc.get_p);
}
if (property_desc.is_set_defined)
{
JERRY_ASSERT(is_current_accessor_descriptor);
{
JERRY_ASSERT(is_current_accessor_descriptor);
ECMA_SET_POINTER(current_p->u.named_accessor_property.set_p, property_desc.set_p);
ECMA_SET_POINTER(current_p->u.named_accessor_property.set_p, property_desc.set_p);
ecma_gc_update_may_ref_younger_object_flag_by_object (obj_p, property_desc.set_p);
}
ecma_gc_update_may_ref_younger_object_flag_by_object (obj_p, property_desc.set_p);
}
if (property_desc.is_enumerable_defined)
{
if (is_current_data_descriptor)
{
if (is_current_data_descriptor)
{
current_p->u.named_data_property.enumerable = property_desc.enumerable;
}
else
{
current_p->u.named_accessor_property.enumerable = property_desc.enumerable;
}
current_p->u.named_data_property.enumerable = property_desc.enumerable;
}
else
{
current_p->u.named_accessor_property.enumerable = property_desc.enumerable;
}
}
if (property_desc.is_configurable_defined)
{
if (is_current_data_descriptor)
{
if (is_current_data_descriptor)
{
current_p->u.named_data_property.configurable = property_desc.configurable;
}
else
{
current_p->u.named_accessor_property.configurable = property_desc.configurable;
}
current_p->u.named_data_property.configurable = property_desc.configurable;
}
else
{
current_p->u.named_accessor_property.configurable = property_desc.configurable;
}
}
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
} /* ecma_op_object_define_own_property */
+14 -11
View File
@@ -41,8 +41,8 @@
*/
ecma_reference_t
ecma_op_get_identifier_reference (ecma_object_t *lex_env_p, /**< lexical environment */
const ecma_char_t *name_p, /**< identifier's name */
bool is_strict) /**< strict reference flag */
const ecma_char_t *name_p, /**< identifier's name */
bool is_strict) /**< strict reference flag */
{
JERRY_ASSERT(lex_env_p != NULL);
@@ -56,8 +56,8 @@ ecma_op_get_identifier_reference (ecma_object_t *lex_env_p, /**< lexical environ
if (ecma_is_completion_value_normal_true (completion_value))
{
return ecma_make_reference (ecma_make_object_value (lex_env_iter_p),
name_p,
is_strict);
name_p,
is_strict);
} else
{
JERRY_ASSERT(ecma_is_completion_value_normal_false (completion_value));
@@ -67,8 +67,8 @@ ecma_op_get_identifier_reference (ecma_object_t *lex_env_p, /**< lexical environ
}
return ecma_make_reference (ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
name_p,
is_strict);
name_p,
is_strict);
} /* ecma_op_get_identifier_reference */
/**
@@ -83,12 +83,15 @@ ecma_op_get_identifier_reference (ecma_object_t *lex_env_p, /**< lexical environ
*/
ecma_reference_t
ecma_make_reference (ecma_value_t base, /**< base value */
const ecma_char_t *name_p, /**< referenced name */
bool is_strict) /**< strict reference flag */
const ecma_char_t *name_p, /**< referenced name */
bool is_strict) /**< strict reference flag */
{
ecma_reference_t ref = (ecma_reference_t) { .base = ecma_copy_value (base, true),
.referenced_name_p = name_p,
.is_strict = is_strict };
ecma_reference_t ref = (ecma_reference_t)
{
.base = ecma_copy_value (base, true),
.referenced_name_p = name_p,
.is_strict = is_strict
};
return ref;
} /* ecma_make_reference */