mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Add property key filters for built-in functions (#4776)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
parent
35058cde31
commit
14ff5bfb52
@ -4607,7 +4607,7 @@ jerry_object_get_property_names (const jerry_value_t obj_val, /**< object */
|
||||
while (true)
|
||||
{
|
||||
/* Step 1. Get Object.[[OwnKeys]] */
|
||||
ecma_collection_t *prop_names_p = ecma_op_object_own_property_keys (obj_iter_p);
|
||||
ecma_collection_t *prop_names_p = ecma_op_object_own_property_keys (obj_iter_p, filter);
|
||||
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
if (prop_names_p == NULL)
|
||||
|
||||
@ -336,7 +336,7 @@ ecma_builtin_object_set_integrity_level (ecma_object_t *obj_p, /**< object */
|
||||
}
|
||||
|
||||
/* 6. */
|
||||
ecma_collection_t *props_p = ecma_op_object_own_property_keys (obj_p);
|
||||
ecma_collection_t *props_p = ecma_op_object_own_property_keys (obj_p, JERRY_PROPERTY_FILTER_ALL);
|
||||
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
if (props_p == NULL)
|
||||
@ -596,7 +596,7 @@ ecma_builtin_object_test_integrity_level (ecma_object_t *obj_p, /**< routine's a
|
||||
ecma_value_t ret_value = ECMA_VALUE_TRUE;
|
||||
|
||||
/* 2. */
|
||||
ecma_collection_t *props_p = ecma_op_object_own_property_keys (obj_p);
|
||||
ecma_collection_t *props_p = ecma_op_object_own_property_keys (obj_p, JERRY_PROPERTY_FILTER_ALL);
|
||||
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
if (props_p == NULL)
|
||||
@ -750,7 +750,7 @@ static ecma_value_t
|
||||
ecma_builtin_object_object_get_own_property_descriptors (ecma_object_t *obj_p) /**< routine's first argument */
|
||||
{
|
||||
/* 2 */
|
||||
ecma_collection_t *prop_names_p = ecma_op_object_own_property_keys (obj_p);
|
||||
ecma_collection_t *prop_names_p = ecma_op_object_own_property_keys (obj_p, JERRY_PROPERTY_FILTER_ALL);
|
||||
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
if (prop_names_p == NULL)
|
||||
@ -831,7 +831,7 @@ ecma_builtin_object_object_define_properties (ecma_object_t *obj_p, /**< routine
|
||||
ecma_object_t *props_p = ecma_get_object_from_value (props);
|
||||
|
||||
/* 3. */
|
||||
ecma_collection_t *prop_names_p = ecma_op_object_own_property_keys (props_p);
|
||||
ecma_collection_t *prop_names_p = ecma_op_object_own_property_keys (props_p, JERRY_PROPERTY_FILTER_ALL);
|
||||
ecma_value_t ret_value = ECMA_VALUE_ERROR;
|
||||
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
@ -1073,7 +1073,7 @@ ecma_builtin_object_object_assign (ecma_object_t *target_p, /**< target object *
|
||||
ecma_object_t *from_obj_p = ecma_get_object_from_value (from_value);
|
||||
|
||||
/* 5.b.iii */
|
||||
ecma_collection_t *props_p = ecma_op_object_own_property_keys (from_obj_p);
|
||||
ecma_collection_t *props_p = ecma_op_object_own_property_keys (from_obj_p, JERRY_PROPERTY_FILTER_ALL);
|
||||
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
if (props_p == NULL)
|
||||
@ -1327,7 +1327,15 @@ ecma_op_object_get_own_property_keys (ecma_value_t this_arg, /**< this argument
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (object);
|
||||
|
||||
/* 2. */
|
||||
ecma_collection_t *props_p = ecma_op_object_own_property_keys (obj_p);
|
||||
jerry_property_filter_t filter = JERRY_PROPERTY_FILTER_EXLCUDE_SYMBOLS;
|
||||
|
||||
if (type == ECMA_OBJECT_ROUTINE_GET_OWN_PROPERTY_SYMBOLS)
|
||||
{
|
||||
filter = (JERRY_PROPERTY_FILTER_EXLCUDE_STRINGS
|
||||
| JERRY_PROPERTY_FILTER_EXLCUDE_INTEGER_INDICES);
|
||||
}
|
||||
|
||||
ecma_collection_t *props_p = ecma_op_object_own_property_keys (obj_p, filter);
|
||||
|
||||
if (props_p == NULL)
|
||||
{
|
||||
@ -1361,7 +1369,7 @@ ecma_op_object_get_own_property_keys (ecma_value_t this_arg, /**< this argument
|
||||
#else /* !JERRY_ESNEXT */
|
||||
JERRY_UNUSED (type);
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (this_arg);
|
||||
ecma_collection_t *props_p = ecma_op_object_own_property_keys (obj_p);
|
||||
ecma_collection_t *props_p = ecma_op_object_own_property_keys (obj_p, JERRY_PROPERTY_FILTER_ALL);
|
||||
return ecma_op_new_array_object_from_collection (props_p, false);
|
||||
#endif /* JERRY_ESNEXT */
|
||||
} /* ecma_op_object_get_own_property_keys */
|
||||
|
||||
@ -163,7 +163,7 @@ ecma_builtin_reflect_dispatch_routine (uint8_t builtin_routine_id, /**< built-in
|
||||
ecma_object_t *target_p = ecma_get_object_from_value (arguments_list[0]);
|
||||
|
||||
/* 2. */
|
||||
ecma_collection_t *prop_names = ecma_op_object_own_property_keys (target_p);
|
||||
ecma_collection_t *prop_names = ecma_op_object_own_property_keys (target_p, JERRY_PROPERTY_FILTER_ALL);
|
||||
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
if (prop_names == NULL)
|
||||
|
||||
@ -1414,11 +1414,17 @@ ecma_builtin_native_handler_list_lazy_property_names (ecma_object_t *object_p, /
|
||||
void
|
||||
ecma_builtin_routine_list_lazy_property_names (ecma_object_t *object_p, /**< a built-in object */
|
||||
ecma_collection_t *prop_names_p, /**< prop name collection */
|
||||
ecma_property_counter_t *prop_counter_p) /**< prop counter */
|
||||
ecma_property_counter_t *prop_counter_p, /**< property counters */
|
||||
jerry_property_filter_t filter) /**< name filters */
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_object_type (object_p) == ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION);
|
||||
JERRY_ASSERT (ecma_builtin_function_is_routine (object_p));
|
||||
|
||||
if (filter & JERRY_PROPERTY_FILTER_EXLCUDE_STRINGS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
@ -1456,7 +1462,8 @@ ecma_builtin_routine_list_lazy_property_names (ecma_object_t *object_p, /**< a b
|
||||
void
|
||||
ecma_builtin_list_lazy_property_names (ecma_object_t *object_p, /**< a built-in object */
|
||||
ecma_collection_t *prop_names_p, /**< prop name collection */
|
||||
ecma_property_counter_t *prop_counter_p) /**< prop counter */
|
||||
ecma_property_counter_t *prop_counter_p, /**< property counters */
|
||||
jerry_property_filter_t filter) /**< name filters */
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_object_type (object_p) != ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION
|
||||
|| !ecma_builtin_function_is_routine (object_p));
|
||||
@ -1477,57 +1484,91 @@ ecma_builtin_list_lazy_property_names (ecma_object_t *object_p, /**< a built-in
|
||||
|
||||
JERRY_ASSERT (builtin_id < ECMA_BUILTIN_ID__COUNT);
|
||||
|
||||
const ecma_builtin_property_descriptor_t *curr_property_p = ecma_builtin_property_list_references[builtin_id];
|
||||
|
||||
uint32_t index = 0;
|
||||
uint8_t bitset = built_in_props_p->u2.instantiated_bitset[0];
|
||||
|
||||
#if JERRY_BUILTIN_REALMS
|
||||
uint8_t *bitset_p = built_in_props_p->u2.instantiated_bitset + 1 + sizeof (ecma_value_t);
|
||||
#else /* !JERRY_BUILTIN_REALMS */
|
||||
uint8_t *bitset_p = built_in_props_p->u2.instantiated_bitset + 1;
|
||||
#endif /* JERRY_BUILTIN_REALMS */
|
||||
|
||||
while (curr_property_p->magic_string_id != LIT_MAGIC_STRING__COUNT)
|
||||
{
|
||||
if (index == 8)
|
||||
{
|
||||
bitset = *bitset_p++;
|
||||
index = 0;
|
||||
}
|
||||
|
||||
uint32_t bit_for_index = (uint32_t) 1u << index;
|
||||
|
||||
if (curr_property_p->magic_string_id > LIT_NON_INTERNAL_MAGIC_STRING__COUNT)
|
||||
{
|
||||
#if JERRY_ESNEXT
|
||||
if (LIT_IS_GLOBAL_SYMBOL (curr_property_p->magic_string_id))
|
||||
{
|
||||
ecma_string_t *name_p = ecma_op_get_global_symbol (curr_property_p->magic_string_id);
|
||||
uint8_t *symbol_bitset_p = bitset_p;
|
||||
bool has_symbol = true;
|
||||
#endif /* JERRY_BUILTIN_REALMS */
|
||||
|
||||
if (!(bitset & bit_for_index))
|
||||
if (!(filter & JERRY_PROPERTY_FILTER_EXLCUDE_STRINGS))
|
||||
{
|
||||
const ecma_builtin_property_descriptor_t *curr_property_p = ecma_builtin_property_list_references[builtin_id];
|
||||
uint8_t bitset = built_in_props_p->u2.instantiated_bitset[0];
|
||||
uint32_t index = 0;
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
has_symbol = false;
|
||||
#endif /* JERRY_BUILTIN_REALMS */
|
||||
|
||||
while (curr_property_p->magic_string_id != LIT_MAGIC_STRING__COUNT)
|
||||
{
|
||||
if (index == 8)
|
||||
{
|
||||
bitset = *bitset_p++;
|
||||
index = 0;
|
||||
}
|
||||
|
||||
uint32_t bit_for_index = (uint32_t) 1u << index;
|
||||
|
||||
if (!(bitset & bit_for_index))
|
||||
{
|
||||
#if JERRY_ESNEXT
|
||||
if (JERRY_LIKELY (curr_property_p->magic_string_id < LIT_NON_INTERNAL_MAGIC_STRING__COUNT))
|
||||
{
|
||||
ecma_value_t name = ecma_make_symbol_value (name_p);
|
||||
#endif /* JERRY_ESNEXT */
|
||||
ecma_value_t name = ecma_make_magic_string_value ((lit_magic_string_id_t) curr_property_p->magic_string_id);
|
||||
ecma_collection_push_back (prop_names_p, name);
|
||||
prop_counter_p->symbol_named_props++;
|
||||
prop_counter_p->string_named_props++;
|
||||
#if JERRY_ESNEXT
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_deref_ecma_string (name_p);
|
||||
JERRY_ASSERT (LIT_IS_GLOBAL_SYMBOL (curr_property_p->magic_string_id));
|
||||
has_symbol = true;
|
||||
}
|
||||
}
|
||||
#endif /* JERRY_ESNEXT */
|
||||
}
|
||||
else if (!(bitset & bit_for_index))
|
||||
{
|
||||
ecma_value_t name = ecma_make_magic_string_value ((lit_magic_string_id_t) curr_property_p->magic_string_id);
|
||||
ecma_collection_push_back (prop_names_p, name);
|
||||
prop_counter_p->string_named_props++;
|
||||
}
|
||||
}
|
||||
|
||||
curr_property_p++;
|
||||
index++;
|
||||
curr_property_p++;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
if (has_symbol && !(filter & JERRY_PROPERTY_FILTER_EXLCUDE_SYMBOLS))
|
||||
{
|
||||
const ecma_builtin_property_descriptor_t *curr_property_p = ecma_builtin_property_list_references[builtin_id];
|
||||
uint8_t bitset = built_in_props_p->u2.instantiated_bitset[0];
|
||||
uint32_t index = 0;
|
||||
|
||||
while (curr_property_p->magic_string_id != LIT_MAGIC_STRING__COUNT)
|
||||
{
|
||||
if (index == 8)
|
||||
{
|
||||
bitset = *symbol_bitset_p++;
|
||||
index = 0;
|
||||
}
|
||||
|
||||
uint32_t bit_for_index = (uint32_t) 1u << index;
|
||||
|
||||
if (curr_property_p->magic_string_id > LIT_NON_INTERNAL_MAGIC_STRING__COUNT
|
||||
&& !(bitset & bit_for_index))
|
||||
{
|
||||
ecma_string_t *name_p = ecma_op_get_global_symbol (curr_property_p->magic_string_id);
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_symbol_value (name_p));
|
||||
prop_counter_p->symbol_named_props++;
|
||||
}
|
||||
|
||||
curr_property_p++;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
#endif /* JERRY_ESNEXT */
|
||||
} /* ecma_builtin_list_lazy_property_names */
|
||||
|
||||
/**
|
||||
|
||||
@ -138,13 +138,13 @@ ecma_builtin_routine_delete_built_in_property (ecma_object_t *object_p, ecma_str
|
||||
void
|
||||
ecma_builtin_delete_built_in_property (ecma_object_t *object_p, ecma_string_t *property_name_p);
|
||||
void
|
||||
ecma_builtin_routine_list_lazy_property_names (ecma_object_t *object_p,
|
||||
ecma_collection_t *prop_names_p,
|
||||
ecma_property_counter_t *prop_counter_p);
|
||||
ecma_builtin_routine_list_lazy_property_names (ecma_object_t *object_p, ecma_collection_t *prop_names_p,
|
||||
ecma_property_counter_t *prop_counter_p,
|
||||
jerry_property_filter_t filter);
|
||||
void
|
||||
ecma_builtin_list_lazy_property_names (ecma_object_t *object_p,
|
||||
ecma_collection_t *prop_names_p,
|
||||
ecma_property_counter_t *prop_counter_p);
|
||||
ecma_builtin_list_lazy_property_names (ecma_object_t *object_p, ecma_collection_t *prop_names_p,
|
||||
ecma_property_counter_t *prop_counter_p,
|
||||
jerry_property_filter_t filter);
|
||||
bool
|
||||
ecma_builtin_is_global (ecma_object_t *object_p);
|
||||
ecma_object_t *
|
||||
|
||||
@ -401,7 +401,8 @@ ecma_op_arguments_delete_built_in_property (ecma_object_t *object_p, /**< the ob
|
||||
void
|
||||
ecma_op_arguments_object_list_lazy_property_names (ecma_object_t *obj_p, /**< arguments object */
|
||||
ecma_collection_t *prop_names_p, /**< prop name collection */
|
||||
ecma_property_counter_t *prop_counter_p) /**< property counters */
|
||||
ecma_property_counter_t *prop_counter_p, /**< property counters */
|
||||
jerry_property_filter_t filter) /**< property name filter options */
|
||||
{
|
||||
JERRY_ASSERT (ecma_object_class_is (obj_p, ECMA_OBJECT_CLASS_ARGUMENTS));
|
||||
|
||||
@ -410,45 +411,52 @@ ecma_op_arguments_object_list_lazy_property_names (ecma_object_t *obj_p, /**< ar
|
||||
uint32_t arguments_number = arguments_p->header.u.cls.u3.arguments_number;
|
||||
uint8_t flags = arguments_p->header.u.cls.u1.arguments_flags;
|
||||
|
||||
ecma_value_t *argv_p = (ecma_value_t *) (arguments_p + 1);
|
||||
|
||||
if (flags & ECMA_ARGUMENTS_OBJECT_MAPPED)
|
||||
if (!(filter & JERRY_PROPERTY_FILTER_EXLCUDE_INTEGER_INDICES))
|
||||
{
|
||||
argv_p = (ecma_value_t *) (((ecma_mapped_arguments_t *) obj_p) + 1);
|
||||
}
|
||||
ecma_value_t *argv_p = (ecma_value_t *) (arguments_p + 1);
|
||||
|
||||
for (uint32_t index = 0; index < arguments_number; index++)
|
||||
{
|
||||
if (!ecma_is_value_empty (argv_p[index]))
|
||||
if (flags & ECMA_ARGUMENTS_OBJECT_MAPPED)
|
||||
{
|
||||
ecma_string_t *index_string_p = ecma_new_ecma_string_from_uint32 (index);
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_string_value (index_string_p));
|
||||
prop_counter_p->array_index_named_props++;
|
||||
argv_p = (ecma_value_t *) (((ecma_mapped_arguments_t *) obj_p) + 1);
|
||||
}
|
||||
|
||||
for (uint32_t index = 0; index < arguments_number; index++)
|
||||
{
|
||||
if (!ecma_is_value_empty (argv_p[index]))
|
||||
{
|
||||
ecma_string_t *index_string_p = ecma_new_ecma_string_from_uint32 (index);
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_string_value (index_string_p));
|
||||
prop_counter_p->array_index_named_props++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!(flags & ECMA_ARGUMENTS_OBJECT_LENGTH_INITIALIZED))
|
||||
if (!(filter & JERRY_PROPERTY_FILTER_EXLCUDE_STRINGS))
|
||||
{
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH));
|
||||
prop_counter_p->string_named_props++;
|
||||
}
|
||||
if (!(flags & ECMA_ARGUMENTS_OBJECT_LENGTH_INITIALIZED))
|
||||
{
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH));
|
||||
prop_counter_p->string_named_props++;
|
||||
}
|
||||
|
||||
if (!(flags & ECMA_ARGUMENTS_OBJECT_CALLEE_INITIALIZED))
|
||||
{
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_CALLEE));
|
||||
prop_counter_p->string_named_props++;
|
||||
}
|
||||
if (!(flags & ECMA_ARGUMENTS_OBJECT_CALLEE_INITIALIZED))
|
||||
{
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_CALLEE));
|
||||
prop_counter_p->string_named_props++;
|
||||
}
|
||||
|
||||
#if !JERRY_ESNEXT
|
||||
if (!(flags & ECMA_ARGUMENTS_OBJECT_MAPPED))
|
||||
{
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_CALLER));
|
||||
prop_counter_p->string_named_props++;
|
||||
}
|
||||
if (!(flags & ECMA_ARGUMENTS_OBJECT_MAPPED))
|
||||
{
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_CALLER));
|
||||
prop_counter_p->string_named_props++;
|
||||
}
|
||||
#endif /* !JERRY_ESNEXT */
|
||||
}
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
if (!(flags & ECMA_ARGUMENTS_OBJECT_ITERATOR_INITIALIZED))
|
||||
if (!(filter & JERRY_PROPERTY_FILTER_EXLCUDE_SYMBOLS)
|
||||
&& !(flags & ECMA_ARGUMENTS_OBJECT_ITERATOR_INITIALIZED))
|
||||
{
|
||||
ecma_string_t *symbol_p = ecma_op_get_global_symbol (LIT_GLOBAL_SYMBOL_ITERATOR);
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_symbol_value (symbol_p));
|
||||
|
||||
@ -36,7 +36,8 @@ ecma_op_arguments_delete_built_in_property (ecma_object_t *object_p, ecma_string
|
||||
|
||||
void
|
||||
ecma_op_arguments_object_list_lazy_property_names (ecma_object_t *obj_p, ecma_collection_t *prop_names_p,
|
||||
ecma_property_counter_t *prop_counter_p);
|
||||
ecma_property_counter_t *prop_counter_p,
|
||||
jerry_property_filter_t filter);
|
||||
|
||||
ecma_string_t *
|
||||
ecma_op_arguments_object_get_formal_parameter (ecma_mapped_arguments_t *mapped_arguments_p,
|
||||
|
||||
@ -649,32 +649,40 @@ ecma_fast_array_set_length (ecma_object_t *object_p, /**< fast access mode array
|
||||
* @return collection of strings - property names
|
||||
*/
|
||||
ecma_collection_t *
|
||||
ecma_fast_array_object_own_property_keys (ecma_object_t *object_p) /**< fast access mode array object */
|
||||
ecma_fast_array_object_own_property_keys (ecma_object_t *object_p, /**< fast access mode array object */
|
||||
jerry_property_filter_t filter) /**< property name filter options */
|
||||
{
|
||||
JERRY_ASSERT (ecma_op_object_is_fast_array (object_p));
|
||||
|
||||
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) object_p;
|
||||
ecma_collection_t *ret_p = ecma_new_collection ();
|
||||
uint32_t length = ext_obj_p->u.array.length;
|
||||
|
||||
if (length != 0)
|
||||
if (!(filter & JERRY_PROPERTY_FILTER_EXLCUDE_INTEGER_INDICES))
|
||||
{
|
||||
ecma_value_t *values_p = ECMA_GET_NON_NULL_POINTER (ecma_value_t, object_p->u1.property_list_cp);
|
||||
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) object_p;
|
||||
uint32_t length = ext_obj_p->u.array.length;
|
||||
|
||||
for (uint32_t i = 0; i < length; i++)
|
||||
if (length != 0)
|
||||
{
|
||||
if (ecma_is_value_array_hole (values_p[i]))
|
||||
ecma_value_t *values_p = ECMA_GET_NON_NULL_POINTER (ecma_value_t, object_p->u1.property_list_cp);
|
||||
|
||||
for (uint32_t i = 0; i < length; i++)
|
||||
{
|
||||
continue;
|
||||
if (ecma_is_value_array_hole (values_p[i]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ecma_string_t *index_str_p = ecma_new_ecma_string_from_uint32 (i);
|
||||
|
||||
ecma_collection_push_back (ret_p, ecma_make_string_value (index_str_p));
|
||||
}
|
||||
|
||||
ecma_string_t *index_str_p = ecma_new_ecma_string_from_uint32 (i);
|
||||
|
||||
ecma_collection_push_back (ret_p, ecma_make_string_value (index_str_p));
|
||||
}
|
||||
}
|
||||
|
||||
ecma_collection_push_back (ret_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH));
|
||||
if (!(filter & JERRY_PROPERTY_FILTER_EXLCUDE_STRINGS))
|
||||
{
|
||||
ecma_collection_push_back (ret_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH));
|
||||
}
|
||||
|
||||
return ret_p;
|
||||
} /* ecma_fast_array_object_own_property_keys */
|
||||
|
||||
@ -96,7 +96,7 @@ uint32_t
|
||||
ecma_delete_fast_array_properties (ecma_object_t *object_p, uint32_t new_length);
|
||||
|
||||
ecma_collection_t *
|
||||
ecma_fast_array_object_own_property_keys (ecma_object_t *object_p);
|
||||
ecma_fast_array_object_own_property_keys (ecma_object_t *object_p, jerry_property_filter_t filter);
|
||||
|
||||
void
|
||||
ecma_fast_array_convert_to_normal (ecma_object_t *object_p);
|
||||
|
||||
@ -2162,8 +2162,14 @@ ecma_op_bound_function_delete_built_in_property (ecma_object_t *object_p, /**< o
|
||||
void
|
||||
ecma_op_function_list_lazy_property_names (ecma_object_t *object_p, /**< functionobject */
|
||||
ecma_collection_t *prop_names_p, /**< prop name collection */
|
||||
ecma_property_counter_t *prop_counter_p) /**< prop counter */
|
||||
ecma_property_counter_t *prop_counter_p, /**< property counters */
|
||||
jerry_property_filter_t filter) /**< property name filter options */
|
||||
{
|
||||
if (filter & JERRY_PROPERTY_FILTER_EXLCUDE_STRINGS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const ecma_compiled_code_t *bytecode_data_p;
|
||||
bytecode_data_p = ecma_op_function_get_compiled_code ((ecma_extended_object_t *) object_p);
|
||||
|
||||
@ -2236,21 +2242,20 @@ ecma_op_function_list_lazy_property_names (ecma_object_t *object_p, /**< functio
|
||||
void
|
||||
ecma_op_external_function_list_lazy_property_names (ecma_object_t *object_p, /**< function object */
|
||||
ecma_collection_t *prop_names_p, /**< prop name collection */
|
||||
ecma_property_counter_t *prop_counter_p) /**< prop counter */
|
||||
ecma_property_counter_t *prop_counter_p, /**< property counters */
|
||||
jerry_property_filter_t filter) /**< property name
|
||||
* filter options */
|
||||
{
|
||||
#if !JERRY_ESNEXT
|
||||
JERRY_UNUSED (object_p);
|
||||
#else /* JERRY_ESNEXT */
|
||||
/* TODO: implicit class constructors need rework, and this code should be updated afterwards. */
|
||||
ecma_property_t *property_p = ecma_find_named_property (object_p, ecma_get_magic_string (LIT_MAGIC_STRING_PROTOTYPE));
|
||||
|
||||
if (property_p == NULL || (*property_p & ECMA_PROPERTY_FLAG_BUILT_IN))
|
||||
#endif /* !JERRY_ESNEXT */
|
||||
if (filter & JERRY_PROPERTY_FILTER_EXLCUDE_STRINGS)
|
||||
{
|
||||
/* 'prototype' property is non-enumerable (ECMA-262 v5, 13.2.18) */
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_PROTOTYPE));
|
||||
prop_counter_p->string_named_props++;
|
||||
return;
|
||||
}
|
||||
|
||||
/* 'prototype' property is non-enumerable (ECMA-262 v5, 13.2.18) */
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_PROTOTYPE));
|
||||
prop_counter_p->string_named_props++;
|
||||
} /* ecma_op_external_function_list_lazy_property_names */
|
||||
|
||||
/**
|
||||
@ -2263,8 +2268,14 @@ ecma_op_external_function_list_lazy_property_names (ecma_object_t *object_p, /**
|
||||
void
|
||||
ecma_op_bound_function_list_lazy_property_names (ecma_object_t *object_p, /**< bound function object*/
|
||||
ecma_collection_t *prop_names_p, /**< prop name collection */
|
||||
ecma_property_counter_t *prop_counter_p) /**< prop counter */
|
||||
ecma_property_counter_t *prop_counter_p, /**< property counters */
|
||||
jerry_property_filter_t filter) /**< property name filter options */
|
||||
{
|
||||
if (filter & JERRY_PROPERTY_FILTER_EXLCUDE_STRINGS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
/* Unintialized 'length' property is non-enumerable (ECMA-262 v6, 19.2.4.1) */
|
||||
ecma_bound_function_t *bound_func_p = (ecma_bound_function_t *) object_p;
|
||||
|
||||
@ -117,19 +117,19 @@ ecma_op_bound_function_delete_built_in_property (ecma_object_t *object_p, ecma_s
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
void
|
||||
ecma_op_function_list_lazy_property_names (ecma_object_t *object_p,
|
||||
ecma_collection_t *prop_names_p,
|
||||
ecma_property_counter_t *prop_counter_p);
|
||||
ecma_op_function_list_lazy_property_names (ecma_object_t *object_p, ecma_collection_t *prop_names_p,
|
||||
ecma_property_counter_t *prop_counter_p,
|
||||
jerry_property_filter_t filter);
|
||||
|
||||
void
|
||||
ecma_op_external_function_list_lazy_property_names (ecma_object_t *object_p,
|
||||
ecma_collection_t *prop_names_p,
|
||||
ecma_property_counter_t *prop_counter_p);
|
||||
ecma_op_external_function_list_lazy_property_names (ecma_object_t *object_p, ecma_collection_t *prop_names_p,
|
||||
ecma_property_counter_t *prop_counter_p,
|
||||
jerry_property_filter_t filter);
|
||||
|
||||
void
|
||||
ecma_op_bound_function_list_lazy_property_names (ecma_object_t *object_p,
|
||||
ecma_collection_t *prop_names_p,
|
||||
ecma_property_counter_t *prop_counter_p);
|
||||
ecma_op_bound_function_list_lazy_property_names (ecma_object_t *object_p, ecma_collection_t *prop_names_p,
|
||||
ecma_property_counter_t *prop_counter_p,
|
||||
jerry_property_filter_t filter);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@ -2180,7 +2180,7 @@ ecma_op_object_get_enumerable_property_names (ecma_object_t *obj_p, /**< routine
|
||||
ecma_enumerable_property_names_options_t option) /**< listing option */
|
||||
{
|
||||
/* 2. */
|
||||
ecma_collection_t *prop_names_p = ecma_op_object_own_property_keys (obj_p);
|
||||
ecma_collection_t *prop_names_p = ecma_op_object_own_property_keys (obj_p, JERRY_PROPERTY_FILTER_EXLCUDE_SYMBOLS);
|
||||
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
if (JERRY_UNLIKELY (prop_names_p == NULL))
|
||||
@ -2278,7 +2278,8 @@ ecma_op_object_get_enumerable_property_names (ecma_object_t *obj_p, /**< routine
|
||||
static void
|
||||
ecma_object_list_lazy_property_names (ecma_object_t *obj_p, /**< object */
|
||||
ecma_collection_t *prop_names_p, /**< prop name collection */
|
||||
ecma_property_counter_t *prop_counter_p) /**< prop counter */
|
||||
ecma_property_counter_t *prop_counter_p, /**< property counters */
|
||||
jerry_property_filter_t filter) /**< property name filter options */
|
||||
{
|
||||
switch (ecma_get_object_type (obj_p))
|
||||
{
|
||||
@ -2286,7 +2287,7 @@ ecma_object_list_lazy_property_names (ecma_object_t *obj_p, /**< object */
|
||||
{
|
||||
if (ecma_builtin_function_is_routine (obj_p))
|
||||
{
|
||||
ecma_builtin_routine_list_lazy_property_names (obj_p, prop_names_p, prop_counter_p);
|
||||
ecma_builtin_routine_list_lazy_property_names (obj_p, prop_names_p, prop_counter_p, filter);
|
||||
break;
|
||||
}
|
||||
/* FALLTHRU */
|
||||
@ -2295,7 +2296,7 @@ ecma_object_list_lazy_property_names (ecma_object_t *obj_p, /**< object */
|
||||
case ECMA_OBJECT_TYPE_BUILT_IN_CLASS:
|
||||
case ECMA_OBJECT_TYPE_BUILT_IN_ARRAY:
|
||||
{
|
||||
ecma_builtin_list_lazy_property_names (obj_p, prop_names_p, prop_counter_p);
|
||||
ecma_builtin_list_lazy_property_names (obj_p, prop_names_p, prop_counter_p, filter);
|
||||
break;
|
||||
}
|
||||
case ECMA_OBJECT_TYPE_CLASS:
|
||||
@ -2306,19 +2307,19 @@ ecma_object_list_lazy_property_names (ecma_object_t *obj_p, /**< object */
|
||||
{
|
||||
case ECMA_OBJECT_CLASS_STRING:
|
||||
{
|
||||
ecma_op_string_list_lazy_property_names (obj_p, prop_names_p, prop_counter_p);
|
||||
ecma_op_string_list_lazy_property_names (obj_p, prop_names_p, prop_counter_p, filter);
|
||||
break;
|
||||
}
|
||||
case ECMA_OBJECT_CLASS_ARGUMENTS:
|
||||
{
|
||||
ecma_op_arguments_object_list_lazy_property_names (obj_p, prop_names_p, prop_counter_p);
|
||||
ecma_op_arguments_object_list_lazy_property_names (obj_p, prop_names_p, prop_counter_p, filter);
|
||||
break;
|
||||
}
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
/* ES2015 9.4.5.1 */
|
||||
case ECMA_OBJECT_CLASS_TYPEDARRAY:
|
||||
{
|
||||
ecma_op_typedarray_list_lazy_property_names (obj_p, prop_names_p, prop_counter_p);
|
||||
ecma_op_typedarray_list_lazy_property_names (obj_p, prop_names_p, prop_counter_p, filter);
|
||||
break;
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
@ -2327,23 +2328,26 @@ ecma_object_list_lazy_property_names (ecma_object_t *obj_p, /**< object */
|
||||
}
|
||||
case ECMA_OBJECT_TYPE_FUNCTION:
|
||||
{
|
||||
ecma_op_function_list_lazy_property_names (obj_p, prop_names_p, prop_counter_p);
|
||||
ecma_op_function_list_lazy_property_names (obj_p, prop_names_p, prop_counter_p, filter);
|
||||
break;
|
||||
}
|
||||
case ECMA_OBJECT_TYPE_NATIVE_FUNCTION:
|
||||
{
|
||||
ecma_op_external_function_list_lazy_property_names (obj_p, prop_names_p, prop_counter_p);
|
||||
ecma_op_external_function_list_lazy_property_names (obj_p, prop_names_p, prop_counter_p, filter);
|
||||
break;
|
||||
}
|
||||
case ECMA_OBJECT_TYPE_BOUND_FUNCTION:
|
||||
{
|
||||
ecma_op_bound_function_list_lazy_property_names (obj_p, prop_names_p, prop_counter_p);
|
||||
ecma_op_bound_function_list_lazy_property_names (obj_p, prop_names_p, prop_counter_p, filter);
|
||||
break;
|
||||
}
|
||||
case ECMA_OBJECT_TYPE_ARRAY:
|
||||
{
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH));
|
||||
prop_counter_p->string_named_props++;
|
||||
if (!(filter & JERRY_PROPERTY_FILTER_EXLCUDE_STRINGS))
|
||||
{
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH));
|
||||
prop_counter_p->string_named_props++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -2486,7 +2490,8 @@ ecma_object_sort_property_names (ecma_collection_t *prop_names_p, /**< prop name
|
||||
* collection of property names - otherwise
|
||||
*/
|
||||
ecma_collection_t *
|
||||
ecma_op_object_own_property_keys (ecma_object_t *obj_p) /**< object */
|
||||
ecma_op_object_own_property_keys (ecma_object_t *obj_p, /**< object */
|
||||
jerry_property_filter_t filter) /**< property name filter options */
|
||||
{
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
if (ECMA_OBJECT_IS_PROXY (obj_p))
|
||||
@ -2497,13 +2502,13 @@ ecma_op_object_own_property_keys (ecma_object_t *obj_p) /**< object */
|
||||
|
||||
if (ecma_op_object_is_fast_array (obj_p))
|
||||
{
|
||||
return ecma_fast_array_object_own_property_keys (obj_p);
|
||||
return ecma_fast_array_object_own_property_keys (obj_p, filter);
|
||||
}
|
||||
|
||||
ecma_collection_t *prop_names_p = ecma_new_collection ();
|
||||
ecma_property_counter_t prop_counter = {0, 0, 0, 0, 0};
|
||||
|
||||
ecma_object_list_lazy_property_names (obj_p, prop_names_p, &prop_counter);
|
||||
ecma_object_list_lazy_property_names (obj_p, prop_names_p, &prop_counter, filter);
|
||||
|
||||
prop_counter.lazy_string_named_props = prop_names_p->item_count - prop_counter.symbol_named_props;
|
||||
prop_counter.lazy_symbol_named_props = prop_counter.symbol_named_props;
|
||||
@ -2595,7 +2600,7 @@ ecma_op_object_enumerate (ecma_object_t *obj_p) /**< object */
|
||||
|
||||
while (true)
|
||||
{
|
||||
ecma_collection_t *keys = ecma_op_object_own_property_keys (obj_p);
|
||||
ecma_collection_t *keys = ecma_op_object_own_property_keys (obj_p, JERRY_PROPERTY_FILTER_EXLCUDE_SYMBOLS);
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
if (JERRY_UNLIKELY (keys == NULL))
|
||||
|
||||
@ -97,7 +97,7 @@ ecma_object_t *ecma_op_object_get_prototype_of (ecma_object_t *obj_p);
|
||||
ecma_value_t ecma_op_object_is_prototype_of (ecma_object_t *base_p, ecma_object_t *target_p);
|
||||
ecma_collection_t * ecma_op_object_get_enumerable_property_names (ecma_object_t *obj_p,
|
||||
ecma_enumerable_property_names_options_t option);
|
||||
ecma_collection_t *ecma_op_object_own_property_keys (ecma_object_t *obj_p);
|
||||
ecma_collection_t *ecma_op_object_own_property_keys (ecma_object_t *obj_p, jerry_property_filter_t filter);
|
||||
ecma_collection_t *ecma_op_object_enumerate (ecma_object_t *obj_p);
|
||||
|
||||
lit_magic_string_id_t ecma_object_get_class_name (ecma_object_t *obj_p);
|
||||
|
||||
@ -1628,7 +1628,7 @@ ecma_proxy_object_own_property_keys (ecma_object_t *obj_p) /**< proxy object */
|
||||
/* 6. */
|
||||
if (ecma_is_value_undefined (trap))
|
||||
{
|
||||
ecma_collection_t *result = ecma_op_object_own_property_keys (target_obj_p);
|
||||
ecma_collection_t *result = ecma_op_object_own_property_keys (target_obj_p, JERRY_PROPERTY_FILTER_ALL);
|
||||
JERRY_BLOCK_TAIL_CALL_OPTIMIZATION ();
|
||||
return result;
|
||||
}
|
||||
@ -1674,7 +1674,7 @@ ecma_proxy_object_own_property_keys (ecma_object_t *obj_p) /**< proxy object */
|
||||
}
|
||||
|
||||
/* 11. */
|
||||
ecma_collection_t *target_keys = ecma_op_object_own_property_keys (target_obj_p);
|
||||
ecma_collection_t *target_keys = ecma_op_object_own_property_keys (target_obj_p, JERRY_PROPERTY_FILTER_ALL);
|
||||
|
||||
if (target_keys == NULL)
|
||||
{
|
||||
|
||||
@ -105,29 +105,36 @@ ecma_op_create_string_object (const ecma_value_t *arguments_list_p, /**< list of
|
||||
void
|
||||
ecma_op_string_list_lazy_property_names (ecma_object_t *obj_p, /**< a String object */
|
||||
ecma_collection_t *prop_names_p, /**< prop name collection */
|
||||
ecma_property_counter_t *prop_counter_p) /**< prop counter */
|
||||
ecma_property_counter_t *prop_counter_p, /**< property counters */
|
||||
jerry_property_filter_t filter) /**< property name filter options */
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_object_base_type (obj_p) == ECMA_OBJECT_BASE_TYPE_CLASS);
|
||||
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
JERRY_ASSERT (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_STRING);
|
||||
|
||||
ecma_string_t *prim_value_str_p = ecma_get_string_from_value (ext_object_p->u.cls.u3.value);
|
||||
|
||||
lit_utf8_size_t length = ecma_string_get_length (prim_value_str_p);
|
||||
|
||||
for (lit_utf8_size_t i = 0; i < length; i++)
|
||||
if (!(filter & JERRY_PROPERTY_FILTER_EXLCUDE_INTEGER_INDICES))
|
||||
{
|
||||
ecma_string_t *name_p = ecma_new_ecma_string_from_uint32 (i);
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
JERRY_ASSERT (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_STRING);
|
||||
|
||||
/* the properties are enumerable (ECMA-262 v5, 15.5.5.2.9) */
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_string_value (name_p));
|
||||
ecma_string_t *prim_value_str_p = ecma_get_string_from_value (ext_object_p->u.cls.u3.value);
|
||||
|
||||
lit_utf8_size_t length = ecma_string_get_length (prim_value_str_p);
|
||||
|
||||
for (lit_utf8_size_t i = 0; i < length; i++)
|
||||
{
|
||||
ecma_string_t *name_p = ecma_new_ecma_string_from_uint32 (i);
|
||||
|
||||
/* the properties are enumerable (ECMA-262 v5, 15.5.5.2.9) */
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_string_value (name_p));
|
||||
}
|
||||
|
||||
prop_counter_p->array_index_named_props += length;
|
||||
}
|
||||
|
||||
prop_counter_p->array_index_named_props += length;
|
||||
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH));
|
||||
prop_counter_p->string_named_props++;
|
||||
if (!(filter & JERRY_PROPERTY_FILTER_EXLCUDE_STRINGS))
|
||||
{
|
||||
ecma_collection_push_back (prop_names_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH));
|
||||
prop_counter_p->string_named_props++;
|
||||
}
|
||||
} /* ecma_op_string_list_lazy_property_names */
|
||||
|
||||
/**
|
||||
|
||||
@ -29,9 +29,9 @@ ecma_value_t
|
||||
ecma_op_create_string_object (const ecma_value_t *arguments_list_p, uint32_t arguments_list_len);
|
||||
|
||||
void
|
||||
ecma_op_string_list_lazy_property_names (ecma_object_t *obj_p,
|
||||
ecma_collection_t *prop_names_p,
|
||||
ecma_property_counter_t *prop_counter_p);
|
||||
ecma_op_string_list_lazy_property_names (ecma_object_t *obj_p, ecma_collection_t *prop_names_p,
|
||||
ecma_property_counter_t *prop_counter_p,
|
||||
jerry_property_filter_t filter);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@ -1827,10 +1827,16 @@ ecma_is_typedarray (ecma_value_t value) /**< the target need to be checked */
|
||||
void
|
||||
ecma_op_typedarray_list_lazy_property_names (ecma_object_t *obj_p, /**< a TypedArray object */
|
||||
ecma_collection_t *prop_names_p, /**< prop name collection */
|
||||
ecma_property_counter_t *prop_counter_p) /**< prop counter */
|
||||
ecma_property_counter_t *prop_counter_p, /**< property counters */
|
||||
jerry_property_filter_t filter) /**< property name filter options */
|
||||
{
|
||||
JERRY_ASSERT (ecma_object_is_typedarray (obj_p));
|
||||
|
||||
if (filter & JERRY_PROPERTY_FILTER_EXLCUDE_INTEGER_INDICES)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t array_length = ecma_typedarray_get_length (obj_p);
|
||||
|
||||
for (uint32_t i = 0; i < array_length; i++)
|
||||
|
||||
@ -62,9 +62,9 @@ ecma_typedarray_iterators_helper (ecma_value_t this_arg, ecma_iterator_kind_t ki
|
||||
|
||||
bool ecma_object_is_typedarray (ecma_object_t *obj_p);
|
||||
bool ecma_is_typedarray (ecma_value_t target);
|
||||
void ecma_op_typedarray_list_lazy_property_names (ecma_object_t *obj_p,
|
||||
ecma_collection_t *prop_names_p,
|
||||
ecma_property_counter_t *prop_counter_p);
|
||||
void ecma_op_typedarray_list_lazy_property_names (ecma_object_t *obj_p, ecma_collection_t *prop_names_p,
|
||||
ecma_property_counter_t *prop_counter_p,
|
||||
jerry_property_filter_t filter);
|
||||
ecma_value_t ecma_op_typedarray_define_own_property (ecma_object_t *obj_p,
|
||||
ecma_string_t *prop_name_p,
|
||||
const ecma_property_descriptor_t *property_desc_p);
|
||||
|
||||
@ -1558,7 +1558,7 @@ opfunc_copy_data_properties (ecma_value_t target_object, /**< target object */
|
||||
}
|
||||
|
||||
ecma_object_t *source_object_p = ecma_get_object_from_value (source_object);
|
||||
ecma_collection_t *names_p = ecma_op_object_own_property_keys (source_object_p);
|
||||
ecma_collection_t *names_p = ecma_op_object_own_property_keys (source_object_p, JERRY_PROPERTY_FILTER_ALL);
|
||||
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
if (names_p == NULL)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user