Implement Symbol.unscopables (#3405)

Added a new property for Array.prototype based on ECMA-262 v6, 22.1.3.31
Also upgraded the HasBinding operation with ECMA-262 v6, 8.1.1.2.1 steps 7-9

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
This commit is contained in:
Szilagyi Adam
2019-12-19 16:34:23 +01:00
committed by Robert Fancsik
parent 52616f7d8c
commit 7bfbc701d8
7 changed files with 294 additions and 33 deletions
@@ -0,0 +1,28 @@
/* 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"
#if ENABLED (JERRY_ES2015)
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-array-prototype-unscopables.inc.h"
#define BUILTIN_UNDERSCORED_ID array_prototype_unscopables
#include "ecma-builtin-internal-routines-template.inc.h"
#endif /* ENABLED (JERRY_ES2015) */
@@ -0,0 +1,55 @@
/* 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.
*/
/*
* Array.prototype[@@unscopables] built-in description
*/
#include "ecma-builtin-helpers-macro-defines.inc.h"
#if ENABLED (JERRY_ES2015)
SIMPLE_VALUE (LIT_MAGIC_STRING_COPY_WITHIN,
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_ENTRIES,
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_FILL,
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_FIND,
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_FIND_INDEX,
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_KEYS,
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
SIMPLE_VALUE (LIT_MAGIC_STRING_VALUES,
ECMA_VALUE_TRUE,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
#endif /* ENABLED (JERRY_ES2015) */
#include "ecma-builtin-helpers-macro-undefs.inc.h"
@@ -29,6 +29,13 @@ OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
ECMA_BUILTIN_ID_ARRAY,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
#if ENABLED (JERRY_ES2015)
/* ECMA-262 v6, 22.1.3.31 */
OBJECT_VALUE (LIT_GLOBAL_SYMBOL_UNSCOPABLES,
ECMA_BUILTIN_ID_ARRAY_PROTOTYPE_UNSCOPABLES,
ECMA_PROPERTY_FLAG_CONFIGURABLE)
#endif /* ENABLED (JERRY_ES2015) */
/* Number properties:
* (property name, object pointer getter) */
@@ -510,6 +510,13 @@ BUILTIN_ROUTINE (ECMA_BUILTIN_ID_WEAKSET,
#if ENABLED (JERRY_ES2015)
/* The Array.prototype[@@unscopables] object */
BUILTIN (ECMA_BUILTIN_ID_ARRAY_PROTOTYPE_UNSCOPABLES,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID__COUNT,
true,
array_prototype_unscopables)
/* The Symbol prototype object (ECMA-262 v6, 19.4.2.7) */
BUILTIN (ECMA_BUILTIN_ID_SYMBOL_PROTOTYPE,
ECMA_OBJECT_TYPE_GENERAL,