Rework Object's [[OwnPropertyKeys]] (#4001)
I've removed the ecma_op_object_get_property_names method, and implemented the following ones: - ecma_op_object_own_property_keys: this is now the internal [[OwnPropertyKeys]] method - ecma_op_object_enumerate: this is used for the for-in iterator - ecma_object_sort_property_names: this is used for sorting the property names of an object - ecma_object_list_lazy_property_names: this is for getting the lazy instantiated properties - ecma_object_prop_name_is_duplicated: this is for checking if a given property is duplicated in an object Also the for-in operation with Proxy object works with this patch, #3992 should be closed JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-conversion.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
@@ -187,6 +188,61 @@ ecma_collection_append (ecma_collection_t *collection_p, /**< value collection *
|
||||
collection_p->item_count += count;
|
||||
} /* ecma_collection_append */
|
||||
|
||||
/**
|
||||
* Helper function to check if a given collection have duplicated properties or not
|
||||
*
|
||||
* @return true - if there are duplicated properties in the collection
|
||||
* false - otherwise
|
||||
*/
|
||||
bool
|
||||
ecma_collection_check_duplicated_entries (ecma_collection_t *collection_p) /**< prop name collection */
|
||||
{
|
||||
ecma_value_t *buffer_p = collection_p->buffer_p;
|
||||
|
||||
for (uint32_t i = 0; i < collection_p->item_count - 1; i++)
|
||||
{
|
||||
ecma_string_t *current_name_p = ecma_get_prop_name_from_value (buffer_p[i]);
|
||||
|
||||
for (uint32_t j = i + 1; j < collection_p->item_count; j++)
|
||||
{
|
||||
if (ecma_compare_ecma_strings (current_name_p, ecma_get_prop_name_from_value (buffer_p[j])))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
} /* ecma_collection_check_duplicated_entries */
|
||||
|
||||
/**
|
||||
* Check the string value existance in the collection.
|
||||
*
|
||||
* Used by:
|
||||
* - ecma_builtin_json_stringify step 4.b.ii.5
|
||||
* - ecma_op_object_enumerate
|
||||
*
|
||||
* @return true, if the string is already in the collection.
|
||||
*/
|
||||
bool
|
||||
ecma_collection_has_string_value (ecma_collection_t *collection_p, /**< collection */
|
||||
ecma_string_t *string_p) /**< string */
|
||||
{
|
||||
ecma_value_t *buffer_p = collection_p->buffer_p;
|
||||
|
||||
for (uint32_t i = 0; i < collection_p->item_count; i++)
|
||||
{
|
||||
ecma_string_t *current_p = ecma_get_string_from_value (buffer_p[i]);
|
||||
|
||||
if (ecma_compare_ecma_strings (current_p, string_p))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
} /* ecma_collection_has_string_value */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
|
||||
Reference in New Issue
Block a user