Implement the Symbol builtin object (#2601)

This patch contains the base functionalities that the new builtin object requires.

Currently unavailable:
 - print (Symbol('foo')) - this features requires the refactor of the print handler function
 - Several global symbol based builtin routines (follow up patch)

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2019-01-16 10:09:23 +01:00
committed by Robert Sipka
parent 08c7183ef8
commit 7e3d688e5b
43 changed files with 1896 additions and 212 deletions
+7 -9
View File
@@ -162,14 +162,12 @@ vm_op_delete_prop (ecma_value_t object, /**< base object */
}
JERRY_ASSERT (check_coercible == ECMA_VALUE_EMPTY);
ecma_value_t str_name_value = ecma_op_to_string (property);
if (ECMA_IS_VALUE_ERROR (str_name_value))
{
return str_name_value;
}
ecma_string_t *name_string_p = ecma_op_to_prop_name (property);
JERRY_ASSERT (ecma_is_value_string (str_name_value));
ecma_string_t *name_string_p = ecma_get_string_from_value (str_name_value);
if (JERRY_UNLIKELY (name_string_p == NULL))
{
return ECMA_VALUE_ERROR;
}
ecma_value_t obj_value = ecma_op_to_object (object);
/* The ecma_op_check_object_coercible call already checked the op_to_object error cases. */
@@ -180,8 +178,8 @@ vm_op_delete_prop (ecma_value_t object, /**< base object */
ecma_value_t delete_op_ret = ecma_op_object_delete (obj_p, name_string_p, is_strict);
JERRY_ASSERT (ecma_is_value_boolean (delete_op_ret) || (is_strict == true && ECMA_IS_VALUE_ERROR (delete_op_ret)));
ecma_free_value (obj_value);
ecma_free_value (str_name_value);
ecma_deref_object (obj_p);
ecma_deref_ecma_string (name_string_p);
return delete_op_ret;
} /* vm_op_delete_prop */
+25 -16
View File
@@ -70,6 +70,13 @@ vm_op_get_value (ecma_value_t object, /**< base object */
property_name_p = ecma_get_string_from_value (property);
}
#ifndef CONFIG_DISABLE_ES2015_SYMBOL_BUILTIN
if (ecma_is_value_symbol (property))
{
property_name_p = ecma_get_symbol_from_value (property);
}
#endif /* !CONFIG_DISABLE_ES2015_SYMBOL_BUILTIN */
if (property_name_p != NULL)
{
#ifndef CONFIG_ECMA_LCACHE_DISABLE
@@ -101,15 +108,13 @@ vm_op_get_value (ecma_value_t object, /**< base object */
return error_value;
}
ecma_value_t prop_to_string_result = ecma_op_to_string (property);
ecma_string_t *property_name_p = ecma_op_to_prop_name (property);
if (ECMA_IS_VALUE_ERROR (prop_to_string_result))
if (property_name_p == NULL)
{
return prop_to_string_result;
return ECMA_VALUE_ERROR;
}
ecma_string_t *property_name_p = ecma_get_string_from_value (prop_to_string_result);
ecma_value_t get_value_result = ecma_op_get_value_object_base (object, property_name_p);
ecma_deref_ecma_string (property_name_p);
@@ -158,22 +163,25 @@ vm_op_set_value (ecma_value_t object, /**< base object */
object = to_object;
}
if (!ecma_is_value_string (property))
ecma_string_t *property_p;
ecma_object_t *object_p = ecma_get_object_from_value (object);
if (!ecma_is_value_prop_name (property))
{
ecma_value_t to_string = ecma_op_to_string (property);
property_p = ecma_op_to_prop_name (property);
ecma_fast_free_value (property);
if (ECMA_IS_VALUE_ERROR (to_string))
if (JERRY_UNLIKELY (property_p == NULL))
{
ecma_free_value (object);
return to_string;
ecma_deref_object (object_p);
return ECMA_VALUE_ERROR;
}
property = to_string;
}
else
{
property_p = ecma_get_prop_name_from_value (property);
}
ecma_object_t *object_p = ecma_get_object_from_value (object);
ecma_string_t *property_p = ecma_get_string_from_value (property);
ecma_value_t completion_value = ECMA_VALUE_EMPTY;
if (!ecma_is_lexical_environment (object_p))
@@ -191,8 +199,8 @@ vm_op_set_value (ecma_value_t object, /**< base object */
is_strict);
}
ecma_free_value (object);
ecma_free_value (property);
ecma_deref_object (object_p);
ecma_deref_ecma_string (property_p);
return completion_value;
} /* vm_op_set_value */
@@ -1608,6 +1616,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
ecma_string_t *index_str_p = ecma_new_ecma_string_from_uint32 (length_num);
ecma_property_value_t *prop_value_p;
prop_value_p = ecma_create_named_data_property (array_obj_p,
index_str_p,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,