Implement the core of the map object. (#2447)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
committed by
Robert Sipka
parent
65e81f3262
commit
d3d42f7685
@@ -191,12 +191,20 @@ OBJECT_VALUE (LIT_MAGIC_STRING_UINT8_CLAMPED_ARRAY_UL,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
#endif /* !CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_PROMISE_BUILTIN
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROMISE_UL,
|
||||
ECMA_BUILTIN_ID_PROMISE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* !CONFIG_DISABLE_ES2015_PROMISE_BUILTIN */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_MAP_BUILTIN
|
||||
/* ECMA-262 v6, 23.1.1.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_MAP_UL,
|
||||
ECMA_BUILTIN_ID_MAP,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* !CONFIG_DISABLE_ES2015_MAP_BUILTIN */
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
/* 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-map-object.h"
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_MAP_BUILTIN
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#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"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmabuiltins
|
||||
* @{
|
||||
*
|
||||
* \addtogroup map ECMA Map object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Map.prototype object's 'clear' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 23.1.3.1
|
||||
*
|
||||
* @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 */
|
||||
{
|
||||
return ecma_op_map_clear (this_arg);
|
||||
} /* 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_map_delete (this_arg, key_arg);
|
||||
} /* ecma_builtin_map_prototype_object_delete */
|
||||
|
||||
/**
|
||||
* 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_map_get (this_arg, key_arg);
|
||||
} /* 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_map_has (this_arg, key_arg);
|
||||
} /* 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_map_set (this_arg, key_arg, value_arg);
|
||||
} /* 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_map_size (this_arg);
|
||||
} /* ecma_builtin_map_prototype_object_size_getter */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !CONFIG_DISABLE_ES2015_MAP_BUILTIN */
|
||||
@@ -0,0 +1,52 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Map.prototype built-in description
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_MAP_BUILTIN
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v6, 23.1.3.2 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_MAP,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v6, 23.1.3 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_MAP_UL,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* 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_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)
|
||||
|
||||
/* ECMA-262 v6, 23.1.3.10 */
|
||||
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_SIZE,
|
||||
ecma_builtin_map_prototype_object_size_getter,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
|
||||
#endif /* !CONFIG_DISABLE_ES2015_MAP_BUILTIN */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
@@ -0,0 +1,71 @@
|
||||
/* 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-builtins.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-map-object.h"
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_MAP_BUILTIN
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-map.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID map
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmabuiltins
|
||||
* @{
|
||||
*
|
||||
* \addtogroup map ECMA Map object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handle calling [[Call]] of built-in Map object
|
||||
*
|
||||
* @return ecma value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_map_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor Map requires 'new'."));
|
||||
} /* ecma_builtin_map_dispatch_call */
|
||||
|
||||
/**
|
||||
* Handle calling [[Construct]] of built-in Map object
|
||||
*
|
||||
* @return ecma value
|
||||
*/
|
||||
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_map_create (arguments_list_p, arguments_list_len);
|
||||
} /* ecma_builtin_map_dispatch_construct */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !CONFIG_DISABLE_ES2015_MAP_BUILTIN */
|
||||
@@ -0,0 +1,42 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Map built-in description
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_MAP_BUILTIN
|
||||
|
||||
/* Number properties:
|
||||
* (property name, number value, writable, enumerable, configurable) */
|
||||
|
||||
/* ECMA-262 v6, 23.1.2 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
0,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v6, 23.1.2.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_MAP_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
|
||||
#endif /* !CONFIG_DISABLE_ES2015_MAP_BUILTIN */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
@@ -423,6 +423,24 @@ BUILTIN_ROUTINE (ECMA_BUILTIN_ID_PROMISE,
|
||||
|
||||
#endif /* !CONFIG_DISABLE_ES2015_PROMISE_BUILTIN */
|
||||
|
||||
#ifndef CONFIG_DISABLE_ES2015_MAP_BUILTIN
|
||||
|
||||
/* The Map prototype object (23.1.3) */
|
||||
BUILTIN (ECMA_BUILTIN_ID_MAP_PROTOTYPE,
|
||||
ECMA_OBJECT_TYPE_GENERAL,
|
||||
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
|
||||
true,
|
||||
map_prototype)
|
||||
|
||||
/* The Map routine (ECMA-262 v6, 23.1.1.1) */
|
||||
BUILTIN_ROUTINE (ECMA_BUILTIN_ID_MAP,
|
||||
ECMA_OBJECT_TYPE_FUNCTION,
|
||||
ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
|
||||
true,
|
||||
map)
|
||||
|
||||
#endif /* !CONFIG_DISABLE_ES2015_MAP_BUILTIN */
|
||||
|
||||
/* The Global object (15.1) */
|
||||
BUILTIN (ECMA_BUILTIN_ID_GLOBAL,
|
||||
ECMA_OBJECT_TYPE_GENERAL,
|
||||
|
||||
Reference in New Issue
Block a user