Fix attributes of length property for builtin functions (#3689)
fix length property of builtin functions to be configurable (ECMA-262 v6, 19.2.4.1) JerryScript-DCO-1.0-Signed-off-by: HyukWoo Park hyukwoo.park@samsung.com
This commit is contained in:
@@ -650,17 +650,32 @@ ecma_builtin_try_to_instantiate_property (ecma_object_t *object_p, /**< object *
|
||||
{
|
||||
/*
|
||||
* Lazy instantiation of 'length' property
|
||||
*
|
||||
* Note:
|
||||
* We don't need to mark that the property was already lazy instantiated,
|
||||
* as it is non-configurable and so can't be deleted
|
||||
*/
|
||||
|
||||
ecma_property_t *len_prop_p;
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) object_p;
|
||||
uint32_t *bitset_p = ext_func_p->u.built_in.instantiated_bitset;
|
||||
if (*bitset_p & (1u << 0))
|
||||
{
|
||||
/* length property was already instantiated */
|
||||
return NULL;
|
||||
}
|
||||
/* We mark that the property was lazily instantiated,
|
||||
* as it is configurable and so can be deleted (ECMA-262 v6, 19.2.4.1) */
|
||||
*bitset_p |= (1u << 0);
|
||||
ecma_property_value_t *len_prop_value_p = ecma_create_named_data_property (object_p,
|
||||
string_p,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE,
|
||||
&len_prop_p);
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
/* We don't need to mark that the property was already lazy instantiated,
|
||||
* as it is non-configurable and so can't be deleted (ECMA-262 v5, 13.2.5) */
|
||||
ecma_property_value_t *len_prop_value_p = ecma_create_named_data_property (object_p,
|
||||
string_p,
|
||||
ECMA_PROPERTY_FIXED,
|
||||
&len_prop_p);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
@@ -949,8 +964,17 @@ ecma_builtin_list_lazy_property_names (ecma_object_t *object_p, /**< a built-in
|
||||
|
||||
if (!is_array_indices_only)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) object_p;
|
||||
if (!(ext_func_p->u.built_in.instantiated_bitset[0] & (1u << 0)))
|
||||
{
|
||||
/* Unintialized 'length' property is non-enumerable (ECMA-262 v6, 19.2.4.1) */
|
||||
ecma_collection_push_back (for_non_enumerable_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH));
|
||||
}
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
/* 'length' property is non-enumerable (ECMA-262 v5, 15) */
|
||||
ecma_collection_push_back (for_non_enumerable_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH));
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user