Split globalThis to be configurable. (#4575)
JERRY_BUILTIN_GLOBAL_THIS can be enabled without JERRY_ESNEXT JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
This commit is contained in:
@@ -1446,6 +1446,9 @@ jerry_is_feature_enabled (const jerry_feature_t feature) /**< feature to check *
|
|||||||
#if JERRY_LOGGING
|
#if JERRY_LOGGING
|
||||||
|| feature == JERRY_FEATURE_LOGGING
|
|| feature == JERRY_FEATURE_LOGGING
|
||||||
#endif /* JERRY_LOGGING */
|
#endif /* JERRY_LOGGING */
|
||||||
|
#if JERRY_BUILTIN_GLOBAL_THIS
|
||||||
|
|| feature == JERRY_FEATURE_GLOBAL_THIS
|
||||||
|
#endif /* JERRY_BUILTIN_GLOBAL_THIS */
|
||||||
#if JERRY_BUILTIN_MAP
|
#if JERRY_BUILTIN_MAP
|
||||||
|| feature == JERRY_FEATURE_MAP
|
|| feature == JERRY_FEATURE_MAP
|
||||||
#endif /* JERRY_BUILTIN_MAP */
|
#endif /* JERRY_BUILTIN_MAP */
|
||||||
|
|||||||
@@ -87,6 +87,10 @@
|
|||||||
# define JERRY_BUILTIN_DATAVIEW JERRY_ESNEXT
|
# define JERRY_BUILTIN_DATAVIEW JERRY_ESNEXT
|
||||||
#endif /* !defined (JERRY_BUILTIN_DATAVIEW) */
|
#endif /* !defined (JERRY_BUILTIN_DATAVIEW) */
|
||||||
|
|
||||||
|
#ifndef JERRY_BUILTIN_GLOBAL_THIS
|
||||||
|
# define JERRY_BUILTIN_GLOBAL_THIS JERRY_ESNEXT
|
||||||
|
#endif /* !defined (JERRY_BUILTIN_GLOBAL_THIS) */
|
||||||
|
|
||||||
#ifndef JERRY_BUILTIN_MAP
|
#ifndef JERRY_BUILTIN_MAP
|
||||||
# define JERRY_BUILTIN_MAP JERRY_ESNEXT
|
# define JERRY_BUILTIN_MAP JERRY_ESNEXT
|
||||||
#endif /* !defined (JERRY_BUILTIN_MAP) */
|
#endif /* !defined (JERRY_BUILTIN_MAP) */
|
||||||
@@ -535,6 +539,10 @@
|
|||||||
|| ((JERRY_BUILTIN_DATAVIEW != 0) && (JERRY_BUILTIN_DATAVIEW != 1))
|
|| ((JERRY_BUILTIN_DATAVIEW != 0) && (JERRY_BUILTIN_DATAVIEW != 1))
|
||||||
# error "Invalid value for JERRY_BUILTIN_DATAVIEW macro."
|
# error "Invalid value for JERRY_BUILTIN_DATAVIEW macro."
|
||||||
#endif
|
#endif
|
||||||
|
#if !defined (JERRY_BUILTIN_GLOBAL_THIS) \
|
||||||
|
|| ((JERRY_BUILTIN_GLOBAL_THIS != 0) && (JERRY_BUILTIN_GLOBAL_THIS != 1))
|
||||||
|
# error "Invalid value for JERRY_BUILTIN_GLOBAL_THIS macro."
|
||||||
|
#endif /* !defined (JERRY_BUILTIN_GLOBAL_THIS) */
|
||||||
#if !defined (JERRY_BUILTIN_MAP) \
|
#if !defined (JERRY_BUILTIN_MAP) \
|
||||||
|| ((JERRY_BUILTIN_MAP != 0) && (JERRY_BUILTIN_MAP != 1))
|
|| ((JERRY_BUILTIN_MAP != 0) && (JERRY_BUILTIN_MAP != 1))
|
||||||
# error "Invalid value for JERRY_BUILTIN_MAP macro."
|
# error "Invalid value for JERRY_BUILTIN_MAP macro."
|
||||||
|
|||||||
@@ -220,8 +220,10 @@ enum
|
|||||||
#if JERRY_ESNEXT
|
#if JERRY_ESNEXT
|
||||||
ECMA_VALUE_SYNC_ITERATOR = ECMA_MAKE_VALUE (13), /**< option for ecma_op_get_iterator: sync iterator is requested */
|
ECMA_VALUE_SYNC_ITERATOR = ECMA_MAKE_VALUE (13), /**< option for ecma_op_get_iterator: sync iterator is requested */
|
||||||
ECMA_VALUE_ASYNC_ITERATOR = ECMA_MAKE_VALUE (14), /**< option for ecma_op_get_iterator: async iterator is requested */
|
ECMA_VALUE_ASYNC_ITERATOR = ECMA_MAKE_VALUE (14), /**< option for ecma_op_get_iterator: async iterator is requested */
|
||||||
ECMA_VALUE_GLOBAL_THIS = ECMA_MAKE_VALUE (15), /**< globalThis built-in */
|
|
||||||
#endif /* JERRY_ESNEXT */
|
#endif /* JERRY_ESNEXT */
|
||||||
|
#if JERRY_BUILTIN_GLOBAL_THIS
|
||||||
|
ECMA_VALUE_GLOBAL_THIS = ECMA_MAKE_VALUE (15), /**< globalThis built-in */
|
||||||
|
#endif /* JERRY_BUILTIN_GLOBAL_THIS */
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !JERRY_NUMBER_TYPE_FLOAT64
|
#if !JERRY_NUMBER_TYPE_FLOAT64
|
||||||
|
|||||||
@@ -247,12 +247,14 @@ OBJECT_VALUE (LIT_MAGIC_STRING_WEAKSET_UL,
|
|||||||
OBJECT_VALUE (LIT_MAGIC_STRING_SYMBOL_UL,
|
OBJECT_VALUE (LIT_MAGIC_STRING_SYMBOL_UL,
|
||||||
ECMA_BUILTIN_ID_SYMBOL,
|
ECMA_BUILTIN_ID_SYMBOL,
|
||||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||||
|
#endif /* JERRY_ESNEXT */
|
||||||
|
|
||||||
|
#if JERRY_BUILTIN_GLOBAL_THIS
|
||||||
/* ECMA-262 v11, 18.1.1 */
|
/* ECMA-262 v11, 18.1.1 */
|
||||||
SIMPLE_VALUE (LIT_MAGIC_STRING_GLOBAL_THIS_UL,
|
SIMPLE_VALUE (LIT_MAGIC_STRING_GLOBAL_THIS_UL,
|
||||||
ECMA_VALUE_GLOBAL_THIS,
|
ECMA_VALUE_GLOBAL_THIS,
|
||||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||||
#endif /* JERRY_ESNEXT */
|
#endif /* JERRY_BUILTIN_GLOBAL_THIS */
|
||||||
|
|
||||||
#if JERRY_BUILTIN_DATAVIEW
|
#if JERRY_BUILTIN_DATAVIEW
|
||||||
/* ECMA-262 v6, 23.1.1.1 */
|
/* ECMA-262 v6, 23.1.1.1 */
|
||||||
|
|||||||
@@ -1080,7 +1080,7 @@ ecma_builtin_try_to_instantiate_property (ecma_object_t *object_p, /**< object *
|
|||||||
{
|
{
|
||||||
value = curr_property_p->value;
|
value = curr_property_p->value;
|
||||||
|
|
||||||
#if JERRY_ESNEXT
|
#if JERRY_BUILTIN_GLOBAL_THIS
|
||||||
if (value == ECMA_VALUE_GLOBAL_THIS)
|
if (value == ECMA_VALUE_GLOBAL_THIS)
|
||||||
{
|
{
|
||||||
/* Only the global object has globalThis property. */
|
/* Only the global object has globalThis property. */
|
||||||
@@ -1088,7 +1088,7 @@ ecma_builtin_try_to_instantiate_property (ecma_object_t *object_p, /**< object *
|
|||||||
ecma_ref_object (object_p);
|
ecma_ref_object (object_p);
|
||||||
value = ecma_make_object_value (object_p);
|
value = ecma_make_object_value (object_p);
|
||||||
}
|
}
|
||||||
#endif /* JERRY_ESNEXT */
|
#endif /* JERRY_BUILTIN_GLOBAL_THIS */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ECMA_BUILTIN_PROPERTY_NUMBER:
|
case ECMA_BUILTIN_PROPERTY_NUMBER:
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ typedef enum
|
|||||||
JERRY_FEATURE_WEAKSET, /**< WeakSet support */
|
JERRY_FEATURE_WEAKSET, /**< WeakSet support */
|
||||||
JERRY_FEATURE_BIGINT, /**< BigInt support */
|
JERRY_FEATURE_BIGINT, /**< BigInt support */
|
||||||
JERRY_FEATURE_REALM, /**< realm support */
|
JERRY_FEATURE_REALM, /**< realm support */
|
||||||
|
JERRY_FEATURE_GLOBAL_THIS, /**< GlobalThisValue support */
|
||||||
JERRY_FEATURE__COUNT /**< number of features. NOTE: must be at the end of the list */
|
JERRY_FEATURE__COUNT /**< number of features. NOTE: must be at the end of the list */
|
||||||
} jerry_feature_t;
|
} jerry_feature_t;
|
||||||
|
|
||||||
|
|||||||
@@ -727,7 +727,7 @@ LIT_MAGIC_STRING_DEF (LIT_MAGIC_STRING_GET_MINUTES_UL, "getMinutes")
|
|||||||
LIT_MAGIC_STRING_DEF (LIT_MAGIC_STRING_GET_SECONDS_UL, "getSeconds")
|
LIT_MAGIC_STRING_DEF (LIT_MAGIC_STRING_GET_SECONDS_UL, "getSeconds")
|
||||||
LIT_MAGIC_STRING_DEF (LIT_MAGIC_STRING_GET_UTC_DATE_UL, "getUTCDate")
|
LIT_MAGIC_STRING_DEF (LIT_MAGIC_STRING_GET_UTC_DATE_UL, "getUTCDate")
|
||||||
#endif
|
#endif
|
||||||
#if JERRY_ESNEXT
|
#if JERRY_BUILTIN_GLOBAL_THIS
|
||||||
LIT_MAGIC_STRING_DEF (LIT_MAGIC_STRING_GLOBAL_THIS_UL, "globalThis")
|
LIT_MAGIC_STRING_DEF (LIT_MAGIC_STRING_GLOBAL_THIS_UL, "globalThis")
|
||||||
#endif
|
#endif
|
||||||
#if !JERRY_ESNEXT && JERRY_BUILTIN_REGEXP \
|
#if !JERRY_ESNEXT && JERRY_BUILTIN_REGEXP \
|
||||||
|
|||||||
@@ -102,6 +102,8 @@ defined to `1`.
|
|||||||
Enables or disables the [BigInt](https://262.ecma-international.org/11.0/#sec-ecmascript-language-types-bigint-type) syntax and built-in.
|
Enables or disables the [BigInt](https://262.ecma-international.org/11.0/#sec-ecmascript-language-types-bigint-type) syntax and built-in.
|
||||||
* `JERRY_BUILTIN_DATAVIEW`:
|
* `JERRY_BUILTIN_DATAVIEW`:
|
||||||
Enables or disables the [DataView](https://www.ecma-international.org/ecma-262/6.0/#sec-dataview-objects) built-in.
|
Enables or disables the [DataView](https://www.ecma-international.org/ecma-262/6.0/#sec-dataview-objects) built-in.
|
||||||
|
* `JERRY_BUILTIN_GLOBAL_THIS`:
|
||||||
|
Enables or disables the [GlobalThisValue](https://262.ecma-international.org/11.0/#sec-globalthis) built-in.
|
||||||
* `JERRY_BUILTIN_MAP`:
|
* `JERRY_BUILTIN_MAP`:
|
||||||
Enables or disables the [Map](http://www.ecma-international.org/ecma-262/6.0/#sec-keyed-collection) built-ins.
|
Enables or disables the [Map](http://www.ecma-international.org/ecma-262/6.0/#sec-keyed-collection) built-ins.
|
||||||
* `JERRY_BUILTIN_PROMISE`:
|
* `JERRY_BUILTIN_PROMISE`:
|
||||||
@@ -147,6 +149,7 @@ defined to `1`.
|
|||||||
Equivalent with setting the following defines to the `JERRY_ESNEXT` value:
|
Equivalent with setting the following defines to the `JERRY_ESNEXT` value:
|
||||||
* `JERRY_BUILTIN_BIGINT`
|
* `JERRY_BUILTIN_BIGINT`
|
||||||
* `JERRY_BUILTIN_DATAVIEW`
|
* `JERRY_BUILTIN_DATAVIEW`
|
||||||
|
* `JERRY_BUILTIN_GLOBAL_THIS`
|
||||||
* `JERRY_BUILTIN_MAP`
|
* `JERRY_BUILTIN_MAP`
|
||||||
* `JERRY_BUILTIN_PROMISE`
|
* `JERRY_BUILTIN_PROMISE`
|
||||||
* `JERRY_BUILTIN_PROXY`
|
* `JERRY_BUILTIN_PROXY`
|
||||||
|
|||||||
Reference in New Issue
Block a user