Skip to content

Commit 39dba1a

Browse files
committed
Create namespace with references for modules
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
1 parent ef35c03 commit 39dba1a

27 files changed

+1366
-472
lines changed

jerry-core/api/jerry.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -861,9 +861,10 @@ jerry_module_get_namespace (const jerry_value_t module_val) /**< module */
861861

862862
if (module_p->namespace_object_p == NULL)
863863
{
864-
if (module_p->header.u.cls.u1.module_state != JERRY_MODULE_STATE_EVALUATED)
864+
if (module_p->header.u.cls.u1.module_state < JERRY_MODULE_STATE_LINKED
865+
|| module_p->header.u.cls.u1.module_state > JERRY_MODULE_STATE_EVALUATED)
865866
{
866-
return jerry_throw (ecma_raise_range_error (ECMA_ERR_MSG ("Namespace object has not been created yet")));
867+
return jerry_throw (ecma_raise_range_error (ECMA_ERR_MSG ("Namespace object cannot be created")));
867868
}
868869

869870
ecma_module_create_namespace_object (module_p);
@@ -1264,6 +1265,9 @@ static const uint8_t jerry_class_object_type[] =
12641265
#if JERRY_BUILTIN_TYPEDARRAY
12651266
JERRY_OBJECT_TYPE_TYPEDARRAY, /**< type of ECMA_OBJECT_CLASS_TYPEDARRAY */
12661267
#endif /* JERRY_BUILTIN_TYPEDARRAY */
1268+
#if JERRY_MODULE_SYSTEM
1269+
JERRY_OBJECT_TYPE_GENERIC, /**< type of ECMA_OBJECT_CLASS_MODULE_NAMESPACE */
1270+
#endif
12671271

12681272
/* These objects are marked by Garbage Collector. */
12691273
#if JERRY_ESNEXT
@@ -5130,9 +5134,7 @@ jerry_realm_set_this (jerry_value_t realm_value, /**< realm value */
51305134
ecma_global_object_t *global_object_p = (ecma_global_object_t *) object_p;
51315135
global_object_p->this_binding = this_value;
51325136

5133-
ecma_object_t *global_lex_env_p = ecma_create_object_lex_env (NULL,
5134-
ecma_get_object_from_value (this_value),
5135-
ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
5137+
ecma_object_t *global_lex_env_p = ecma_create_object_lex_env (NULL, ecma_get_object_from_value (this_value));
51365138

51375139
ECMA_SET_NON_NULL_POINTER (global_object_p->global_env_cp, global_lex_env_p);
51385140
#if JERRY_ESNEXT

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,22 @@ const char * const ecma_error_local_variable_is_redeclared = "Local variable is
138138
*/
139139
const char * const ecma_error_expected_a_function = "Expected a function";
140140

141+
#if JERRY_ESNEXT
142+
141143
/**
142144
* Error message, class constructor invoked without new keyword
143145
*/
144146
const char * const ecma_error_class_constructor_new = "Class constructor cannot be invoked without 'new'";
145147

146-
#endif /* JERRY_ERROR_MESSAGES */
148+
/**
149+
* Error message, variables declared by let/const must be initialized before reading their value
150+
*/
151+
const char * const ecma_error_let_const_not_initialized = ("Variables declared by let/const must be"
152+
" initialized before reading their value");
153+
154+
#endif /* JERRY_ESNEXT */
155+
156+
#endif /* JERRY_ERROR_MESSAGES */
147157

148158
#if JERRY_SNAPSHOT_SAVE || JERRY_SNAPSHOT_EXEC
149159

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#ifndef ECMA_ERRORS_H
1919
#define ECMA_ERRORS_H
2020

21+
#if JERRY_ERROR_MESSAGES
22+
2123
extern const char * const ecma_error_value_msg_p;
2224
extern const char * const ecma_error_wrong_args_msg_p;
2325

@@ -65,7 +67,13 @@ extern const char * const ecma_error_argument_is_not_an_regexp;
6567
extern const char * const ecma_error_invalid_array_length;
6668
extern const char * const ecma_error_local_variable_is_redeclared;
6769
extern const char * const ecma_error_expected_a_function;
70+
71+
#if JERRY_ESNEXT
6872
extern const char * const ecma_error_class_constructor_new;
73+
extern const char * const ecma_error_let_const_not_initialized;
74+
#endif /* JERRY_ESNEXT */
75+
76+
#endif /* JERRY_ERROR_MESSAGES */
6977

7078
/* snapshot errors */
7179
extern const char * const ecma_error_maximum_snapshot_size;

0 commit comments

Comments
 (0)