Rework module parsing and execution (#4462)

This patch disables automatic detection of module code, and instead
requires the user to explicitly specify whether to parse a source
as a module or as a script.

To achieve this the jerry_parse API function now takes a new option
which signals that the source should be parsed as a module.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
This commit is contained in:
Dániel Bátyai
2021-01-18 15:33:43 +01:00
committed by GitHub
parent ef8a6a9f39
commit 0fec9135ec
85 changed files with 575 additions and 492 deletions
+10 -2
View File
@@ -86,6 +86,8 @@ restart:
goto exit;
}
uint32_t parse_opts = JERRY_PARSE_NO_OPTS;
switch (source_file_p->type)
{
case SOURCE_SNAPSHOT:
@@ -98,9 +100,15 @@ restart:
jerry_port_release_source (source_p);
break;
}
case SOURCE_MODULE:
{
parse_opts = JERRY_PARSE_MODULE;
/* FALLTHRU */
}
default:
{
assert (source_file_p->type == SOURCE_SCRIPT);
assert (source_file_p->type == SOURCE_SCRIPT
|| source_file_p->type == SOURCE_MODULE);
if (!jerry_is_valid_utf8_string ((jerry_char_t *) source_p, (jerry_size_t) source_size))
{
@@ -113,7 +121,7 @@ restart:
strlen (file_path_p),
source_p,
source_size,
JERRY_PARSE_NO_OPTS);
parse_opts);
jerry_port_release_source (source_p);