Fixing object declaration and function expression opcode handlers; adding unit test that declares object and operates on the object's properties.

This commit is contained in:
Ruben Ayrapetyan
2014-09-04 21:02:29 +04:00
parent 5630352f36
commit b9fd80ce36
3 changed files with 179 additions and 12 deletions
+20 -11
View File
@@ -595,6 +595,8 @@ ecma_completion_value_t
opfunc_func_expr_n (opcode_t opdata, /**< operation data */
int_data_t *int_data) /**< interpreter context */
{
int_data->pos++;
const idx_t dst_var_idx = opdata.data.func_expr_n.lhs;
const idx_t function_name_lit_idx = opdata.data.func_expr_n.name_lit_idx;
const ecma_length_t params_number = opdata.data.func_expr_n.arg_list;
@@ -985,9 +987,12 @@ opfunc_obj_decl (opcode_t opdata, /**< operation data */
ecma_string_t *prop_name_string_p = ecma_new_ecma_string_from_lit_index (prop_name_lit_idx);
ecma_property_t *previous_p = ecma_op_object_get_own_property (obj_p, prop_name_string_p);
const bool is_previous_data_desc = (previous_p->type == ECMA_PROPERTY_NAMEDDATA);
const bool is_previous_accessor_desc = (previous_p->type == ECMA_PROPERTY_NAMEDACCESSOR);
JERRY_ASSERT (is_previous_data_desc || is_previous_accessor_desc);
const bool is_previous_undefined = (previous_p == NULL);
const bool is_previous_data_desc = (!is_previous_undefined
&& previous_p->type == ECMA_PROPERTY_NAMEDDATA);
const bool is_previous_accessor_desc = (!is_previous_undefined
&& previous_p->type == ECMA_PROPERTY_NAMEDACCESSOR);
JERRY_ASSERT (is_previous_undefined || is_previous_data_desc || is_previous_accessor_desc);
ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor ();
{
@@ -1006,9 +1011,10 @@ opfunc_obj_decl (opcode_t opdata, /**< operation data */
prop_desc.is_writable_defined = true;
prop_desc.writable = ECMA_PROPERTY_WRITABLE;
if ((is_previous_data_desc
&& int_data->is_strict)
|| is_previous_accessor_desc)
if (!is_previous_undefined
&& ((is_previous_data_desc
&& int_data->is_strict)
|| is_previous_accessor_desc))
{
is_throw_syntax_error = true;
}
@@ -1020,7 +1026,8 @@ opfunc_obj_decl (opcode_t opdata, /**< operation data */
prop_desc.is_get_defined = true;
prop_desc.get_p = ECMA_GET_POINTER (value_for_prop_desc.u.value.value);
if (is_previous_data_desc)
if (!is_previous_undefined
&& is_previous_data_desc)
{
is_throw_syntax_error = true;
}
@@ -1032,7 +1039,8 @@ opfunc_obj_decl (opcode_t opdata, /**< operation data */
prop_desc.is_set_defined = true;
prop_desc.set_p = ECMA_GET_POINTER (value_for_prop_desc.u.value.value);
if (is_previous_data_desc)
if (!is_previous_undefined
&& is_previous_data_desc)
{
is_throw_syntax_error = true;
}
@@ -1765,6 +1773,9 @@ opfunc_meta (opcode_t opdata, /**< operation data */
switch (type)
{
case OPCODE_META_TYPE_VARG:
case OPCODE_META_TYPE_VARG_PROP_DATA:
case OPCODE_META_TYPE_VARG_PROP_GETTER:
case OPCODE_META_TYPE_VARG_PROP_SETTER:
case OPCODE_META_TYPE_END_WITH:
case OPCODE_META_TYPE_CATCH:
case OPCODE_META_TYPE_FINALLY:
@@ -1774,9 +1785,7 @@ opfunc_meta (opcode_t opdata, /**< operation data */
}
case OPCODE_META_TYPE_UNDEFINED:
case OPCODE_META_TYPE_THIS_ARG:
case OPCODE_META_TYPE_VARG_PROP_DATA:
case OPCODE_META_TYPE_VARG_PROP_GETTER:
case OPCODE_META_TYPE_VARG_PROP_SETTER:
case OPCODE_META_TYPE_FUNCTION_END:
case OPCODE_META_TYPE_CATCH_EXCEPTION_IDENTIFIER:
case OPCODE_META_TYPE_STRICT_CODE:
+1 -1
View File
@@ -61,7 +61,7 @@ ecma_op_create_object_object_noarg (void)
FIXME (/* Set to built-in Object prototype (15.2.4) */);
// 3., 4., 6., 7.
ecma_object_t *obj_p = ecma_create_object (NULL, false, ECMA_OBJECT_TYPE_GENERAL);
ecma_object_t *obj_p = ecma_create_object (NULL, true, ECMA_OBJECT_TYPE_GENERAL);
ecma_property_t *class_prop_p = ecma_create_internal_property (obj_p, ECMA_INTERNAL_PROPERTY_CLASS);
class_prop_p->u.internal_property.value = ECMA_OBJECT_CLASS_OBJECT;