Fix lexical scoping between scripts (#3558)

This change fixes the handling of lexical blocks when executing multiple
scripts, and also fixes a few issues with module environments.

After this change, all script files will run in the same context and
will have access to lexically scoped global variables of previous
scripts, and module environments will no longer have a bound global
'this' value.

The REPL implementation in main-unix is also fixed to correctly handle
lexically scoped variables.

Fixes #3561.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
This commit is contained in:
Dániel Bátyai
2020-02-21 13:30:48 +01:00
committed by GitHub
parent b0a575b049
commit 68909fc5de
22 changed files with 416 additions and 129 deletions
+4 -1
View File
@@ -142,7 +142,10 @@ struct jerry_context_t
jmem_cpointer_t symbol_list_first_cp; /**< first item of the global symbol list */
#endif /* ENABLED (JERRY_ES2015) */
jmem_cpointer_t number_list_first_cp; /**< first item of the literal number list */
jmem_cpointer_t ecma_global_lex_env_cp; /**< global lexical environment */
jmem_cpointer_t ecma_global_env_cp; /**< global lexical environment */
#if ENABLED (JERRY_ES2015)
jmem_cpointer_t ecma_global_scope_cp; /**< global lexical scope */
#endif /* ENABLED (JERRY_ES2015) */
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
ecma_module_t *ecma_modules_p; /**< list of referenced modules */