Don't concatenate multiple JS scripts in jerry
Jerry (the command line tool) has been supporting the execution of multiple script files for long. However, until now, it simply concatenated all sources into a single source buffer and parsed/executed them as one unit. Other JS execution tools (e.g., jsc, v8) load and execute separate files as separate units -- but still in the same execution environment. The most significant effect of this approach is that the `"use strict;"` directive (or the absence of it) at the beginning of each JS script file takes effect as expected (i.e., as if the script was executed alone). Contrarily, the concatenation-based approach forces the strictness of the first script on all the rest (i.e., if the first script starts with `"use strict";` the rest is also executed in a strict environment even if they did not contain the directive, and vice versa). This patch makes the jerry command line tool to load/parse/run one unit at a time. Side effects: - As there is no need for separate file read routines that load one file (a snapshot) or concat multiple (JS sources) anymore, those routines got merged. - Both previous read routines used multiple stdio functions (`fseek`, `ftell`, and `rewind`). This has been simplified to rely on `fread` only to find out the length of the input. - This simplification made the above mentioned functions superfluous in jerry-libc. - As some error messages had to be touched in this patch, several more have been beautified to make them more consistent. - One small change was needed in `jerry_parse` in jerry-core to allow subsequent parsing of multiple sources (without that, an assertion was triggered). JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
@@ -1698,6 +1698,8 @@ jerry_parse (const jerry_api_char_t *source_p, /**< script source */
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
|
||||
vm_finalize ();
|
||||
|
||||
int is_show_instructions = ((jerry_flags & JERRY_FLAG_SHOW_OPCODES) != 0);
|
||||
|
||||
parser_set_show_instrs (is_show_instructions);
|
||||
|
||||
Reference in New Issue
Block a user