Add custom dispatcher to Set/Map/WeakSet/WeakMap (#3790)
JerryScript-DCO-1.0-Signed-off-by: Daniella Barsony bella@inf.u-szeged.hu
This commit is contained in:
@@ -20,6 +20,10 @@
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
/**
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
#define BUILTIN_CUSTOM_DISPATCH
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-map-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID map_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
@@ -35,179 +39,25 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Map.prototype object's 'clear' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.1.3.1
|
||||
* Dispatcher of the built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_map_prototype_object_clear (ecma_value_t this_arg) /**< this argument */
|
||||
ecma_value_t
|
||||
ecma_builtin_map_prototype_dispatch_routine (uint16_t builtin_routine_id, /**< built-in wide routine
|
||||
* identifier */
|
||||
ecma_value_t this_arg, /**< 'this' argument value */
|
||||
const ecma_value_t arguments_list_p[], /**< list of arguments
|
||||
* passed to routine */
|
||||
ecma_length_t arguments_number) /**< length of arguments' list */
|
||||
{
|
||||
return ecma_op_container_clear (this_arg, LIT_MAGIC_STRING_MAP_UL);
|
||||
} /* ecma_builtin_map_prototype_object_clear */
|
||||
|
||||
/**
|
||||
* The Map.prototype object's 'delete' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.1.3.3
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_map_prototype_object_delete (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_value_t key_arg) /**< key argument */
|
||||
{
|
||||
return ecma_op_container_delete (this_arg, key_arg, LIT_MAGIC_STRING_MAP_UL);
|
||||
} /* ecma_builtin_map_prototype_object_delete */
|
||||
|
||||
/**
|
||||
* The Map.prototype object's 'forEach' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.1.3.5
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_map_prototype_object_foreach (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_value_t predicate, /**< callback function */
|
||||
ecma_value_t predicate_this_arg) /**< this argument for
|
||||
* invoke predicate */
|
||||
{
|
||||
return ecma_op_container_foreach (this_arg, predicate, predicate_this_arg, LIT_MAGIC_STRING_MAP_UL);
|
||||
} /* ecma_builtin_map_prototype_object_foreach */
|
||||
|
||||
/**
|
||||
* The Map.prototype object's 'get' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.1.3.6
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_map_prototype_object_get (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_value_t key_arg) /**< key argument */
|
||||
{
|
||||
return ecma_op_container_get (this_arg, key_arg, LIT_MAGIC_STRING_MAP_UL);
|
||||
} /* ecma_builtin_map_prototype_object_get */
|
||||
|
||||
/**
|
||||
* The Map.prototype object's 'has' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.1.3.7
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_map_prototype_object_has (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_value_t key_arg) /**< key argument */
|
||||
{
|
||||
return ecma_op_container_has (this_arg, key_arg, LIT_MAGIC_STRING_MAP_UL);
|
||||
} /* ecma_builtin_map_prototype_object_has */
|
||||
|
||||
/**
|
||||
* The Map.prototype object's 'set' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.1.3.9
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_map_prototype_object_set (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_value_t key_arg, /**< key argument */
|
||||
ecma_value_t value_arg) /**< value argument */
|
||||
{
|
||||
return ecma_op_container_set (this_arg, key_arg, value_arg, LIT_MAGIC_STRING_MAP_UL);
|
||||
} /* ecma_builtin_map_prototype_object_set */
|
||||
|
||||
/**
|
||||
* The Map.prototype object's 'size' getter
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.1.3.10
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_map_prototype_object_size_getter (ecma_value_t this_arg) /**< this argument */
|
||||
{
|
||||
return ecma_op_container_size (this_arg, LIT_MAGIC_STRING_MAP_UL);
|
||||
} /* ecma_builtin_map_prototype_object_size_getter */
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/**
|
||||
* The Map.prototype object's 'entries' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.1.3.4
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_map_prototype_object_entries (ecma_value_t this_arg) /**< this argument */
|
||||
{
|
||||
return ecma_op_container_create_iterator (this_arg,
|
||||
ECMA_ITERATOR_KEYS_VALUES,
|
||||
LIT_MAGIC_STRING_MAP_UL,
|
||||
ECMA_BUILTIN_ID_MAP_ITERATOR_PROTOTYPE,
|
||||
ECMA_PSEUDO_MAP_ITERATOR);
|
||||
} /* ecma_builtin_map_prototype_object_entries */
|
||||
|
||||
/**
|
||||
* The Map.prototype object's 'keys' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.1.3.8
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_map_prototype_object_keys (ecma_value_t this_arg) /**< this argument */
|
||||
{
|
||||
return ecma_op_container_create_iterator (this_arg,
|
||||
ECMA_ITERATOR_KEYS,
|
||||
LIT_MAGIC_STRING_MAP_UL,
|
||||
ECMA_BUILTIN_ID_MAP_ITERATOR_PROTOTYPE,
|
||||
ECMA_PSEUDO_MAP_ITERATOR);
|
||||
} /* ecma_builtin_map_prototype_object_keys */
|
||||
|
||||
/**
|
||||
* The Map.prototype object's 'values' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.1.3.11
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_map_prototype_object_values (ecma_value_t this_arg) /**< this argument */
|
||||
{
|
||||
return ecma_op_container_create_iterator (this_arg,
|
||||
ECMA_ITERATOR_VALUES,
|
||||
LIT_MAGIC_STRING_MAP_UL,
|
||||
ECMA_BUILTIN_ID_MAP_ITERATOR_PROTOTYPE,
|
||||
ECMA_PSEUDO_MAP_ITERATOR);
|
||||
} /* ecma_builtin_map_prototype_object_values */
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
JERRY_UNUSED (arguments_number);
|
||||
return ecma_builtin_container_dispatch_routine (builtin_routine_id,
|
||||
this_arg,
|
||||
arguments_list_p,
|
||||
LIT_MAGIC_STRING_MAP_UL);
|
||||
} /* ecma_builtin_map_prototype_dispatch_routine */
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
|
||||
@@ -38,22 +38,22 @@ STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
ROUTINE (LIT_MAGIC_STRING_CLEAR, ecma_builtin_map_prototype_object_clear, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_DELETE, ecma_builtin_map_prototype_object_delete, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_FOR_EACH_UL, ecma_builtin_map_prototype_object_foreach, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_GET, ecma_builtin_map_prototype_object_get, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_HAS, ecma_builtin_map_prototype_object_has, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET, ecma_builtin_map_prototype_object_set, 2, 2)
|
||||
ROUTINE (LIT_MAGIC_STRING_CLEAR, ECMA_CONTAINER_ROUTINE_CLEAR, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_DELETE, ECMA_CONTAINER_ROUTINE_DELETE, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_FOR_EACH_UL, ECMA_CONTAINER_ROUTINE_FOREACH, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_GET, ECMA_CONTAINER_ROUTINE_GET, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_HAS, ECMA_CONTAINER_ROUTINE_HAS, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET, ECMA_CONTAINER_ROUTINE_SET, 2, 2)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ROUTINE (LIT_MAGIC_STRING_ENTRIES, ecma_builtin_map_prototype_object_entries, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_VALUES, ecma_builtin_map_prototype_object_values, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_KEYS, ecma_builtin_map_prototype_object_keys, 0, 0)
|
||||
ROUTINE (LIT_GLOBAL_SYMBOL_ITERATOR, ecma_builtin_map_prototype_object_entries, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_ENTRIES, ECMA_CONTAINER_ROUTINE_ENTRIES, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_VALUES, ECMA_CONTAINER_ROUTINE_VALUES, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_KEYS, ECMA_CONTAINER_ROUTINE_KEYS, 0, 0)
|
||||
ROUTINE (LIT_GLOBAL_SYMBOL_ITERATOR, ECMA_CONTAINER_ROUTINE_ENTRIES, 0, 0)
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/* ECMA-262 v6, 23.1.3.10 */
|
||||
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_SIZE,
|
||||
ecma_builtin_map_prototype_object_size_getter,
|
||||
ECMA_CONTAINER_ROUTINE_SIZE_GETTER,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_MAP) */
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
/**
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
#define BUILTIN_CUSTOM_DISPATCH
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-set-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID set_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
@@ -33,168 +37,32 @@
|
||||
* \addtogroup set ECMA Set object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Set.prototype object's 'add' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.2.3.1
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_set_prototype_object_add (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_value_t value_arg) /**< value argument */
|
||||
{
|
||||
return ecma_op_container_set (this_arg, value_arg, value_arg, LIT_MAGIC_STRING_SET_UL);
|
||||
} /* ecma_builtin_set_prototype_object_add */
|
||||
|
||||
/**
|
||||
* The Set.prototype object's 'clear' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.2.3.2
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_set_prototype_object_clear (ecma_value_t this_arg) /**< this argument */
|
||||
{
|
||||
return ecma_op_container_clear (this_arg, LIT_MAGIC_STRING_SET_UL);
|
||||
} /* ecma_builtin_set_prototype_object_clear */
|
||||
|
||||
/**
|
||||
* The Set.prototype object's 'delete' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.2.3.4
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_set_prototype_object_delete (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_value_t value_arg) /**< value argument */
|
||||
{
|
||||
return ecma_op_container_delete (this_arg, value_arg, LIT_MAGIC_STRING_SET_UL);
|
||||
} /* ecma_builtin_set_prototype_object_delete */
|
||||
|
||||
/**
|
||||
* The Set.prototype object's 'forEach' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.2.3.6
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_set_prototype_object_foreach (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_value_t predicate, /**< callback function */
|
||||
ecma_value_t predicate_this_arg) /**< this argument for
|
||||
* invoke predicate */
|
||||
{
|
||||
return ecma_op_container_foreach (this_arg, predicate, predicate_this_arg, LIT_MAGIC_STRING_SET_UL);
|
||||
} /* ecma_builtin_set_prototype_object_foreach */
|
||||
|
||||
/**
|
||||
* The Set.prototype object's 'has' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.2.3.7
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_set_prototype_object_has (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_value_t value_arg) /**< value argument */
|
||||
{
|
||||
return ecma_op_container_has (this_arg, value_arg, LIT_MAGIC_STRING_SET_UL);
|
||||
} /* ecma_builtin_set_prototype_object_has */
|
||||
|
||||
/**
|
||||
* The Set.prototype object's 'size' getter
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.2.3.9
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_set_prototype_object_size_getter (ecma_value_t this_arg) /**< this argument */
|
||||
{
|
||||
return ecma_op_container_size (this_arg, LIT_MAGIC_STRING_SET_UL);
|
||||
} /* ecma_builtin_set_prototype_object_size_getter */
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/**
|
||||
* The Set.prototype object's 'entries' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.2.3.5
|
||||
* Dispatcher of the built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_set_prototype_object_entries (ecma_value_t this_arg) /**< this argument */
|
||||
ecma_value_t
|
||||
ecma_builtin_set_prototype_dispatch_routine (uint16_t builtin_routine_id, /**< built-in wide routine
|
||||
* identifier */
|
||||
ecma_value_t this_arg, /**< 'this' argument value */
|
||||
const ecma_value_t arguments_list_p[], /**< list of arguments
|
||||
* passed to routine */
|
||||
ecma_length_t arguments_number) /**< length of arguments' list */
|
||||
{
|
||||
return ecma_op_container_create_iterator (this_arg,
|
||||
ECMA_ITERATOR_KEYS_VALUES,
|
||||
LIT_MAGIC_STRING_SET_UL,
|
||||
ECMA_BUILTIN_ID_SET_ITERATOR_PROTOTYPE,
|
||||
ECMA_PSEUDO_SET_ITERATOR);
|
||||
} /* ecma_builtin_set_prototype_object_entries */
|
||||
|
||||
JERRY_UNUSED (arguments_number);
|
||||
return ecma_builtin_container_dispatch_routine (builtin_routine_id,
|
||||
this_arg,
|
||||
arguments_list_p,
|
||||
LIT_MAGIC_STRING_SET_UL);
|
||||
} /* ecma_builtin_set_prototype_dispatch_routine */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
/**
|
||||
* The Set.prototype object's 'keys' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.2.3.8
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_set_prototype_object_keys (ecma_value_t this_arg) /**< this argument */
|
||||
{
|
||||
return ecma_op_container_create_iterator (this_arg,
|
||||
ECMA_ITERATOR_KEYS,
|
||||
LIT_MAGIC_STRING_SET_UL,
|
||||
ECMA_BUILTIN_ID_SET_ITERATOR_PROTOTYPE,
|
||||
ECMA_PSEUDO_SET_ITERATOR);
|
||||
} /* ecma_builtin_set_prototype_object_keys */
|
||||
|
||||
/**
|
||||
* The Set.prototype object's 'values' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.2.3.10
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_set_prototype_object_values (ecma_value_t this_arg) /**< this argument */
|
||||
{
|
||||
return ecma_op_container_create_iterator (this_arg,
|
||||
ECMA_ITERATOR_VALUES,
|
||||
LIT_MAGIC_STRING_SET_UL,
|
||||
ECMA_BUILTIN_ID_SET_ITERATOR_PROTOTYPE,
|
||||
ECMA_PSEUDO_SET_ITERATOR);
|
||||
} /* ecma_builtin_set_prototype_object_values */
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_SET) */
|
||||
|
||||
@@ -38,20 +38,20 @@ STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
ROUTINE (LIT_MAGIC_STRING_ADD, ecma_builtin_set_prototype_object_add, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_CLEAR, ecma_builtin_set_prototype_object_clear, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_DELETE, ecma_builtin_set_prototype_object_delete, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_FOR_EACH_UL, ecma_builtin_set_prototype_object_foreach, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_HAS, ecma_builtin_set_prototype_object_has, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_CLEAR, ECMA_CONTAINER_ROUTINE_CLEAR, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_ADD, ECMA_CONTAINER_ROUTINE_ADD, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_DELETE, ECMA_CONTAINER_ROUTINE_DELETE, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_FOR_EACH_UL, ECMA_CONTAINER_ROUTINE_FOREACH, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_HAS, ECMA_CONTAINER_ROUTINE_HAS, 1, 1)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ROUTINE (LIT_MAGIC_STRING_ENTRIES, ecma_builtin_set_prototype_object_entries, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_VALUES, ecma_builtin_set_prototype_object_values, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_KEYS, ecma_builtin_set_prototype_object_keys, 0, 0)
|
||||
ROUTINE (LIT_GLOBAL_SYMBOL_ITERATOR, ecma_builtin_set_prototype_object_values, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_ENTRIES, ECMA_CONTAINER_ROUTINE_ENTRIES, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_VALUES, ECMA_CONTAINER_ROUTINE_VALUES, 0, 0)
|
||||
ROUTINE (LIT_GLOBAL_SYMBOL_ITERATOR, ECMA_CONTAINER_ROUTINE_VALUES, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_KEYS, ECMA_CONTAINER_ROUTINE_KEYS, 0, 0)
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_SIZE,
|
||||
ecma_builtin_set_prototype_object_size_getter,
|
||||
ECMA_CONTAINER_ROUTINE_SIZE_GETTER,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_SET) */
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
/**
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
#define BUILTIN_CUSTOM_DISPATCH
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-weakmap-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID weakmap_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
@@ -33,72 +37,26 @@
|
||||
* \addtogroup weakmap ECMA WeakMap object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The WeakMap.prototype object's 'delete' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.3.3.2
|
||||
* Dispatcher of the built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_weakmap_prototype_object_delete (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_value_t key_arg) /**< key argument */
|
||||
ecma_value_t
|
||||
ecma_builtin_weakmap_prototype_dispatch_routine (uint16_t builtin_routine_id, /**< built-in wide routine
|
||||
* identifier */
|
||||
ecma_value_t this_arg, /**< 'this' argument value */
|
||||
const ecma_value_t arguments_list_p[], /**< list of arguments
|
||||
* passed to routine */
|
||||
ecma_length_t arguments_number) /**< length of arguments' list */
|
||||
{
|
||||
return ecma_op_container_delete_weak (this_arg, key_arg, LIT_MAGIC_STRING_WEAKMAP_UL);
|
||||
} /* ecma_builtin_weakmap_prototype_object_delete */
|
||||
|
||||
/**
|
||||
* The WeakMap.prototype object's 'get' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.3.3.3
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_weakmap_prototype_object_get (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_value_t key_arg) /**< key argument */
|
||||
{
|
||||
return ecma_op_container_get (this_arg, key_arg, LIT_MAGIC_STRING_WEAKMAP_UL);
|
||||
} /* ecma_builtin_weakmap_prototype_object_get */
|
||||
|
||||
/**
|
||||
* The WeakMap.prototype object's 'has' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.3.3.4
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_weakmap_prototype_object_has (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_value_t key_arg) /**< key argument */
|
||||
{
|
||||
return ecma_op_container_has (this_arg, key_arg, LIT_MAGIC_STRING_WEAKMAP_UL);
|
||||
} /* ecma_builtin_weakmap_prototype_object_has */
|
||||
|
||||
/**
|
||||
* The WeakMap.prototype object's 'set' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.3.3.5
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_weakmap_prototype_object_set (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_value_t key_arg, /**< key argument */
|
||||
ecma_value_t value_arg) /**< value argument */
|
||||
{
|
||||
return ecma_op_container_set (this_arg, key_arg, value_arg, LIT_MAGIC_STRING_WEAKMAP_UL);
|
||||
} /* ecma_builtin_weakmap_prototype_object_set */
|
||||
|
||||
JERRY_UNUSED (arguments_number);
|
||||
return ecma_builtin_container_dispatch_routine (builtin_routine_id,
|
||||
this_arg,
|
||||
arguments_list_p,
|
||||
LIT_MAGIC_STRING_WEAKMAP_UL);
|
||||
} /* ecma_builtin_weakmap_prototype_dispatch_routine */
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
|
||||
@@ -36,10 +36,10 @@ STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
ROUTINE (LIT_MAGIC_STRING_DELETE, ecma_builtin_weakmap_prototype_object_delete, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_GET, ecma_builtin_weakmap_prototype_object_get, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_HAS, ecma_builtin_weakmap_prototype_object_has, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET, ecma_builtin_weakmap_prototype_object_set, 2, 2)
|
||||
ROUTINE (LIT_MAGIC_STRING_DELETE, ECMA_CONTAINER_ROUTINE_DELETE_WEAK, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_GET, ECMA_CONTAINER_ROUTINE_GET, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_HAS, ECMA_CONTAINER_ROUTINE_HAS, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET, ECMA_CONTAINER_ROUTINE_SET, 2, 2)
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_WEAKMAP) */
|
||||
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
/**
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
#define BUILTIN_CUSTOM_DISPATCH
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-weakset-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID weakset_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
@@ -35,53 +39,25 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* The WeakSet.prototype object's 'add' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.4.3.1
|
||||
* Dispatcher of the built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_weakset_prototype_object_add (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_value_t value_arg) /**< value argument */
|
||||
ecma_value_t
|
||||
ecma_builtin_weakset_prototype_dispatch_routine (uint16_t builtin_routine_id, /**< built-in wide routine
|
||||
* identifier */
|
||||
ecma_value_t this_arg, /**< 'this' argument value */
|
||||
const ecma_value_t arguments_list_p[], /**< list of arguments
|
||||
* passed to routine */
|
||||
ecma_length_t arguments_number) /**< length of arguments' list */
|
||||
{
|
||||
return ecma_op_container_set (this_arg, value_arg, ECMA_VALUE_UNDEFINED, LIT_MAGIC_STRING_WEAKSET_UL);
|
||||
} /* ecma_builtin_weakset_prototype_object_add */
|
||||
|
||||
/**
|
||||
* The WeakSet.prototype object's 'delete' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.4.3.3
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_weakset_prototype_object_delete (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_value_t value_arg) /**< value argument */
|
||||
{
|
||||
return ecma_op_container_delete_weak (this_arg, value_arg, LIT_MAGIC_STRING_WEAKSET_UL);
|
||||
} /* ecma_builtin_weakset_prototype_object_delete */
|
||||
|
||||
/**
|
||||
* The WeakSet.prototype object's 'has' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.4.3.4
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_weakset_prototype_object_has (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_value_t value_arg) /**< value argument */
|
||||
{
|
||||
return ecma_op_container_has (this_arg, value_arg, LIT_MAGIC_STRING_WEAKSET_UL);
|
||||
} /* ecma_builtin_weakset_prototype_object_has */
|
||||
|
||||
JERRY_UNUSED (arguments_number);
|
||||
return ecma_builtin_container_dispatch_routine (builtin_routine_id,
|
||||
this_arg,
|
||||
arguments_list_p,
|
||||
LIT_MAGIC_STRING_WEAKSET_UL);
|
||||
} /* ecma_builtin_weakset_prototype_dispatch_routine */
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
|
||||
@@ -36,9 +36,9 @@ STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
ROUTINE (LIT_MAGIC_STRING_ADD, ecma_builtin_weakset_prototype_object_add, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_DELETE, ecma_builtin_weakset_prototype_object_delete, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_HAS, ecma_builtin_weakset_prototype_object_has, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_ADD, ECMA_CONTAINER_ROUTINE_ADD, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_DELETE, ECMA_CONTAINER_ROUTINE_DELETE_WEAK, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_HAS, ECMA_CONTAINER_ROUTINE_HAS, 1, 1)
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_WEAKSET) */
|
||||
|
||||
|
||||
@@ -557,7 +557,7 @@ cleanup_object:
|
||||
* @return pointer to the Map/Set if this_arg is a valid Map/Set object
|
||||
* NULL otherwise
|
||||
*/
|
||||
static ecma_extended_object_t *
|
||||
ecma_extended_object_t *
|
||||
ecma_op_container_get_object (ecma_value_t this_arg, /**< this argument */
|
||||
lit_magic_string_id_t lit_id) /**< internal class id */
|
||||
{
|
||||
@@ -589,16 +589,8 @@ ecma_op_container_get_object (ecma_value_t this_arg, /**< this argument */
|
||||
* @return size of the Map/Set object as ecma-value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_container_size (ecma_value_t this_arg, /**< this argument */
|
||||
lit_magic_string_id_t lit_id) /**< internal class id */
|
||||
ecma_op_container_size (ecma_extended_object_t *map_object_p) /**< internal class id */
|
||||
{
|
||||
ecma_extended_object_t *map_object_p = ecma_op_container_get_object (this_arg, lit_id);
|
||||
|
||||
if (map_object_p == NULL)
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
|
||||
map_object_p->u.class_prop.u.value);
|
||||
|
||||
@@ -612,17 +604,10 @@ ecma_op_container_size (ecma_value_t this_arg, /**< this argument */
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_container_get (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_op_container_get (ecma_extended_object_t *map_object_p, /**< map object */
|
||||
ecma_value_t key_arg, /**< key argument */
|
||||
lit_magic_string_id_t lit_id) /**< internal class id */
|
||||
{
|
||||
ecma_extended_object_t *map_object_p = ecma_op_container_get_object (this_arg, lit_id);
|
||||
|
||||
if (map_object_p == NULL)
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_WEAKMAP)
|
||||
if (lit_id == LIT_MAGIC_STRING_WEAKMAP_UL && !ecma_is_value_object (key_arg))
|
||||
{
|
||||
@@ -655,17 +640,10 @@ ecma_op_container_get (ecma_value_t this_arg, /**< this argument */
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_container_has (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_op_container_has (ecma_extended_object_t *map_object_p, /**< map object */
|
||||
ecma_value_t key_arg, /**< key argument */
|
||||
lit_magic_string_id_t lit_id) /**< internal class id */
|
||||
{
|
||||
ecma_extended_object_t *map_object_p = ecma_op_container_get_object (this_arg, lit_id);
|
||||
|
||||
if (map_object_p == NULL)
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
|
||||
map_object_p->u.class_prop.u.value);
|
||||
|
||||
@@ -763,18 +741,11 @@ ecma_op_container_set_noramlize_zero (ecma_value_t this_arg) /*< this arg */
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_container_set (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_op_container_set (ecma_extended_object_t *map_object_p, /**< map object */
|
||||
ecma_value_t key_arg, /**< key argument */
|
||||
ecma_value_t value_arg, /**< value argument */
|
||||
lit_magic_string_id_t lit_id) /**< internal class id */
|
||||
{
|
||||
ecma_extended_object_t *map_object_p = ecma_op_container_get_object (this_arg, lit_id);
|
||||
|
||||
if (map_object_p == NULL)
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
|
||||
map_object_p->u.class_prop.u.value);
|
||||
|
||||
@@ -809,7 +780,7 @@ ecma_op_container_set (ecma_value_t this_arg, /**< this argument */
|
||||
}
|
||||
|
||||
ecma_ref_object ((ecma_object_t *) map_object_p);
|
||||
return this_arg;
|
||||
return ecma_make_object_value ((ecma_object_t *) map_object_p);
|
||||
} /* ecma_op_container_set */
|
||||
|
||||
/**
|
||||
@@ -819,19 +790,12 @@ ecma_op_container_set (ecma_value_t this_arg, /**< this argument */
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_container_foreach (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_op_container_foreach (ecma_extended_object_t *map_object_p, /**< map object */
|
||||
ecma_value_t predicate, /**< callback function */
|
||||
ecma_value_t predicate_this_arg, /**< this argument for
|
||||
* invoke predicate */
|
||||
lit_magic_string_id_t lit_id) /**< internal class id */
|
||||
{
|
||||
ecma_extended_object_t *map_object_p = ecma_op_container_get_object (this_arg, lit_id);
|
||||
|
||||
if (map_object_p == NULL)
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
if (!ecma_op_is_callable (predicate))
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Callback function is not callable."));
|
||||
@@ -858,6 +822,7 @@ ecma_op_container_foreach (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_value_t key_arg = *entry_p;
|
||||
ecma_value_t value_arg = ecma_op_container_get_value (entry_p, lit_id);
|
||||
|
||||
ecma_value_t this_arg = ecma_make_object_value ((ecma_object_t *) map_object_p);
|
||||
ecma_value_t call_args[] = { value_arg, key_arg, this_arg };
|
||||
ecma_value_t call_value = ecma_op_function_call (func_object_p, predicate_this_arg, call_args, 3);
|
||||
|
||||
@@ -880,15 +845,8 @@ ecma_op_container_foreach (ecma_value_t this_arg, /**< this argument */
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_container_clear (ecma_value_t this_arg, /**< this argument */
|
||||
lit_magic_string_id_t lit_id) /**< internal class id */
|
||||
ecma_op_container_clear (ecma_extended_object_t *map_object_p) /**< this argument */
|
||||
{
|
||||
ecma_extended_object_t *map_object_p = ecma_op_container_get_object (this_arg, lit_id);
|
||||
|
||||
if (map_object_p == NULL)
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_op_container_free_entries ((ecma_object_t *) map_object_p);
|
||||
|
||||
@@ -902,17 +860,10 @@ ecma_op_container_clear (ecma_value_t this_arg, /**< this argument */
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_container_delete (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_op_container_delete (ecma_extended_object_t *map_object_p, /**< map object */
|
||||
ecma_value_t key_arg, /**< key argument */
|
||||
lit_magic_string_id_t lit_id) /**< internal class id */
|
||||
{
|
||||
ecma_extended_object_t *map_object_p = ecma_op_container_get_object (this_arg, lit_id);
|
||||
|
||||
if (map_object_p == NULL)
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
|
||||
map_object_p->u.class_prop.u.value);
|
||||
|
||||
@@ -934,17 +885,10 @@ ecma_op_container_delete (ecma_value_t this_arg, /**< this argument */
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_container_delete_weak (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_op_container_delete_weak (ecma_extended_object_t *map_object_p, /**< map object */
|
||||
ecma_value_t key_arg, /**< key argument */
|
||||
lit_magic_string_id_t lit_id) /**< internal class id */
|
||||
{
|
||||
ecma_extended_object_t *map_object_p = ecma_op_container_get_object (this_arg, lit_id);
|
||||
|
||||
if (map_object_p == NULL)
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
if (!ecma_is_value_object (key_arg))
|
||||
{
|
||||
return ECMA_VALUE_FALSE;
|
||||
@@ -1033,17 +977,9 @@ ecma_value_t
|
||||
ecma_op_container_create_iterator (ecma_value_t this_arg, /**< this argument */
|
||||
uint8_t type, /**< any combination of
|
||||
* ecma_iterator_type_t bits */
|
||||
lit_magic_string_id_t lit_id, /**< internal class id */
|
||||
ecma_builtin_id_t proto_id, /**< prototype builtin id */
|
||||
ecma_pseudo_array_type_t iterator_type) /**< type of the iterator */
|
||||
{
|
||||
ecma_extended_object_t *map_object_p = ecma_op_container_get_object (this_arg, lit_id);
|
||||
|
||||
if (map_object_p == NULL)
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
return ecma_op_create_iterator_object (this_arg,
|
||||
ecma_builtin_get (proto_id),
|
||||
(uint8_t) iterator_type,
|
||||
@@ -1207,6 +1143,92 @@ ecma_op_container_iterator_next (ecma_value_t this_val, /**< this argument */
|
||||
return ret_value;
|
||||
} /* ecma_op_container_iterator_next */
|
||||
|
||||
/**
|
||||
* Dispatcher of builtin container routines.
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_container_dispatch_routine (uint16_t builtin_routine_id, /**< built-in wide routine
|
||||
* identifier */
|
||||
ecma_value_t this_arg, /**< 'this' argument value */
|
||||
const ecma_value_t arguments_list_p[], /**< list of arguments
|
||||
* passed to routine */
|
||||
lit_magic_string_id_t lit_id) /**< internal class id */
|
||||
{
|
||||
ecma_extended_object_t *map_object_p = ecma_op_container_get_object (this_arg, lit_id);
|
||||
|
||||
if (map_object_p == NULL)
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
switch (builtin_routine_id)
|
||||
{
|
||||
case ECMA_CONTAINER_ROUTINE_DELETE:
|
||||
{
|
||||
return ecma_op_container_delete (map_object_p, arguments_list_p[0], lit_id);
|
||||
}
|
||||
case ECMA_CONTAINER_ROUTINE_DELETE_WEAK:
|
||||
{
|
||||
return ecma_op_container_delete_weak (map_object_p, arguments_list_p[0], lit_id);
|
||||
}
|
||||
case ECMA_CONTAINER_ROUTINE_GET:
|
||||
{
|
||||
return ecma_op_container_get (map_object_p, arguments_list_p[0], lit_id);
|
||||
}
|
||||
case ECMA_CONTAINER_ROUTINE_SET:
|
||||
{
|
||||
return ecma_op_container_set (map_object_p, arguments_list_p[0], arguments_list_p[1], lit_id);
|
||||
}
|
||||
case ECMA_CONTAINER_ROUTINE_HAS:
|
||||
{
|
||||
return ecma_op_container_has (map_object_p, arguments_list_p[0], lit_id);
|
||||
}
|
||||
case ECMA_CONTAINER_ROUTINE_FOREACH:
|
||||
{
|
||||
return ecma_op_container_foreach (map_object_p, arguments_list_p[0], arguments_list_p[1], lit_id);
|
||||
}
|
||||
case ECMA_CONTAINER_ROUTINE_SIZE_GETTER:
|
||||
{
|
||||
return ecma_op_container_size (map_object_p);
|
||||
}
|
||||
case ECMA_CONTAINER_ROUTINE_ADD:
|
||||
{
|
||||
return ecma_op_container_set (map_object_p, arguments_list_p[0], arguments_list_p[0], lit_id);
|
||||
}
|
||||
case ECMA_CONTAINER_ROUTINE_CLEAR:
|
||||
{
|
||||
return ecma_op_container_clear (map_object_p);
|
||||
}
|
||||
case ECMA_CONTAINER_ROUTINE_KEYS:
|
||||
case ECMA_CONTAINER_ROUTINE_VALUES:
|
||||
case ECMA_CONTAINER_ROUTINE_ENTRIES:
|
||||
{
|
||||
ecma_builtin_id_t builtin_iterator_prototype = ECMA_BUILTIN_ID_MAP_ITERATOR_PROTOTYPE;
|
||||
ecma_pseudo_array_type_t iterator_type = ECMA_PSEUDO_MAP_ITERATOR;
|
||||
|
||||
if (lit_id != LIT_MAGIC_STRING_MAP_UL)
|
||||
{
|
||||
builtin_iterator_prototype = ECMA_BUILTIN_ID_SET_ITERATOR_PROTOTYPE;
|
||||
iterator_type = ECMA_PSEUDO_SET_ITERATOR;
|
||||
}
|
||||
|
||||
uint8_t mode = (uint8_t) (builtin_routine_id - ECMA_CONTAINER_ROUTINE_KEYS);
|
||||
|
||||
return ecma_op_container_create_iterator (this_arg,
|
||||
mode,
|
||||
builtin_iterator_prototype,
|
||||
iterator_type);
|
||||
}
|
||||
default:
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
}
|
||||
}
|
||||
} /* ecma_builtin_container_dispatch_routine */
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,25 +28,54 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* List of built-in routine identifiers.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
ECMA_CONTAINER_ROUTINE_START = ECMA_BUILTIN_ID__COUNT - 1,
|
||||
ECMA_CONTAINER_ROUTINE_ADD,
|
||||
ECMA_CONTAINER_ROUTINE_CLEAR,
|
||||
ECMA_CONTAINER_ROUTINE_DELETE_WEAK,
|
||||
ECMA_CONTAINER_ROUTINE_DELETE,
|
||||
ECMA_CONTAINER_ROUTINE_FOREACH,
|
||||
ECMA_CONTAINER_ROUTINE_HAS,
|
||||
ECMA_CONTAINER_ROUTINE_SIZE_GETTER,
|
||||
ECMA_CONTAINER_ROUTINE_GET,
|
||||
ECMA_CONTAINER_ROUTINE_SET,
|
||||
/* Note: These 3 routines MUST be in this order */
|
||||
ECMA_CONTAINER_ROUTINE_KEYS,
|
||||
ECMA_CONTAINER_ROUTINE_VALUES,
|
||||
ECMA_CONTAINER_ROUTINE_ENTRIES
|
||||
};
|
||||
|
||||
uint8_t ecma_op_container_entry_size (lit_magic_string_id_t lit_id);
|
||||
ecma_extended_object_t *ecma_op_container_get_object (ecma_value_t this_arg, lit_magic_string_id_t lit_id);
|
||||
ecma_value_t ecma_op_container_create (const ecma_value_t *arguments_list_p, ecma_length_t arguments_list_len,
|
||||
lit_magic_string_id_t lit_id, ecma_builtin_id_t proto_id);
|
||||
ecma_value_t ecma_op_container_size (ecma_value_t this_arg, lit_magic_string_id_t lit_id);
|
||||
ecma_value_t ecma_op_container_get (ecma_value_t this_arg, ecma_value_t key_arg, lit_magic_string_id_t lit_id);
|
||||
ecma_value_t ecma_op_container_foreach (ecma_value_t this_arg, ecma_value_t predicate, ecma_value_t predicate_this_arg,
|
||||
lit_magic_string_id_t lit_id);
|
||||
ecma_value_t ecma_op_container_has (ecma_value_t this_arg, ecma_value_t key_arg, lit_magic_string_id_t lit_id);
|
||||
ecma_value_t ecma_op_container_set (ecma_value_t this_arg, ecma_value_t key_arg, ecma_value_t value_arg,
|
||||
ecma_value_t ecma_op_container_size (ecma_extended_object_t *map_object_p);
|
||||
ecma_value_t ecma_op_container_get (ecma_extended_object_t *map_object_p, ecma_value_t key_arg,
|
||||
lit_magic_string_id_t lit_id);
|
||||
ecma_value_t ecma_op_container_clear (ecma_value_t this_arg, lit_magic_string_id_t lit_id);
|
||||
ecma_value_t ecma_op_container_delete (ecma_value_t this_arg, ecma_value_t key_arg, lit_magic_string_id_t lit_id);
|
||||
ecma_value_t ecma_op_container_delete_weak (ecma_value_t this_arg, ecma_value_t key_arg, lit_magic_string_id_t lit_id);
|
||||
ecma_value_t ecma_op_container_foreach (ecma_extended_object_t *map_object_p, ecma_value_t predicate,
|
||||
ecma_value_t predicate_this_arg, lit_magic_string_id_t lit_id);
|
||||
ecma_value_t ecma_op_container_has (ecma_extended_object_t *map_object_p, ecma_value_t key_arg,
|
||||
lit_magic_string_id_t lit_id);
|
||||
ecma_value_t ecma_op_container_set (ecma_extended_object_t *map_object_p, ecma_value_t key_arg,
|
||||
ecma_value_t value_arg, lit_magic_string_id_t lit_id);
|
||||
ecma_value_t ecma_op_container_clear (ecma_extended_object_t *map_object_p);
|
||||
ecma_value_t ecma_op_container_delete (ecma_extended_object_t *map_object_p, ecma_value_t key_arg,
|
||||
lit_magic_string_id_t lit_id);
|
||||
ecma_value_t ecma_op_container_delete_weak (ecma_extended_object_t *map_object_p, ecma_value_t key_arg,
|
||||
lit_magic_string_id_t lit_id);
|
||||
void ecma_op_container_unref_weak (ecma_object_t *object_p, ecma_value_t ref_holder);
|
||||
void ecma_op_container_remove_weak_entry (ecma_object_t *container_p, ecma_value_t key_arg);
|
||||
void ecma_op_container_free_entries (ecma_object_t *object_p);
|
||||
ecma_value_t ecma_op_container_create_iterator (ecma_value_t this_arg, uint8_t type, lit_magic_string_id_t lit_id,
|
||||
ecma_value_t ecma_op_container_create_iterator (ecma_value_t this_arg, uint8_t type,
|
||||
ecma_builtin_id_t proto_id, ecma_pseudo_array_type_t iterator_type);
|
||||
ecma_value_t ecma_op_container_iterator_next (ecma_value_t this_val, ecma_pseudo_array_type_t iterator_type);
|
||||
ecma_value_t ecma_builtin_container_dispatch_routine (uint16_t builtin_routine_id, ecma_value_t this_arg,
|
||||
const ecma_value_t arguments_list_p[],
|
||||
lit_magic_string_id_t lit_id);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
Reference in New Issue
Block a user