Skip to content

Commit 70e275e

Browse files
authored
Implement ECMAScript 2022 private class methods and fields (jerryscript-project#4831)
Co-authored-by: Robert Fancsik [email protected] Co-authored-by: Martin Negyokru [email protected] JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi [email protected]
1 parent 841e21a commit 70e275e

35 files changed

+2194
-4339
lines changed

jerry-core/ecma/base/ecma-error-messages.inc.h

+20
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,9 @@ ECMA_ERROR_DEF (ECMA_ERR_MODULE_MUST_BE_IN_LINKED_STATE, "Module must be in link
298298
ECMA_ERROR_DEF (ECMA_ERR_UNKNOWN_EXPORT, "Native module export not found")
299299
#endif /* JERRY_MODULE_SYSTEM */
300300
ECMA_ERROR_DEF (ECMA_ERR_PASSED_ARGUMENT_IS_NOT_A_REALM, "Passed argument is not a realm")
301+
#if JERRY_ESNEXT
302+
ECMA_ERROR_DEF (ECMA_ERR_PRIVATE_METHOD_IS_NOT_WRITABLE, "Private method is not writable")
303+
#endif /* JERRY_ESNEXT */
301304
#if JERRY_BUILTIN_BIGINT || JERRY_BUILTIN_NUMBER
302305
ECMA_ERROR_DEF (ECMA_ERR_RADIX_IS_OUT_OF_RANGE, "Radix must be between 2 and 36")
303306
#endif /* JERRY_BUILTIN_BIGINT \
@@ -548,6 +551,9 @@ ECMA_ERROR_DEF (ECMA_ERR_VALUE_RECEIVED_BY_YIELD_IS_NOT_OBJECT, "Value received
548551
#if JERRY_BUILTIN_BOOLEAN
549552
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_BOOLEAN_OBJECT, "Argument 'this' is not a Boolean object")
550553
#endif /* JERRY_BUILTIN_BOOLEAN */
554+
#if JERRY_ESNEXT
555+
ECMA_ERROR_DEF (ECMA_ERR_CANNOT_DECLARE_SAME_PRIVATE_FIELD_TWICE, "Cannot declare same private field twice")
556+
#endif /* JERRY_ESNEXT */
551557
#if JERRY_BUILTIN_TYPEDARRAY
552558
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_FLOAT32_ARRAY_REQUIRES_NEW, "Constructor Float32Array requires 'new'")
553559
#endif /* JERRY_BUILTIN_TYPEDARRAY */
@@ -608,6 +614,8 @@ ECMA_ERROR_DEF (ECMA_ERR_CANNOT_CONVERT_TO_OBJECT, "Cannot convert undefined or
608614
ECMA_ERROR_DEF (ECMA_ERR_PRECISION_DIGITS_MUST_BE_BETWEEN_IN_RANGE, "Precision digits must be between 1 and 100")
609615
#endif /* JERRY_BUILTIN_NUMBER */
610616
#if JERRY_ESNEXT
617+
ECMA_ERROR_DEF (ECMA_ERR_PRIVATE_FIELD_WAS_DEFINED_WITHOUT_A_GETTER, "Private field was defined without a getter")
618+
ECMA_ERROR_DEF (ECMA_ERR_PRIVATE_FIELD_WAS_DEFINED_WITHOUT_A_SETTER, "Private field was defined without a setter")
611619
ECMA_ERROR_DEF (ECMA_ERR_PROPERTY_NAME_IS_NEITHER_SYMBOL_NOR_STRING, "Property name is neither Symbol nor string")
612620
#endif /* JERRY_ESNEXT */
613621
#if JERRY_BUILTIN_BIGINT
@@ -818,8 +826,20 @@ ECMA_ERROR_DEF (ECMA_ERR_TARGET_NOT_EXTENSIBLE_DIFFERENT_PROTOTYPE_RETURNED,
818826
"Target object is non-extensible and trap returned different prototype")
819827
ECMA_ERROR_DEF (ECMA_ERR_TRAP_TRUISH_ADDING_PROPERTY_NON_EXTENSIBLE_TARGET,
820828
"Trap returned truish for adding property to the non-extensible target")
829+
#endif /* JERRY_BUILTIN_PROXY */
830+
#if JERRY_ESNEXT
831+
ECMA_ERROR_DEF (ECMA_ERR_CANNOT_READ_PRIVATE_MEMBER_TO_AN_OBJECT_WHOSE_CLASS_DID_NOT_DECLARE_IT,
832+
"Cannot read private member to an object whose class did not declare it")
833+
#endif /* JERRY_ESNEXT */
834+
#if JERRY_BUILTIN_PROXY
821835
ECMA_ERROR_DEF (ECMA_ERR_GIVEN_PROPERTY_IS_A_NON_CONFIGURABLE,
822836
"Given property is a non-configurable data property on the proxy target")
837+
#endif /* JERRY_BUILTIN_PROXY */
838+
#if JERRY_ESNEXT
839+
ECMA_ERROR_DEF (ECMA_ERR_CANNOT_WRITE_PRIVATE_MEMBER_TO_AN_OBJECT_WHOSE_CLASS_DID_NOT_DECLARE_IT,
840+
"Cannot write private member to an object whose class did not declare it")
841+
#endif /* JERRY_ESNEXT */
842+
#if JERRY_BUILTIN_PROXY
823843
ECMA_ERROR_DEF (ECMA_ERR_TRAP_FALSISH_PROPERTY_TARGET_NOT_EXTENSIBLE,
824844
"Trap returned falsish for property but the proxy target is not extensible")
825845
ECMA_ERROR_DEF (ECMA_ERR_PROXY_PROPERTY_NOT_CONFIGURABLE_NOT_HAVE_GETTER,

jerry-core/ecma/base/ecma-error-messages.ini

+7-1
Original file line numberDiff line numberDiff line change
@@ -323,4 +323,10 @@ ECMA_ERR_PROXY_TARGET_IS_NOT_A_CONSTRUCTOR = "Proxy target is not a constructor"
323323
ECMA_ERR_MAXIMUM_CALL_STACK_SIZE_EXCEEDED = "Maximum call stack size exceeded"
324324
ECMA_ERR_INVALID_SNAPSHOT_FORMAT = "Invalid snapshot format"
325325
ECMA_ERR_INVALID_SNAPSHOT_VERSION_OR_FEATURES = "Invalid snapshot version or unsupported features present"
326-
ECMA_ERR_RECEIVER_MUST_BE_AN_OBJECT = "Receiver must be an object"
326+
ECMA_ERR_RECEIVER_MUST_BE_AN_OBJECT = "Receiver must be an object"
327+
ECMA_ERR_CANNOT_DECLARE_SAME_PRIVATE_FIELD_TWICE = "Cannot declare same private field twice"
328+
ECMA_ERR_CANNOT_WRITE_PRIVATE_MEMBER_TO_AN_OBJECT_WHOSE_CLASS_DID_NOT_DECLARE_IT = "Cannot write private member to an object whose class did not declare it"
329+
ECMA_ERR_PRIVATE_METHOD_IS_NOT_WRITABLE = "Private method is not writable"
330+
ECMA_ERR_PRIVATE_FIELD_WAS_DEFINED_WITHOUT_A_SETTER = "Private field was defined without a setter"
331+
ECMA_ERR_CANNOT_READ_PRIVATE_MEMBER_TO_AN_OBJECT_WHOSE_CLASS_DID_NOT_DECLARE_IT = "Cannot read private member to an object whose class did not declare it"
332+
ECMA_ERR_PRIVATE_FIELD_WAS_DEFINED_WITHOUT_A_GETTER = "Private field was defined without a getter"

jerry-core/ecma/base/ecma-gc.c

+52-3
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,27 @@ ecma_gc_mark_properties (ecma_object_t *object_p, /**< object */
328328
ecma_gc_set_object_visited (ecma_get_object_from_value (environment_record_p->function_object));
329329
break;
330330
}
331+
case LIT_INTERNAL_MAGIC_STRING_CLASS_PRIVATE_ELEMENTS:
332+
{
333+
ecma_value_t *compact_collection_p;
334+
compact_collection_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_value_t, property_pair_p->values[index].value);
335+
336+
ecma_value_t *end_p = ecma_compact_collection_end (compact_collection_p);
337+
ecma_value_t *current_p = compact_collection_p + 1;
338+
339+
while (end_p - current_p >= ECMA_PRIVATE_ELEMENT_LIST_SIZE)
340+
{
341+
current_p++; /* skip the type */
342+
current_p++; /* skip the name */
343+
ecma_value_t value = *current_p++;
344+
345+
if (!ecma_is_value_undefined (value))
346+
{
347+
ecma_gc_set_object_visited (ecma_get_object_from_value (value));
348+
}
349+
}
350+
break;
351+
}
331352
#endif /* JERRY_ESNEXT */
332353
#if JERRY_BUILTIN_CONTAINER
333354
case LIT_INTERNAL_MAGIC_STRING_WEAK_REFS:
@@ -816,8 +837,12 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
816837
#if JERRY_MODULE_SYSTEM
817838
if (object_p->type_flags_refs & ECMA_OBJECT_FLAG_LEXICAL_ENV_HAS_DATA)
818839
{
819-
ecma_gc_mark_properties (object_p, true);
820-
ecma_gc_set_object_visited (((ecma_lexical_environment_class_t *) object_p)->module_p);
840+
if (ECMA_LEX_ENV_CLASS_IS_MODULE (object_p))
841+
{
842+
ecma_gc_mark_properties (object_p, true);
843+
}
844+
845+
ecma_gc_set_object_visited (((ecma_lexical_environment_class_t *) object_p)->object_p);
821846
return;
822847
}
823848
#endif /* JERRY_MODULE_SYSTEM */
@@ -1591,6 +1616,26 @@ ecma_gc_free_property (ecma_object_t *object_p, /**< object */
15911616
ecma_compact_collection_free (compact_collection_p);
15921617
break;
15931618
}
1619+
case LIT_INTERNAL_MAGIC_STRING_CLASS_PRIVATE_ELEMENTS:
1620+
{
1621+
ecma_value_t *compact_collection_p;
1622+
compact_collection_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_value_t, value);
1623+
1624+
ecma_value_t *end_p = ecma_compact_collection_end (compact_collection_p);
1625+
ecma_value_t *current_p = compact_collection_p + 1;
1626+
1627+
JERRY_ASSERT ((end_p - current_p) % ECMA_PRIVATE_ELEMENT_LIST_SIZE == 0);
1628+
1629+
while (current_p < end_p)
1630+
{
1631+
current_p++; /* skip the type */
1632+
ecma_deref_ecma_string (ecma_get_prop_name_from_value (*current_p++));
1633+
current_p++; /* skip the value */
1634+
}
1635+
1636+
ecma_compact_collection_destroy (compact_collection_p);
1637+
break;
1638+
}
15941639
#endif /* JERRY_ESNEXT */
15951640
#if JERRY_BUILTIN_WEAKREF || JERRY_BUILTIN_CONTAINER
15961641
case LIT_INTERNAL_MAGIC_STRING_WEAK_REFS:
@@ -1684,7 +1729,11 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
16841729
if (ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_CLASS
16851730
&& (object_p->type_flags_refs & ECMA_OBJECT_FLAG_LEXICAL_ENV_HAS_DATA))
16861731
{
1687-
ecma_gc_free_properties (object_p, ECMA_GC_FREE_REFERENCES);
1732+
if (ECMA_LEX_ENV_CLASS_IS_MODULE (object_p))
1733+
{
1734+
ecma_gc_free_properties (object_p, ECMA_GC_FREE_REFERENCES);
1735+
}
1736+
16881737
ecma_dealloc_extended_object (object_p, sizeof (ecma_lexical_environment_class_t));
16891738
return;
16901739
}

jerry-core/ecma/base/ecma-globals.h

+58-14
Original file line numberDiff line numberDiff line change
@@ -1184,16 +1184,32 @@ typedef struct
11841184
ecma_built_in_props_t built_in; /**< built-in object part */
11851185
} ecma_extended_built_in_object_t;
11861186

1187+
/**
1188+
* Type of lexical environment with class
1189+
*/
1190+
typedef enum
1191+
{
1192+
ECMA_LEX_ENV_CLASS_TYPE_MODULE, /**< module object reference */
1193+
ECMA_LEX_ENV_CLASS_TYPE_CLASS_ENV, /**< class constructor object reference */
1194+
} ecma_lexical_environment_class_type_t;
1195+
11871196
/**
11881197
* Description of lexical environment with class
11891198
*/
11901199
typedef struct
11911200
{
11921201
ecma_object_t lexical_env; /**< lexical environment header */
1193-
1194-
ecma_object_t *module_p; /**< module reference */
1202+
uint32_t type; /**< element of ecma_lexical_environment_class_type_t */
1203+
ecma_object_t *object_p; /**< object reference */
11951204
} ecma_lexical_environment_class_t;
11961205

1206+
/**
1207+
* Check whether the given lexical class environment is a module
1208+
*/
1209+
#define ECMA_LEX_ENV_CLASS_IS_MODULE(lex_env_p) \
1210+
(((lex_env_p)->type_flags_refs & ECMA_OBJECT_FLAG_LEXICAL_ENV_HAS_DATA) \
1211+
&& ((ecma_lexical_environment_class_t *) (lex_env_p))->type == ECMA_LEX_ENV_CLASS_TYPE_MODULE)
1212+
11971213
/**
11981214
* Description of native functions
11991215
*/
@@ -1892,6 +1908,13 @@ typedef struct
18921908
} u;
18931909
} ecma_extended_string_t;
18941910

1911+
#if JERRY_ESNEXT
1912+
/**
1913+
* Required number of ecma values in a compact collection to represent PrivateElement
1914+
*/
1915+
#define ECMA_PRIVATE_ELEMENT_LIST_SIZE 3
1916+
#endif /* JERRY_ESNEXT */
1917+
18951918
/**
18961919
* String builder header
18971920
*/
@@ -2248,24 +2271,23 @@ typedef struct
22482271
} ecma_dataview_object_t;
22492272
#endif /* JERRY_BUILTIN_DATAVIEW */
22502273

2251-
/**
2252-
* Flag for indicating whether the symbol is a well known symbol
2253-
*
2254-
* See also: 6.1.5.1
2255-
*/
2256-
#define ECMA_GLOBAL_SYMBOL_FLAG 0x01
2274+
typedef enum
2275+
{
2276+
ECMA_SYMBOL_FLAG_NONE = 0, /**< no options */
2277+
ECMA_SYMBOL_FLAG_GLOBAL = (1 << 0), /**< symbol is a well known symbol, See also: 6.1.5.1 */
2278+
ECMA_SYMBOL_FLAG_PRIVATE_KEY = (1 << 1), /**< symbol is a private field */
2279+
ECMA_SYMBOL_FLAG_PRIVATE_INSTANCE_METHOD = (1 << 2), /**< symbol is a private method or accessor */
2280+
} ecma_symbol_flags_t;
22572281

22582282
/**
2259-
* Bitshift index for indicating whether the symbol is a well known symbol
2260-
*
2261-
* See also: 6.1.5.1
2283+
* Bitshift index for the symbol hash property
22622284
*/
2263-
#define ECMA_GLOBAL_SYMBOL_SHIFT 1
2285+
#define ECMA_SYMBOL_FLAGS_SHIFT 3
22642286

22652287
/**
2266-
* Bitshift index for the symbol hash property
2288+
* Bitmask for symbol hash flags
22672289
*/
2268-
#define ECMA_SYMBOL_HASH_SHIFT 2
2290+
#define ECMA_SYMBOL_FLAGS_MASK ((1 << ECMA_SYMBOL_FLAGS_SHIFT) - 1)
22692291

22702292
#if (JERRY_STACK_LIMIT != 0)
22712293
/**
@@ -2481,6 +2503,28 @@ typedef struct
24812503
ecma_extended_object_t header; /**< header part */
24822504
ecma_value_t sync_next_method; /**< IteratorRecord [[NextMethod]] internal slot */
24832505
} ecma_async_from_sync_iterator_object_t;
2506+
2507+
/**
2508+
* Private method kind
2509+
*/
2510+
typedef enum
2511+
{
2512+
ECMA_PRIVATE_FIELD = 0, /**< private field */
2513+
ECMA_PRIVATE_METHOD, /**< private method */
2514+
ECMA_PRIVATE_GETTER, /**< private setter */
2515+
ECMA_PRIVATE_SETTER, /**< private getter */
2516+
} ecma_private_property_kind_t;
2517+
2518+
/**
2519+
* Private static property flag
2520+
*/
2521+
#define ECMA_PRIVATE_PROPERTY_STATIC_FLAG (1 << 2)
2522+
2523+
/*
2524+
* Get private property kind from a descriptor
2525+
*/
2526+
#define ECMA_PRIVATE_PROPERTY_KIND(prop) ((prop) & ((ECMA_PRIVATE_PROPERTY_STATIC_FLAG - 1)))
2527+
24842528
#endif /* JERRY_ESNEXT */
24852529

24862530
/**

jerry-core/ecma/base/ecma-helpers-collection.c

+25
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,31 @@ ecma_compact_collection_free (ecma_value_t *compact_collection_p) /**< compact c
417417
jmem_heap_free_block (compact_collection_p, size * sizeof (ecma_value_t));
418418
} /* ecma_compact_collection_free */
419419

420+
/**
421+
* Get the end of a compact collection
422+
*
423+
* @return pointer to the compact collection end
424+
*/
425+
ecma_value_t *
426+
ecma_compact_collection_end (ecma_value_t *compact_collection_p) /**< compact collection */
427+
{
428+
ecma_value_t size = ECMA_COMPACT_COLLECTION_GET_SIZE (compact_collection_p);
429+
ecma_value_t unused_items = ECMA_COMPACT_COLLECTION_GET_UNUSED_ITEM_COUNT (compact_collection_p);
430+
431+
return compact_collection_p + size - unused_items;
432+
} /* ecma_compact_collection_end */
433+
434+
/**
435+
* Destroy a compact collection
436+
*/
437+
void
438+
ecma_compact_collection_destroy (ecma_value_t *compact_collection_p) /**< compact collection */
439+
{
440+
ecma_value_t size = ECMA_COMPACT_COLLECTION_GET_SIZE (compact_collection_p);
441+
442+
jmem_heap_free_block (compact_collection_p, size * sizeof (ecma_value_t));
443+
} /* ecma_compact_collection_destroy */
444+
420445
/**
421446
* @}
422447
* @}

jerry-core/ecma/base/ecma-helpers-string.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,7 @@ ecma_new_symbol_from_descriptor_string (ecma_value_t string_desc) /**< ecma-stri
221221
ecma_extended_string_t *symbol_p = ecma_alloc_extended_string ();
222222
symbol_p->header.refs_and_container = ECMA_STRING_REF_ONE | ECMA_STRING_CONTAINER_SYMBOL;
223223
symbol_p->u.symbol_descriptor = string_desc;
224-
symbol_p->header.u.hash = (lit_string_hash_t) (((uintptr_t) symbol_p) >> ECMA_SYMBOL_HASH_SHIFT);
225-
JERRY_ASSERT ((symbol_p->header.u.hash & ECMA_GLOBAL_SYMBOL_FLAG) == 0);
224+
symbol_p->header.u.hash = (lit_string_hash_t) (((uintptr_t) symbol_p) & (uintptr_t) ~ECMA_SYMBOL_FLAGS_MASK);
226225

227226
return (ecma_string_t *) symbol_p;
228227
} /* ecma_new_symbol_from_descriptor_string */

jerry-core/ecma/base/ecma-helpers.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ ecma_get_lex_env_binding_object (const ecma_object_t *object_p) /**< object-boun
306306
#if JERRY_ESNEXT
307307
JERRY_ASSERT (ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND
308308
|| (ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_CLASS
309-
&& (object_p->type_flags_refs & ECMA_OBJECT_FLAG_LEXICAL_ENV_HAS_DATA) == 0));
309+
&& !ECMA_LEX_ENV_CLASS_IS_MODULE (object_p)));
310310
#else /* !JERRY_ESNEXT */
311311
JERRY_ASSERT (ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
312312
#endif /* JERRY_ESNEXT */
@@ -593,7 +593,7 @@ ecma_create_named_reference_property (ecma_object_t *object_p, /**< object */
593593
JERRY_ASSERT (ecma_find_named_property (object_p, name_p) == NULL);
594594
JERRY_ASSERT ((ecma_is_lexical_environment (object_p)
595595
&& ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_CLASS
596-
&& (object_p->type_flags_refs & ECMA_OBJECT_FLAG_LEXICAL_ENV_HAS_DATA))
596+
&& ECMA_LEX_ENV_CLASS_IS_MODULE (object_p))
597597
|| ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_MODULE_NAMESPACE));
598598

599599
uint8_t type_and_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE;

jerry-core/ecma/base/ecma-helpers.h

+2
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,8 @@ ecma_value_t *ecma_new_compact_collection (void);
434434
ecma_value_t *ecma_compact_collection_push_back (ecma_value_t *compact_collection_p, ecma_value_t value);
435435
ecma_value_t *ecma_compact_collection_shrink (ecma_value_t *compact_collection_p);
436436
void ecma_compact_collection_free (ecma_value_t *compact_collection_p);
437+
ecma_value_t *ecma_compact_collection_end (ecma_value_t *compact_collection_p);
438+
void ecma_compact_collection_destroy (ecma_value_t *compact_collection_p);
437439

438440
/* ecma-helpers.c */
439441
ecma_object_t *ecma_create_object (ecma_object_t *prototype_object_p, size_t ext_object_size, ecma_object_type_t type);

jerry-core/ecma/builtin-objects/ecma-builtins.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -937,9 +937,9 @@ ecma_builtin_try_to_instantiate_property (ecma_object_t *object_p, /**< object *
937937
lit_magic_string_id_t magic_string_id = ecma_get_string_magic (property_name_p);
938938

939939
#if JERRY_ESNEXT
940-
if (JERRY_UNLIKELY (ecma_prop_name_is_symbol (property_name_p)) && property_name_p->u.hash & ECMA_GLOBAL_SYMBOL_FLAG)
940+
if (JERRY_UNLIKELY (ecma_prop_name_is_symbol (property_name_p)) && property_name_p->u.hash & ECMA_SYMBOL_FLAG_GLOBAL)
941941
{
942-
magic_string_id = (property_name_p->u.hash >> ECMA_GLOBAL_SYMBOL_SHIFT);
942+
magic_string_id = (property_name_p->u.hash >> ECMA_SYMBOL_FLAGS_SHIFT);
943943
}
944944
#endif /* JERRY_ESNEXT */
945945

@@ -1254,9 +1254,9 @@ ecma_builtin_delete_built_in_property (ecma_object_t *object_p, /**< object */
12541254
#if JERRY_ESNEXT
12551255
if (JERRY_UNLIKELY (ecma_prop_name_is_symbol (property_name_p)))
12561256
{
1257-
if (property_name_p->u.hash & ECMA_GLOBAL_SYMBOL_FLAG)
1257+
if (property_name_p->u.hash & ECMA_SYMBOL_FLAG_GLOBAL)
12581258
{
1259-
magic_string_id = (property_name_p->u.hash >> ECMA_GLOBAL_SYMBOL_SHIFT);
1259+
magic_string_id = (property_name_p->u.hash >> ECMA_SYMBOL_FLAGS_SHIFT);
12601260
}
12611261
}
12621262
#endif /* JERRY_ESNEXT */

jerry-core/ecma/operations/ecma-get-put-value.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ ecma_op_get_value_lex_env_base (ecma_object_t *lex_env_p, /**< lexical environme
7777
case ECMA_LEXICAL_ENVIRONMENT_CLASS:
7878
{
7979
#if JERRY_MODULE_SYSTEM
80-
if (lex_env_p->type_flags_refs & ECMA_OBJECT_FLAG_LEXICAL_ENV_HAS_DATA)
80+
if (ECMA_LEX_ENV_CLASS_IS_MODULE (lex_env_p))
8181
{
8282
ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p);
8383

@@ -237,7 +237,7 @@ ecma_op_put_value_lex_env_base (ecma_object_t *lex_env_p, /**< lexical environme
237237
#if JERRY_ESNEXT
238238
case ECMA_LEXICAL_ENVIRONMENT_CLASS:
239239
{
240-
if ((lex_env_p->type_flags_refs & ECMA_OBJECT_FLAG_LEXICAL_ENV_HAS_DATA) == 0)
240+
if (!ECMA_LEX_ENV_CLASS_IS_MODULE (lex_env_p))
241241
{
242242
break;
243243
}

jerry-core/ecma/operations/ecma-lex-env.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ ecma_op_has_binding (ecma_object_t *lex_env_p, /**< lexical environment */
167167
#if JERRY_ESNEXT
168168
case ECMA_LEXICAL_ENVIRONMENT_CLASS:
169169
{
170-
if ((lex_env_p->type_flags_refs & ECMA_OBJECT_FLAG_LEXICAL_ENV_HAS_DATA) == 0)
170+
if (!ECMA_LEX_ENV_CLASS_IS_MODULE (lex_env_p))
171171
{
172172
return ECMA_VALUE_FALSE;
173173
}
@@ -297,7 +297,7 @@ ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment
297297
#if JERRY_ESNEXT
298298
case ECMA_LEXICAL_ENVIRONMENT_CLASS:
299299
{
300-
if ((lex_env_p->type_flags_refs & ECMA_OBJECT_FLAG_LEXICAL_ENV_HAS_DATA) == 0)
300+
if (!ECMA_LEX_ENV_CLASS_IS_MODULE (lex_env_p))
301301
{
302302
return ECMA_VALUE_EMPTY;
303303
}

0 commit comments

Comments
 (0)