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:
@@ -44,6 +44,7 @@ typedef enum
|
||||
OPT_DEBUGGER_WAIT_SOURCE,
|
||||
OPT_EXEC_SNAP,
|
||||
OPT_EXEC_SNAP_FUNC,
|
||||
OPT_MODULE,
|
||||
OPT_LOG_LEVEL,
|
||||
OPT_NO_PROMPT,
|
||||
OPT_CALL_ON_EXIT,
|
||||
@@ -85,6 +86,8 @@ static const cli_opt_t main_opts[] =
|
||||
.help = "execute input snapshot file(s)"),
|
||||
CLI_OPT_DEF (.id = OPT_EXEC_SNAP_FUNC, .longopt = "exec-snapshot-func", .meta = "FILE NUM",
|
||||
.help = "execute specific function from input snapshot file(s)"),
|
||||
CLI_OPT_DEF (.id = OPT_MODULE, .opt = "m", .longopt = "module", .meta = "FILE",
|
||||
.help = "execute module file"),
|
||||
CLI_OPT_DEF (.id = OPT_LOG_LEVEL, .longopt = "log-level", .meta = "NUM",
|
||||
.help = "set log level (0-3)"),
|
||||
CLI_OPT_DEF (.id = OPT_NO_PROMPT, .longopt = "no-prompt",
|
||||
@@ -307,6 +310,19 @@ main_parse_args (int argc, /**< argc */
|
||||
|
||||
break;
|
||||
}
|
||||
case OPT_MODULE:
|
||||
{
|
||||
const uint32_t path_index = cli_consume_path (&cli_state);
|
||||
|
||||
main_source_t *source_p = arguments_p->sources_p + arguments_p->source_count;
|
||||
arguments_p->source_count++;
|
||||
|
||||
source_p->type = SOURCE_MODULE;
|
||||
source_p->path_index = path_index;
|
||||
source_p->snapshot_index = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
case OPT_LOG_LEVEL:
|
||||
{
|
||||
long int log_level = cli_consume_int (&cli_state);
|
||||
|
||||
Reference in New Issue
Block a user