Create namespace with references for modules (#4646)

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2021-04-12 15:58:56 +02:00
committed by GitHub
parent ef35c0329c
commit b3ec217b50
27 changed files with 1378 additions and 479 deletions
@@ -899,7 +899,7 @@ ecma_delete_array_properties (ecma_object_t *object_p, /**< object */
JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (current_prop_p));
ecma_property_pair_t *prop_pair_p = (ecma_property_pair_t *) current_prop_p;
for (int i = 0; i < ECMA_PROPERTY_PAIR_ITEM_COUNT; i++)
for (uint32_t i = 0; i < ECMA_PROPERTY_PAIR_ITEM_COUNT; i++)
{
if (current_prop_p->types[i] != ECMA_PROPERTY_TYPE_DELETED
&& ecma_is_property_configurable (current_prop_p->types[i]))
@@ -920,7 +920,7 @@ ecma_delete_array_properties (ecma_object_t *object_p, /**< object */
}
#endif /* JERRY_PROPRETY_HASHMAP */
ecma_free_property (object_p, prop_pair_p->names_cp[i], current_prop_p->types + i);
ecma_gc_free_property (object_p, prop_pair_p, i);
current_prop_p->types[i] = ECMA_PROPERTY_TYPE_DELETED;
prop_pair_p->names_cp[i] = LIT_INTERNAL_MAGIC_STRING_DELETED;
}
+52 -34
View File
@@ -67,8 +67,7 @@ ecma_op_get_value_lex_env_base (ecma_object_t *lex_env_p, /**< lexical environme
#if JERRY_ESNEXT
if (JERRY_UNLIKELY (property_value_p->value == ECMA_VALUE_UNINITIALIZED))
{
return ecma_raise_reference_error (ECMA_ERR_MSG ("Variables declared by let/const must be"
" initialized before reading their value"));
return ecma_raise_reference_error (ECMA_ERR_MSG (ecma_error_let_const_not_initialized));
}
#endif /* JERRY_ESNEXT */
@@ -77,8 +76,32 @@ ecma_op_get_value_lex_env_base (ecma_object_t *lex_env_p, /**< lexical environme
break;
}
#if JERRY_ESNEXT
case ECMA_LEXICAL_ENVIRONMENT_HOME_OBJECT_BOUND:
case ECMA_LEXICAL_ENVIRONMENT_CLASS:
{
#if JERRY_MODULE_SYSTEM
if (lex_env_p->type_flags_refs & ECMA_OBJECT_FLAG_LEXICAL_ENV_HAS_DATA)
{
ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p);
if (property_p != NULL)
{
*ref_base_lex_env_p = lex_env_p;
ecma_property_value_t *property_value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
if (!(*property_p & ECMA_PROPERTY_FLAG_DATA))
{
property_value_p = ecma_get_property_value_from_named_reference (property_value_p);
}
if (JERRY_UNLIKELY (property_value_p->value == ECMA_VALUE_UNINITIALIZED))
{
return ecma_raise_reference_error (ECMA_ERR_MSG (ecma_error_let_const_not_initialized));
}
return ecma_fast_copy_value (property_value_p->value);
}
}
#endif /* JERRY_MODULE_SYSTEM */
break;
}
#endif /* JERRY_ESNEXT */
@@ -215,52 +238,47 @@ ecma_op_put_value_lex_env_base (ecma_object_t *lex_env_p, /**< lexical environme
{
switch (ecma_get_lex_env_type (lex_env_p))
{
#if JERRY_ESNEXT
case ECMA_LEXICAL_ENVIRONMENT_CLASS:
{
if ((lex_env_p->type_flags_refs & ECMA_OBJECT_FLAG_LEXICAL_ENV_HAS_DATA) == 0)
{
break;
}
/* FALLTHRU */
}
#endif /* JERRY_ESNEXT */
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
{
ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p);
if (property_p != NULL)
{
#if JERRY_ESNEXT
ecma_property_value_t *property_value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
JERRY_ASSERT (!(*property_p & ECMA_PROPERTY_FLAG_WRITABLE)
|| (*property_p & ECMA_PROPERTY_FLAG_DATA));
if ((*property_p & ECMA_PROPERTY_FLAG_WRITABLE)
&& property_value_p->value != ECMA_VALUE_UNINITIALIZED)
{
ecma_named_data_property_assign_value (lex_env_p, property_value_p, value);
return ECMA_VALUE_EMPTY;
}
#else /* JERRY_ESNEXT */
if (ecma_is_property_writable (*property_p))
{
ecma_property_value_t *property_value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
#if JERRY_ESNEXT
if (JERRY_UNLIKELY (property_value_p->value == ECMA_VALUE_UNINITIALIZED))
{
return ecma_raise_reference_error (ECMA_ERR_MSG ("Variables declared by let/const must be"
" initialized before writing their value"));
}
#endif /* JERRY_ESNEXT */
ecma_named_data_property_assign_value (lex_env_p, property_value_p, value);
}
#if JERRY_ESNEXT
else if (ecma_is_property_enumerable (*property_p))
{
if (JERRY_UNLIKELY (ECMA_PROPERTY_VALUE_PTR (property_p)->value == ECMA_VALUE_UNINITIALIZED))
{
return ecma_raise_reference_error (ECMA_ERR_MSG ("Variables declared by let/const must be"
" initialized before writing their value"));
}
return ecma_raise_type_error (ECMA_ERR_MSG ("Constant bindings cannot be reassigned"));
return ECMA_VALUE_EMPTY;
}
#endif /* JERRY_ESNEXT */
else if (is_strict)
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Binding cannot be set"));
}
return ECMA_VALUE_EMPTY;
return ecma_op_raise_set_binding_error (property_p, is_strict);
}
break;
}
#if JERRY_ESNEXT
case ECMA_LEXICAL_ENVIRONMENT_HOME_OBJECT_BOUND:
{
break;
}
#endif /* JERRY_ESNEXT */
default:
{
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
+110 -48
View File
@@ -88,6 +88,42 @@ ecma_create_global_lexical_block (ecma_object_t *global_object_p) /**< global ob
} /* ecma_create_global_lexical_block */
#endif /* JERRY_ESNEXT */
/**
* Raise the appropriate error when setting a binding is failed
*
* @return ECMA_VALUE_EMPTY or ECMA_VALUE_ERROR
*/
ecma_value_t
ecma_op_raise_set_binding_error (ecma_property_t *property_p, /**< property */
bool is_strict) /**< flag indicating strict mode */
{
JERRY_UNUSED (property_p);
#if JERRY_ESNEXT
const ecma_property_t expected_bits = (ECMA_PROPERTY_FLAG_DATA | ECMA_PROPERTY_FLAG_ENUMERABLE);
if ((*property_p & expected_bits) == expected_bits)
{
ecma_property_value_t *property_value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
if (JERRY_UNLIKELY (property_value_p->value == ECMA_VALUE_UNINITIALIZED))
{
return ecma_raise_reference_error (ECMA_ERR_MSG (ecma_error_let_const_not_initialized));
}
JERRY_ASSERT (!ecma_is_property_writable (*property_p));
return ecma_raise_type_error (ECMA_ERR_MSG ("Constant bindings cannot be reassigned"));
}
#endif /* JERRY_ESNEXT */
if (is_strict)
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Binding cannot be set"));
}
return ECMA_VALUE_EMPTY;
} /* ecma_op_raise_set_binding_error */
/**
* Get reference to Global lexical scope
* without increasing its reference count.
@@ -125,18 +161,33 @@ ecma_op_has_binding (ecma_object_t *lex_env_p, /**< lexical environment */
ecma_lexical_environment_type_t lex_env_type = ecma_get_lex_env_type (lex_env_p);
if (lex_env_type == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE)
switch (lex_env_type)
{
ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p);
#if JERRY_ESNEXT
case ECMA_LEXICAL_ENVIRONMENT_CLASS:
{
if ((lex_env_p->type_flags_refs & ECMA_OBJECT_FLAG_LEXICAL_ENV_HAS_DATA) == 0)
{
return ECMA_VALUE_FALSE;
}
/* FALLTHRU */
}
#endif /* JERRY_ESNEXT */
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
{
ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p);
return ecma_make_boolean_value (property_p != NULL);
return ecma_make_boolean_value (property_p != NULL);
}
default:
{
JERRY_ASSERT (lex_env_type == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
return ecma_op_object_has_property (binding_obj_p, name_p);
}
}
JERRY_ASSERT (lex_env_type == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
return ecma_op_object_has_property (binding_obj_p, name_p);
} /* ecma_op_has_binding */
/**
@@ -245,53 +296,64 @@ ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment
&& ecma_is_lexical_environment (lex_env_p));
JERRY_ASSERT (name_p != NULL);
if (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE)
switch (ecma_get_lex_env_type (lex_env_p))
{
ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p);
if (JERRY_UNLIKELY (property_p == NULL))
{
property_p = ecma_op_create_mutable_binding (lex_env_p, name_p, is_strict);
JERRY_ASSERT (property_p != ECMA_PROPERTY_POINTER_ERROR);
}
JERRY_ASSERT (property_p != NULL && ECMA_PROPERTY_IS_RAW_DATA (*property_p));
if (ecma_is_property_writable (*property_p))
{
ecma_named_data_property_assign_value (lex_env_p, ECMA_PROPERTY_VALUE_PTR (property_p), value);
}
#if JERRY_ESNEXT
else if (ecma_is_property_enumerable (*property_p))
case ECMA_LEXICAL_ENVIRONMENT_CLASS:
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Constant bindings cannot be reassigned"));
if ((lex_env_p->type_flags_refs & ECMA_OBJECT_FLAG_LEXICAL_ENV_HAS_DATA) == 0)
{
return ECMA_VALUE_EMPTY;
}
/* FALLTHRU */
}
#endif /* JERRY_ESNEXT */
else if (is_strict)
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
{
return ecma_raise_type_error (ECMA_ERR_MSG ("Binding cannot be set"));
ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p);
if (JERRY_UNLIKELY (property_p == NULL))
{
property_p = ecma_op_create_mutable_binding (lex_env_p, name_p, is_strict);
JERRY_ASSERT (property_p != ECMA_PROPERTY_POINTER_ERROR);
}
JERRY_ASSERT (property_p != NULL && ECMA_PROPERTY_IS_RAW_DATA (*property_p));
JERRY_ASSERT (!(*property_p & ECMA_PROPERTY_FLAG_WRITABLE)
|| (*property_p & ECMA_PROPERTY_FLAG_DATA));
if ((*property_p & ECMA_PROPERTY_FLAG_WRITABLE))
{
ecma_property_value_t *property_value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
JERRY_ASSERT (property_value_p->value != ECMA_VALUE_UNINITIALIZED);
ecma_named_data_property_assign_value (lex_env_p, property_value_p, value);
return ECMA_VALUE_EMPTY;
}
return ecma_op_raise_set_binding_error (property_p, is_strict);
}
default:
{
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
ecma_value_t completion = ecma_op_object_put (binding_obj_p,
name_p,
value,
is_strict);
if (ECMA_IS_VALUE_ERROR (completion))
{
return completion;
}
JERRY_ASSERT (ecma_is_value_boolean (completion));
return ECMA_VALUE_EMPTY;
}
}
else
{
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
ecma_value_t completion = ecma_op_object_put (binding_obj_p,
name_p,
value,
is_strict);
if (ECMA_IS_VALUE_ERROR (completion))
{
return completion;
}
JERRY_ASSERT (ecma_is_value_boolean (completion));
}
return ECMA_VALUE_EMPTY;
} /* ecma_op_set_mutable_binding */
/**
@@ -37,6 +37,7 @@ ecma_object_t *ecma_get_global_scope (ecma_object_t *global_object_p);
#if JERRY_ESNEXT
void ecma_create_global_lexical_block (ecma_object_t *global_object_p);
#endif /* JERRY_ESNEXT */
ecma_value_t ecma_op_raise_set_binding_error (ecma_property_t *property_p, bool is_strict);
#if JERRY_MODULE_SYSTEM
void ecma_module_add_lex_env (ecma_object_t *lex_env_p);
@@ -425,12 +425,33 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
if (ECMA_PROPERTY_IS_VIRTUAL (current_prop))
{
bool writable_check_failed = (property_desc_p->flags & ECMA_PROP_IS_WRITABLE);
#if JERRY_MODULE_SYSTEM
if (ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_MODULE_NAMESPACE))
{
if (JERRY_UNLIKELY (ext_property_ref.property_ref.virtual_value == ECMA_VALUE_UNINITIALIZED))
{
return ecma_raise_reference_error (ECMA_ERR_MSG (ecma_error_let_const_not_initialized));
}
if (property_desc_p->flags & ECMA_PROP_IS_WRITABLE_DEFINED)
{
writable_check_failed = ((property_desc_p->flags ^ current_prop) & ECMA_PROP_IS_WRITABLE) != 0;
}
}
else
{
JERRY_ASSERT (!is_current_configurable && !ecma_is_property_writable (current_prop));
}
#else /* !JERRY_MODULE_SYSTEM */
JERRY_ASSERT (!is_current_configurable && !ecma_is_property_writable (current_prop));
#endif /* JERRY_MODULE_SYSTEM */
ecma_value_t result = ECMA_VALUE_TRUE;
if (property_desc_type == ECMA_OP_OBJECT_DEFINE_ACCESSOR
|| (property_desc_p->flags & ECMA_PROP_IS_WRITABLE)
|| writable_check_failed
|| ((property_desc_p->flags & ECMA_PROP_IS_VALUE_DEFINED)
&& !ecma_op_same_value (property_desc_p->value,
ext_property_ref.property_ref.virtual_value)))
+125 -23
View File
@@ -183,6 +183,59 @@ ecma_op_object_get_own_property (ecma_object_t *object_p, /**< the object */
break;
}
#endif /* JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_MODULE_SYSTEM
case ECMA_OBJECT_CLASS_MODULE_NAMESPACE:
{
if (JERRY_UNLIKELY (ecma_prop_name_is_symbol (property_name_p)))
{
if (!ecma_op_compare_string_to_global_symbol (property_name_p, LIT_GLOBAL_SYMBOL_TO_STRING_TAG))
{
return ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP;
}
/* ECMA-262 v11, 26.3.1 */
if (options & ECMA_PROPERTY_GET_VALUE)
{
property_ref_p->virtual_value = ecma_make_magic_string_value (LIT_MAGIC_STRING_MODULE_UL);
}
return ECMA_PROPERTY_VIRTUAL;
}
ecma_property_t *property_p = ecma_find_named_property (object_p, property_name_p);
if (property_p == NULL)
{
return ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP;
}
JERRY_ASSERT (ECMA_PROPERTY_IS_RAW (*property_p));
if (*property_p & ECMA_PROPERTY_FLAG_DATA)
{
if (options & ECMA_PROPERTY_GET_EXT_REFERENCE)
{
((ecma_extended_property_ref_t *) property_ref_p)->property_p = property_p;
}
if (property_ref_p != NULL)
{
property_ref_p->value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
}
return *property_p;
}
if (options & ECMA_PROPERTY_GET_VALUE)
{
ecma_property_value_t *prop_value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
prop_value_p = ecma_get_property_value_from_named_reference (prop_value_p);
property_ref_p->virtual_value = ecma_fast_copy_value (prop_value_p->value);
}
return ECMA_PROPERTY_ENUMERABLE_WRITABLE | ECMA_PROPERTY_VIRTUAL;
}
#endif /* JERRY_MODULE_SYSTEM */
}
break;
}
@@ -538,6 +591,44 @@ ecma_op_object_find_own (ecma_value_t base_value, /**< base value */
break;
}
#endif /* JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_MODULE_SYSTEM
case ECMA_OBJECT_CLASS_MODULE_NAMESPACE:
{
if (JERRY_UNLIKELY (ecma_prop_name_is_symbol (property_name_p)))
{
/* ECMA-262 v11, 26.3.1 */
if (ecma_op_compare_string_to_global_symbol (property_name_p, LIT_GLOBAL_SYMBOL_TO_STRING_TAG))
{
return ecma_make_magic_string_value (LIT_MAGIC_STRING_MODULE_UL);
}
return ECMA_VALUE_NOT_FOUND;
}
ecma_property_t *property_p = ecma_find_named_property (object_p, property_name_p);
if (property_p == NULL)
{
return ECMA_VALUE_NOT_FOUND;
}
JERRY_ASSERT (ECMA_PROPERTY_IS_RAW (*property_p));
ecma_property_value_t *prop_value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
if (!(*property_p & ECMA_PROPERTY_FLAG_DATA))
{
prop_value_p = ecma_get_property_value_from_named_reference (prop_value_p);
if (JERRY_UNLIKELY (prop_value_p->value == ECMA_VALUE_UNINITIALIZED))
{
return ecma_raise_reference_error (ECMA_ERR_MSG (ecma_error_let_const_not_initialized));
}
}
return ecma_fast_copy_value (prop_value_p->value);
}
#endif /* JERRY_MODULE_SYSTEM */
}
break;
}
@@ -940,6 +1031,25 @@ ecma_op_get_global_symbol (lit_magic_string_id_t property_id) /**< property symb
return symbol_p;
} /* ecma_op_get_global_symbol */
/**
* Checks whether the string equals to the global symbol.
*
* @return true - if the string equals to the global symbol
* false - otherwise
*/
bool
ecma_op_compare_string_to_global_symbol (ecma_string_t *string_p, /**< string to compare */
lit_magic_string_id_t property_id) /**< property symbol id */
{
JERRY_ASSERT (LIT_IS_GLOBAL_SYMBOL (property_id));
uint32_t symbol_index = (uint32_t) property_id - (uint32_t) LIT_GLOBAL_SYMBOL__FIRST;
jmem_cpointer_t symbol_cp = JERRY_CONTEXT (global_symbols_cp)[symbol_index];
return (symbol_cp != JMEM_CP_NULL
&& string_p == ECMA_GET_NON_NULL_POINTER (ecma_string_t, symbol_cp));
} /* ecma_op_compare_string_to_global_symbol */
/**
* [[Get]] operation of ecma object where the property is a well-known symbol
*
@@ -1327,6 +1437,12 @@ ecma_op_object_put_with_receiver (ecma_object_t *object_p, /**< the object */
break;
}
#endif /* JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_MODULE_SYSTEM
case ECMA_OBJECT_CLASS_MODULE_NAMESPACE:
{
return ecma_raise_readonly_assignment (property_name_p, is_throw);
}
#endif /* JERRY_MODULE_SYSTEM */
}
break;
}
@@ -1837,6 +1953,12 @@ ecma_op_object_get_own_property_descriptor (ecma_object_t *object_p, /**< the ob
}
else
{
#if JERRY_MODULE_SYSTEM
if (JERRY_UNLIKELY (property_ref.virtual_value == ECMA_VALUE_UNINITIALIZED))
{
return ecma_raise_reference_error (ECMA_ERR_MSG (ecma_error_let_const_not_initialized));
}
#endif /* JERRY_MODULE_SYSTEM */
prop_desc_p->value = property_ref.virtual_value;
}
@@ -2685,6 +2807,9 @@ static const uint16_t ecma_class_object_magic_string_id[] =
#if JERRY_BUILTIN_TYPEDARRAY
LIT_MAGIC_STRING__EMPTY, /**< ECMA_OBJECT_CLASS_TYPEDARRAY needs special resolver */
#endif /* JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_MODULE_SYSTEM
LIT_MAGIC_STRING_MODULE_UL, /**< magic string id of ECMA_OBJECT_CLASS_MODULE_NAMESPACE */
#endif
/* These objects are marked by Garbage Collector. */
#if JERRY_ESNEXT
@@ -2887,29 +3012,6 @@ ecma_object_get_class_name (ecma_object_t *obj_p) /**< object */
}
} /* ecma_object_get_class_name */
/**
* Get value of an object if the class matches
*
* @return value of the object if the class matches
* ECMA_VALUE_NOT_FOUND otherwise
*/
extern inline bool JERRY_ATTR_ALWAYS_INLINE
ecma_object_class_is (ecma_object_t *object_p, /**< object */
ecma_object_class_type_t class_id) /**< class id */
{
if (ecma_get_object_type (object_p) == ECMA_OBJECT_TYPE_CLASS)
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
if (ext_object_p->u.cls.type == (uint8_t) class_id)
{
return true;
}
}
return false;
} /* ecma_object_class_is */
#if JERRY_BUILTIN_REGEXP
/**
* Checks if the given argument has [[RegExpMatcher]] internal slot
+1 -1
View File
@@ -71,6 +71,7 @@ ecma_value_t ecma_op_object_get_by_index (ecma_object_t *object_p, ecma_length_t
ecma_value_t ecma_op_object_get_by_magic_id (ecma_object_t *object_p, lit_magic_string_id_t property_id);
#if JERRY_ESNEXT
ecma_string_t *ecma_op_get_global_symbol (lit_magic_string_id_t property_id);
bool ecma_op_compare_string_to_global_symbol (ecma_string_t *string_p, lit_magic_string_id_t property_id);
ecma_value_t ecma_op_object_get_by_symbol_id (ecma_object_t *object_p, lit_magic_string_id_t property_id);
ecma_value_t ecma_op_get_method_by_symbol_id (ecma_value_t value, lit_magic_string_id_t symbol_id);
ecma_value_t ecma_op_get_method_by_magic_id (ecma_value_t value, lit_magic_string_id_t magic_id);
@@ -100,7 +101,6 @@ ecma_collection_t *ecma_op_object_own_property_keys (ecma_object_t *obj_p);
ecma_collection_t *ecma_op_object_enumerate (ecma_object_t *obj_p);
lit_magic_string_id_t ecma_object_get_class_name (ecma_object_t *obj_p);
bool ecma_object_class_is (ecma_object_t *object_p, ecma_object_class_type_t class_id);
#if JERRY_BUILTIN_REGEXP
bool ecma_object_is_regexp_object (ecma_value_t arg);
#endif /* JERRY_BUILTIN_REGEXP */
+80 -60
View File
@@ -47,14 +47,6 @@ ecma_op_resolve_reference_base (ecma_object_t *lex_env_p, /**< starting lexical
while (true)
{
#if JERRY_ESNEXT
if (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_HOME_OBJECT_BOUND)
{
JERRY_ASSERT (lex_env_p->u2.outer_reference_cp != JMEM_CP_NULL);
lex_env_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t, lex_env_p->u2.outer_reference_cp);
}
#endif /* JERRY_ESNEXT */
ecma_value_t has_binding = ecma_op_has_binding (lex_env_p, name_p);
#if JERRY_BUILTIN_PROXY
@@ -114,11 +106,12 @@ ecma_op_is_global_environment (ecma_object_t *lex_env_p) /**< lexical environmen
ecma_value_t
ecma_op_resolve_super_base (ecma_object_t *lex_env_p) /**< starting lexical environment */
{
JERRY_ASSERT (lex_env_p != NULL);
while (true)
{
if (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_HOME_OBJECT_BOUND)
JERRY_ASSERT (lex_env_p != NULL);
if (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_CLASS
&& (lex_env_p->type_flags_refs & ECMA_OBJECT_FLAG_LEXICAL_ENV_HAS_DATA) == 0)
{
ecma_object_t *home_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t, lex_env_p->u1.home_object_cp);
@@ -297,82 +290,109 @@ ecma_op_resolve_reference_value (ecma_object_t *lex_env_p, /**< starting lexical
while (true)
{
ecma_lexical_environment_type_t lex_env_type = ecma_get_lex_env_type (lex_env_p);
if (lex_env_type == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE)
switch (ecma_get_lex_env_type (lex_env_p))
{
ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p);
if (property_p != NULL)
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
{
ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p);
if (property_p == NULL)
{
break;
}
ecma_property_value_t *property_value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
#if JERRY_ESNEXT
if (JERRY_UNLIKELY (property_value_p->value == ECMA_VALUE_UNINITIALIZED))
{
return ecma_raise_reference_error (ECMA_ERR_MSG ("Variables declared by let/const must be"
" initialized before reading their value"));
return ecma_raise_reference_error (ECMA_ERR_MSG (ecma_error_let_const_not_initialized));
}
#endif /* JERRY_ESNEXT */
return ecma_fast_copy_value (property_value_p->value);
}
}
else if (lex_env_type == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND)
{
#if JERRY_ESNEXT
bool lcache_lookup_allowed = ecma_op_is_global_environment (lex_env_p);
#else /* !JERRY_ESNEXT*/
bool lcache_lookup_allowed = true;
#endif /* JERRY_ESNEXT */
if (lcache_lookup_allowed)
case ECMA_LEXICAL_ENVIRONMENT_CLASS:
{
#if JERRY_LCACHE
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
ecma_property_t *property_p = ecma_lcache_lookup (binding_obj_p, name_p);
if (property_p != NULL)
#if JERRY_MODULE_SYSTEM
if (lex_env_p->type_flags_refs & ECMA_OBJECT_FLAG_LEXICAL_ENV_HAS_DATA)
{
JERRY_ASSERT (ECMA_PROPERTY_IS_RAW (*property_p));
ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p);
ecma_property_value_t *prop_value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
if (*property_p & ECMA_PROPERTY_FLAG_DATA)
if (property_p == NULL)
{
return ecma_fast_copy_value (prop_value_p->value);
break;
}
ecma_getter_setter_pointers_t *get_set_pair_p = ecma_get_named_accessor_property (prop_value_p);
ecma_property_value_t *property_value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
if (get_set_pair_p->getter_cp == JMEM_CP_NULL)
if (!(*property_p & ECMA_PROPERTY_FLAG_DATA))
{
return ECMA_VALUE_UNDEFINED;
property_value_p = ecma_get_property_value_from_named_reference (property_value_p);
}
ecma_object_t *getter_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t, get_set_pair_p->getter_cp);
if (JERRY_UNLIKELY (property_value_p->value == ECMA_VALUE_UNINITIALIZED))
{
return ecma_raise_reference_error (ECMA_ERR_MSG (ecma_error_let_const_not_initialized));
}
ecma_value_t base_value = ecma_make_object_value (binding_obj_p);
return ecma_op_function_call (getter_p, base_value, NULL, 0);
return ecma_fast_copy_value (property_value_p->value);
}
#endif /* JERRY_LCACHE */
#endif /* JERRY_MODULE_SYSTEM */
break;
}
ecma_value_t result = ecma_op_object_bound_environment_resolve_reference_value (lex_env_p, name_p);
if (ecma_is_value_found (result))
{
/* Note: the result may contains ECMA_VALUE_ERROR */
return result;
}
}
else
{
#if JERRY_ESNEXT
JERRY_ASSERT (lex_env_type == ECMA_LEXICAL_ENVIRONMENT_HOME_OBJECT_BOUND);
#else /* !JERRY_ESNEXT */
JERRY_UNREACHABLE ();
#endif /* JERRY_ESNEXT */
default:
{
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
#if JERRY_ESNEXT
bool lcache_lookup_allowed = ecma_op_is_global_environment (lex_env_p);
#else /* !JERRY_ESNEXT*/
bool lcache_lookup_allowed = true;
#endif /* JERRY_ESNEXT */
if (lcache_lookup_allowed)
{
#if JERRY_LCACHE
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
ecma_property_t *property_p = ecma_lcache_lookup (binding_obj_p, name_p);
if (property_p != NULL)
{
JERRY_ASSERT (ECMA_PROPERTY_IS_RAW (*property_p));
ecma_property_value_t *prop_value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
if (*property_p & ECMA_PROPERTY_FLAG_DATA)
{
return ecma_fast_copy_value (prop_value_p->value);
}
ecma_getter_setter_pointers_t *get_set_pair_p = ecma_get_named_accessor_property (prop_value_p);
if (get_set_pair_p->getter_cp == JMEM_CP_NULL)
{
return ECMA_VALUE_UNDEFINED;
}
ecma_object_t *getter_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t, get_set_pair_p->getter_cp);
ecma_value_t base_value = ecma_make_object_value (binding_obj_p);
return ecma_op_function_call (getter_p, base_value, NULL, 0);
}
#endif /* JERRY_LCACHE */
}
ecma_value_t result = ecma_op_object_bound_environment_resolve_reference_value (lex_env_p, name_p);
if (ecma_is_value_found (result))
{
/* Note: the result may contains ECMA_VALUE_ERROR */
return result;
}
break;
}
}
if (lex_env_p->u2.outer_reference_cp == JMEM_CP_NULL)