Implement the Map/Set iterator operations (#2882)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
committed by
Dániel Bátyai
parent
6f7dbbce7e
commit
9d4c2315f3
@@ -155,7 +155,7 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
|
||||
/* 7. */
|
||||
uint8_t iterator_type = ext_obj_p->u.pseudo_array.extra_info;
|
||||
|
||||
if (iterator_type == ECMA_ARRAY_ITERATOR_KEYS)
|
||||
if (iterator_type == ECMA_ITERATOR_KEYS)
|
||||
{
|
||||
/* 12. */
|
||||
return ecma_create_iter_result_object (ecma_make_uint32_value (index), ECMA_VALUE_FALSE);
|
||||
@@ -177,14 +177,14 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
|
||||
ecma_value_t result;
|
||||
|
||||
/* 16. */
|
||||
if (iterator_type == ECMA_ARRAY_ITERATOR_VALUES)
|
||||
if (iterator_type == ECMA_ITERATOR_VALUES)
|
||||
{
|
||||
result = ecma_create_iter_result_object (get_value, ECMA_VALUE_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 17.a */
|
||||
JERRY_ASSERT (iterator_type == ECMA_ARRAY_ITERATOR_KEYS_VALUES);
|
||||
JERRY_ASSERT (iterator_type == ECMA_ITERATOR_KEYS_VALUES);
|
||||
|
||||
/* 17.b */
|
||||
ecma_value_t entry_array_value;
|
||||
|
||||
@@ -2088,7 +2088,7 @@ ecma_builtin_array_prototype_object_find (ecma_value_t predicate, /**< callback
|
||||
static ecma_value_t
|
||||
ecma_builtin_array_iterators_helper (ecma_object_t *obj_p, /**< array object */
|
||||
uint8_t type) /**< any combination of
|
||||
* ecma_array_iterator_type_t bits */
|
||||
* ecma_iterator_type_t bits */
|
||||
{
|
||||
ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_ARRAY_ITERATOR_PROTOTYPE);
|
||||
|
||||
@@ -2150,18 +2150,18 @@ ecma_builtin_array_prototype_dispatch_routine (uint16_t builtin_routine_id, /**<
|
||||
|
||||
if (builtin_routine_id == ECMA_ARRAY_PROTOTYPE_ENTRIES)
|
||||
{
|
||||
ret_value = ecma_builtin_array_iterators_helper (obj_p, ECMA_ARRAY_ITERATOR_KEYS_VALUES);
|
||||
ret_value = ecma_builtin_array_iterators_helper (obj_p, ECMA_ITERATOR_KEYS_VALUES);
|
||||
}
|
||||
else if (builtin_routine_id == ECMA_ARRAY_PROTOTYPE_KEYS)
|
||||
{
|
||||
ret_value = ecma_builtin_array_iterators_helper (obj_p, ECMA_ARRAY_ITERATOR_KEYS);
|
||||
ret_value = ecma_builtin_array_iterators_helper (obj_p, ECMA_ITERATOR_KEYS);
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (builtin_routine_id == ECMA_ARRAY_PROTOTYPE_VALUES
|
||||
|| builtin_routine_id == ECMA_ARRAY_PROTOTYPE_SYMBOL_ITERATOR);
|
||||
|
||||
ret_value = ecma_builtin_array_iterators_helper (obj_p, ECMA_ARRAY_ITERATOR_VALUES);
|
||||
ret_value = ecma_builtin_array_iterators_helper (obj_p, ECMA_ITERATOR_VALUES);
|
||||
}
|
||||
|
||||
ecma_deref_object (obj_p);
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-container-object.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_MAP)
|
||||
|
||||
#if !ENABLED (JERRY_ES2015_BUILTIN_ITERATOR)
|
||||
#error "Map iterator builtin requires ES2015 iterator builtin"
|
||||
#endif /* !ENABLED (JERRY_ES2015_BUILTIN_ITERATOR) */
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-map-iterator-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID map_iterator_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmabuiltins
|
||||
* @{
|
||||
*
|
||||
* \addtogroup %mapiteratorprototype% ECMA %MapIteratorPrototype% object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The %MapIteratorPrototype% object's 'next' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.1.5.2.1
|
||||
*
|
||||
* Note:
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*
|
||||
* @return iterator result object, if success
|
||||
* error - otherwise
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_map_iterator_prototype_object_next (ecma_value_t this_val) /**< this argument */
|
||||
{
|
||||
return ecma_op_container_iterator_next (this_val, ECMA_PSEUDO_MAP_ITERATOR);
|
||||
} /* ecma_builtin_map_iterator_prototype_object_next */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_MAP) */
|
||||
@@ -0,0 +1,34 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* %MapIteratorPrototype% built-in description
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_MAP)
|
||||
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_MAP_ITERATOR_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
ROUTINE (LIT_MAGIC_STRING_NEXT, ecma_builtin_map_iterator_prototype_object_next, 0, 0)
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_MAP) */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
@@ -46,7 +46,7 @@
|
||||
static ecma_value_t
|
||||
ecma_builtin_map_prototype_object_clear (ecma_value_t this_arg) /**< this argument */
|
||||
{
|
||||
return ecma_op_container_clear (this_arg, false);
|
||||
return ecma_op_container_clear (this_arg, LIT_MAGIC_STRING_MAP_UL);
|
||||
} /* ecma_builtin_map_prototype_object_clear */
|
||||
|
||||
/**
|
||||
@@ -62,7 +62,7 @@ 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, false);
|
||||
return ecma_op_container_delete (this_arg, key_arg, LIT_MAGIC_STRING_MAP_UL);
|
||||
} /* ecma_builtin_map_prototype_object_delete */
|
||||
|
||||
/**
|
||||
@@ -80,7 +80,7 @@ ecma_builtin_map_prototype_object_foreach (ecma_value_t this_arg, /**< this argu
|
||||
ecma_value_t predicate_this_arg) /**< this argument for
|
||||
* invoke predicate */
|
||||
{
|
||||
return ecma_op_container_foreach (this_arg, predicate, predicate_this_arg, false);
|
||||
return ecma_op_container_foreach (this_arg, predicate, predicate_this_arg, LIT_MAGIC_STRING_MAP_UL);
|
||||
} /* ecma_builtin_map_prototype_object_foreach */
|
||||
|
||||
/**
|
||||
@@ -112,7 +112,7 @@ 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, false);
|
||||
return ecma_op_container_has (this_arg, key_arg, LIT_MAGIC_STRING_MAP_UL);
|
||||
} /* ecma_builtin_map_prototype_object_has */
|
||||
|
||||
/**
|
||||
@@ -129,7 +129,7 @@ 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, false);
|
||||
return ecma_op_container_set (this_arg, key_arg, value_arg, LIT_MAGIC_STRING_MAP_UL);
|
||||
} /* ecma_builtin_map_prototype_object_set */
|
||||
|
||||
/**
|
||||
@@ -144,9 +144,69 @@ ecma_builtin_map_prototype_object_set (ecma_value_t this_arg, /**< this argument
|
||||
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, false);
|
||||
return ecma_op_container_size (this_arg, LIT_MAGIC_STRING_MAP_UL);
|
||||
} /* ecma_builtin_map_prototype_object_size_getter */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_ITERATOR)
|
||||
/**
|
||||
* 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_ES2015_BUILTIN_ITERATOR) */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
|
||||
@@ -44,6 +44,12 @@ ROUTINE (LIT_MAGIC_STRING_FOR_EACH_UL, ecma_builtin_map_prototype_object_foreach
|
||||
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)
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_ITERATOR)
|
||||
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_values, 0, 0)
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_ITERATOR) */
|
||||
|
||||
/* ECMA-262 v6, 23.1.3.10 */
|
||||
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_SIZE,
|
||||
|
||||
@@ -59,7 +59,10 @@ ecma_value_t
|
||||
ecma_builtin_map_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
return ecma_op_container_create (arguments_list_p, arguments_list_len, false);
|
||||
return ecma_op_container_create (arguments_list_p,
|
||||
arguments_list_len,
|
||||
LIT_MAGIC_STRING_MAP_UL,
|
||||
ECMA_BUILTIN_ID_MAP_PROTOTYPE);
|
||||
} /* ecma_builtin_map_dispatch_construct */
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-container-object.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_SET)
|
||||
|
||||
#if !ENABLED (JERRY_ES2015_BUILTIN_ITERATOR)
|
||||
#error "Set iterator builtin requires ES2015 iterator builtin"
|
||||
#endif /* !ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-set-iterator-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID set_iterator_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmabuiltins
|
||||
* @{
|
||||
*
|
||||
* \addtogroup %setiteratorprototype% ECMA %SetIteratorPrototype% object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The %SetIteratorPrototype% object's 'next' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.2.5.2.1
|
||||
*
|
||||
* Note:
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*
|
||||
* @return iterator result object, if success
|
||||
* error - otherwise
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_set_iterator_prototype_object_next (ecma_value_t this_val) /**< this argument */
|
||||
{
|
||||
return ecma_op_container_iterator_next (this_val, ECMA_PSEUDO_SET_ITERATOR);
|
||||
} /* ecma_builtin_set_iterator_prototype_object_next */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SET) */
|
||||
@@ -0,0 +1,34 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* %SetIteratorPrototype% built-in description
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_SET)
|
||||
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_SET_ITERATOR_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
ROUTINE (LIT_MAGIC_STRING_NEXT, ecma_builtin_set_iterator_prototype_object_next, 0, 0)
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SET) */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
@@ -17,10 +17,6 @@
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_SET)
|
||||
|
||||
#if !ENABLED (JERRY_ES2015_BUILTIN_MAP)
|
||||
#error "Set builtin requires ES2015 map builtin"
|
||||
#endif /* !ENABLED (JERRY_ES2015_BUILTIN_MAP) */
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
@@ -51,7 +47,7 @@ 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, true);
|
||||
return ecma_op_container_set (this_arg, value_arg, value_arg, LIT_MAGIC_STRING_SET_UL);
|
||||
} /* ecma_builtin_set_prototype_object_add */
|
||||
|
||||
/**
|
||||
@@ -66,7 +62,7 @@ ecma_builtin_set_prototype_object_add (ecma_value_t this_arg, /**< this argument
|
||||
static ecma_value_t
|
||||
ecma_builtin_set_prototype_object_clear (ecma_value_t this_arg) /**< this argument */
|
||||
{
|
||||
return ecma_op_container_clear (this_arg, true);
|
||||
return ecma_op_container_clear (this_arg, LIT_MAGIC_STRING_SET_UL);
|
||||
} /* ecma_builtin_set_prototype_object_clear */
|
||||
|
||||
/**
|
||||
@@ -82,7 +78,7 @@ 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, true);
|
||||
return ecma_op_container_delete (this_arg, value_arg, LIT_MAGIC_STRING_SET_UL);
|
||||
} /* ecma_builtin_set_prototype_object_delete */
|
||||
|
||||
/**
|
||||
@@ -100,7 +96,7 @@ ecma_builtin_set_prototype_object_foreach (ecma_value_t this_arg, /**< this argu
|
||||
ecma_value_t predicate_this_arg) /**< this argument for
|
||||
* invoke predicate */
|
||||
{
|
||||
return ecma_op_container_foreach (this_arg, predicate, predicate_this_arg, true);
|
||||
return ecma_op_container_foreach (this_arg, predicate, predicate_this_arg, LIT_MAGIC_STRING_SET_UL);
|
||||
} /* ecma_builtin_set_prototype_object_foreach */
|
||||
|
||||
/**
|
||||
@@ -116,7 +112,7 @@ 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, true);
|
||||
return ecma_op_container_has (this_arg, value_arg, LIT_MAGIC_STRING_SET_UL);
|
||||
} /* ecma_builtin_set_prototype_object_has */
|
||||
|
||||
/**
|
||||
@@ -131,13 +127,73 @@ ecma_builtin_set_prototype_object_has (ecma_value_t this_arg, /**< this argument
|
||||
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, true);
|
||||
return ecma_op_container_size (this_arg, LIT_MAGIC_STRING_SET_UL);
|
||||
} /* ecma_builtin_set_prototype_object_size_getter */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_ITERATOR)
|
||||
/**
|
||||
* The Set.prototype object's 'entries' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.2.3.5
|
||||
*
|
||||
* @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 */
|
||||
{
|
||||
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 */
|
||||
|
||||
/**
|
||||
* 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_ES2015_BUILTIN_ITERATOR) */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_MAP) */
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SET) */
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
/* ECMA-262 v6, 23.2.3.2 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_MAP,
|
||||
ECMA_BUILTIN_ID_SET,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_SYMBOL)
|
||||
@@ -43,6 +43,12 @@ 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)
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_ITERATOR)
|
||||
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)
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_ITERATOR) */
|
||||
|
||||
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_SIZE,
|
||||
ecma_builtin_set_prototype_object_size_getter,
|
||||
|
||||
@@ -59,7 +59,10 @@ ecma_value_t
|
||||
ecma_builtin_set_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
return ecma_op_container_create (arguments_list_p, arguments_list_len, true);
|
||||
return ecma_op_container_create (arguments_list_p,
|
||||
arguments_list_len,
|
||||
LIT_MAGIC_STRING_SET_UL,
|
||||
ECMA_BUILTIN_ID_SET_PROTOTYPE);
|
||||
} /* ecma_builtin_set_dispatch_construct */
|
||||
|
||||
/**
|
||||
|
||||
@@ -497,6 +497,24 @@ BUILTIN (ECMA_BUILTIN_ID_STRING_ITERATOR_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_ITERATOR_PROTOTYPE,
|
||||
true,
|
||||
string_iterator_prototype)
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_SET)
|
||||
/* The %SetIteratorPrototype% object (ECMA-262 v6, 23.2.5.2) */
|
||||
BUILTIN (ECMA_BUILTIN_ID_SET_ITERATOR_PROTOTYPE,
|
||||
ECMA_OBJECT_TYPE_GENERAL,
|
||||
ECMA_BUILTIN_ID_ITERATOR_PROTOTYPE,
|
||||
true,
|
||||
set_iterator_prototype)
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SET) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_MAP)
|
||||
/* The %MapIteratorPrototype% object (ECMA-262 v6, 23.1.5.2) */
|
||||
BUILTIN (ECMA_BUILTIN_ID_MAP_ITERATOR_PROTOTYPE,
|
||||
ECMA_OBJECT_TYPE_GENERAL,
|
||||
ECMA_BUILTIN_ID_ITERATOR_PROTOTYPE,
|
||||
true,
|
||||
map_iterator_prototype)
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SET) */
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_ITERATOR) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_DATAVIEW)
|
||||
|
||||
Reference in New Issue
Block a user