diff options
author | Zoltan Herczeg <zherczeg.u-szeged@partner.samsung.com> | 2018-04-17 09:51:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-17 09:51:52 +0200 |
commit | 96b528a4865002863bb4200dad7a3fcabc5a5883 (patch) | |
tree | 9ffe4578cbefb75d1c9935dbf69ffeeed5a3bd03 | |
parent | 3f3d4a64f1abf087d8c1113d0f5c62bc8e381435 (diff) |
Rework jerry_parse function. (#2282)
Remove jerry_parse_named_resource, merge its arguments to jerry_parse
and change is_strict argument to an option list for possible future extensions.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
-rw-r--r-- | docs/02.API-REFERENCE.md | 69 | ||||
-rw-r--r-- | docs/03.API-EXAMPLE.md | 2 | ||||
-rw-r--r-- | docs/07.DEBUGGER.md | 21 | ||||
-rw-r--r-- | jerry-core/api/jerry.c | 64 | ||||
-rw-r--r-- | jerry-core/include/jerryscript-core.h | 16 | ||||
-rw-r--r-- | jerry-main/main-unix-test.c | 2 | ||||
-rw-r--r-- | jerry-main/main-unix.c | 20 | ||||
-rw-r--r-- | targets/mbed/source/jerry_run.cpp | 2 | ||||
-rw-r--r-- | targets/mbedos5/jerryscript-mbed/jerryscript-mbed-launcher/source/launcher.cpp | 2 | ||||
-rw-r--r-- | targets/nuttx-stm32f4/jerry_main.c | 12 | ||||
-rw-r--r-- | targets/riot-stm32f4/source/main-riotos.c | 2 | ||||
-rw-r--r-- | targets/tizenrt-artik053/apps/jerryscript/jerry_main.c | 12 | ||||
-rw-r--r-- | tests/unit-core/test-abort.c | 12 | ||||
-rw-r--r-- | tests/unit-core/test-api.c | 20 | ||||
-rw-r--r-- | tests/unit-core/test-exec-stop.c | 12 | ||||
-rw-r--r-- | tests/unit-core/test-mem-stats.c | 6 | ||||
-rw-r--r-- | tests/unit-core/test-objects-foreach.c | 6 | ||||
-rw-r--r-- | tests/unit-core/test-promise.c | 6 | ||||
-rw-r--r-- | tests/unit-ext/test-ext-arg.c | 6 |
19 files changed, 146 insertions, 146 deletions
diff --git a/docs/02.API-REFERENCE.md b/docs/02.API-REFERENCE.md index 56d8ef8b..aa909d77 100644 --- a/docs/02.API-REFERENCE.md +++ b/docs/02.API-REFERENCE.md @@ -59,6 +59,14 @@ Possible compile time enabled feature types: - JERRY_FEATURE_DATE - Date support - JERRY_FEATURE_REGEXP - RegExp support +## jerry_parse_opts_t + +Option bits for [jerry_parse](#jerry_parse) and +[jerry_parse_function](#jerry_parse_function) functions: + + - JERRY_PARSE_NO_OPTS - no options passed + - JERRY_PARSE_STRICT_MODE - enable strict mode + ## jerry_generate_snapshot_opts_t Flags for [jerry_generate_snapshot](#jerry_generate_snapshot) and @@ -806,8 +814,9 @@ main (void) **Summary** -Parse script and construct an EcmaScript function. The -lexical environment is set to the global lexical environment. +Parse script and construct an EcmaScript function. The lexical environment is +set to the global lexical environment. The resource name can be used by +debugging systems to provide line / backtrace info. *Note*: Returned value must be freed with [jerry_release_value](#jerry_release_value) when it is no longer needed. @@ -816,14 +825,18 @@ is no longer needed. ```c jerry_value_t -jerry_parse (const jerry_char_t *source_p, +jerry_parse (const jerry_char_t *resource_name_p, /**< resource name (usually a file name) */ + size_t resource_name_length, /**< length of resource name */ + const jerry_char_t *source_p, size_t source_size, - bool is_strict); + uint32_t parse_opts); ``` +- `resource_name_p` - resource name, usually a file name (must be a valid UTF8 string). +- `resource_name_length` - size of the resource name, in bytes. - `source_p` - string, containing source code to parse (must be a valid UTF8 string). - `source_size` - size of the string, in bytes. -- `is_strict` - defines strict mode. +- `parse_opts` - any combination of [jerry_parse_opts_t](#jerry_parse_opts_t) flags. - return value - function object value, if script was parsed successfully, - thrown error, otherwise @@ -844,7 +857,7 @@ main (void) const jerry_char_t script[] = "print ('Hello, World!');"; size_t script_size = strlen ((const char *) script); - jerry_value_t parsed_code = jerry_parse (script, script_size, false); + jerry_value_t parsed_code = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS); jerry_release_value (parsed_code); jerry_cleanup (); @@ -855,40 +868,6 @@ main (void) - [jerry_run](#jerry_run) -## jerry_parse_named_resource - -**Summary** - -Parse script and construct an ECMAScript function. The lexical -environment is set to the global lexical environment. The resource -name (usually a file name) is also passed to this function which is -used by the debugger to find the source code. - -*Note*: The returned value must be freed with [jerry_release_value](#jerry_release_value) when it -is no longer needed. - -**Prototype** - -```c -jerry_value_t -jerry_parse_named_resource (const jerry_char_t *resource_name_p, /**< resource name (usually a file name) */ - size_t resource_name_length, /**< length of resource name */ - const jerry_char_t *source_p, /**< script source */ - size_t source_size, /**< script source size */ - bool is_strict) /**< strict mode */ -``` - -- `resource_name_p` - resource name, usually a file name (must be a valid UTF8 string). -- `resource_name_length` - size of the resource name, in bytes. -- `source_p` - string, containing source code to parse (must be a valid UTF8 string). -- `source_size` - size of the string, in bytes. -- `is_strict` - defines strict mode. -- return value - - function object value, if script was parsed successfully, - - thrown error, otherwise - -This function is identical to [jerry_parse](#jerry_parse), except that an additional filename parameter has been added. - ## jerry_parse_function **Summary** @@ -913,7 +892,7 @@ jerry_parse_function (const jerry_char_t *resource_name_p, /**< resource name (u size_t arg_list_size, /**< script source size */ const jerry_char_t *source_p, /**< script source */ size_t source_size, /**< script source size */ - bool is_strict) /**< strict mode */ + uint32_t parse_opts) /**< strict mode */ ``` - `resource_name_p` - resource name, usually a file name (must be a valid UTF8 string). @@ -922,7 +901,7 @@ jerry_parse_function (const jerry_char_t *resource_name_p, /**< resource name (u - `arg_list_size` - size of the argument list, in bytes. - `source_p` - string, containing source code to parse (must be a valid UTF8 string). - `source_size` - size of the string, in bytes. -- `is_strict` - defines strict mode. +- `parse_opts` - any combination of [jerry_parse_opts_t](#jerry_parse_opts_t) flags. - return value - function object value, if script was parsed successfully, - thrown error, otherwise @@ -965,7 +944,7 @@ main (void) jerry_init (JERRY_INIT_EMPTY); /* Setup Global scope code */ - jerry_value_t parsed_code = jerry_parse (script, script_size, false); + jerry_value_t parsed_code = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS); if (!jerry_value_has_error_flag (parsed_code)) { @@ -1055,7 +1034,7 @@ main (void) const jerry_char_t script[] = "new Promise(function(f,r) { f('Hello, World!'); }).then(function(x) { print(x); });"; size_t script_size = strlen ((const char *) script); - jerry_value_t parsed_code = jerry_parse (script, script_size, false); + jerry_value_t parsed_code = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS); jerry_value_t script_value = jerry_run (parsed_code); jerry_value_t job_value = jerry_run_all_enqueued_jobs (); @@ -5440,7 +5419,7 @@ main (void) // Inifinte loop. const char *src_p = "while(true) {}"; - jerry_value_t src = jerry_parse ((jerry_char_t *) src_p, strlen (src_p), false); + jerry_value_t src = jerry_parse (NULL, 0, (jerry_char_t *) src_p, strlen (src_p), JERRY_PARSE_NO_OPTS); jerry_release_value (jerry_run (src)); jerry_release_value (src); jerry_cleanup (); diff --git a/docs/03.API-EXAMPLE.md b/docs/03.API-EXAMPLE.md index e5ca6da7..fc691a00 100644 --- a/docs/03.API-EXAMPLE.md +++ b/docs/03.API-EXAMPLE.md @@ -55,7 +55,7 @@ main (void) jerryx_handler_print); /* Setup Global scope code */ - jerry_value_t parsed_code = jerry_parse (script, script_size, false); + jerry_value_t parsed_code = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS); if (!jerry_value_has_error_flag (parsed_code)) { diff --git a/docs/07.DEBUGGER.md b/docs/07.DEBUGGER.md index 3249d027..84653f2f 100644 --- a/docs/07.DEBUGGER.md +++ b/docs/07.DEBUGGER.md @@ -69,14 +69,9 @@ The debugger can be enabled by calling the `jerry_debugger_init (uint16_t port)` function after the `jerry_init ()` function. It initializes the debugger and blocks until a client connects. -When the debugger is enabled it is recommended to use -`jerry_parse_named_resource ()` instead of `jerry_parse ()` because -the resource name (usually a file name) is also passed to this -function. This resource name is used by the client to identify -the corresponding resource. In general it is always recommended to -use `jerry_parse_named_resource ()` when the resource name is -available because it silently ignores the resource name if the -debugger is disabled. +The resource name provided to `jerry_parse ()` is used by the client +to identify the resource name of the source code. This resource name +is usually a file name. ## JerryScript debugger C-API interface @@ -304,11 +299,11 @@ wait_for_source_callback (const jerry_char_t *resource_name_p, /**< resource nam size_t source_size, /**< source code size */ void *user_p __attribute__((unused))) /**< user pointer */ { - jerry_value_t ret_val = jerry_parse_named_resource (resource_name_p, - resource_name_size, - source_p, - source_size, - false); + jerry_value_t ret_val = jerry_parse (resource_name_p, + resource_name_size, + source_p, + source_size, + JERRY_PARSE_NO_OPTS); if (!jerry_value_has_error_flag (ret_val)) { diff --git a/jerry-core/api/jerry.c b/jerry-core/api/jerry.c index 989f815c..7070b76a 100644 --- a/jerry-core/api/jerry.c +++ b/jerry-core/api/jerry.c @@ -364,7 +364,7 @@ jerry_run_simple (const jerry_char_t *script_source_p, /**< script source */ jerry_init (flags); - jerry_value_t parse_ret_val = jerry_parse (script_source_p, script_source_size, false); + jerry_value_t parse_ret_val = jerry_parse (NULL, 0, script_source_p, script_source_size, JERRY_PARSE_NO_OPTS); if (!ecma_is_value_error_reference (parse_ret_val)) { @@ -392,10 +392,26 @@ jerry_run_simple (const jerry_char_t *script_source_p, /**< script source */ * thrown error - otherwise */ jerry_value_t -jerry_parse (const jerry_char_t *source_p, /**< script source */ +jerry_parse (const jerry_char_t *resource_name_p, /**< resource name (usually a file name) */ + size_t resource_name_length, /**< length of resource name */ + const jerry_char_t *source_p, /**< script source */ size_t source_size, /**< script source size */ - bool is_strict) /**< strict mode */ + uint32_t parse_opts) /**< jerry_parse_opts_t option bits */ { +#if defined JERRY_DEBUGGER && !defined JERRY_DISABLE_JS_PARSER + if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED) + && resource_name_length > 0) + { + jerry_debugger_send_string (JERRY_DEBUGGER_SOURCE_CODE_NAME, + JERRY_DEBUGGER_NO_SUBTYPE, + resource_name_p, + resource_name_length); + } +#else /* !(JERRY_DEBUGGER && !JERRY_DISABLE_JS_PARSER) */ + JERRY_UNUSED (resource_name_p); + JERRY_UNUSED (resource_name_length); +#endif /* JERRY_DEBUGGER && !JERRY_DISABLE_JS_PARSER */ + #ifndef JERRY_DISABLE_JS_PARSER jerry_assert_api_available (); @@ -406,7 +422,7 @@ jerry_parse (const jerry_char_t *source_p, /**< script source */ 0, source_p, source_size, - is_strict, + (parse_opts & JERRY_PARSE_STRICT_MODE) != 0, &bytecode_data_p); if (ECMA_IS_VALUE_ERROR (parse_status)) @@ -425,45 +441,13 @@ jerry_parse (const jerry_char_t *source_p, /**< script source */ #else /* JERRY_DISABLE_JS_PARSER */ JERRY_UNUSED (source_p); JERRY_UNUSED (source_size); - JERRY_UNUSED (is_strict); + JERRY_UNUSED (parse_opts); return jerry_throw (ecma_raise_syntax_error (ECMA_ERR_MSG ("The parser has been disabled."))); #endif /* !JERRY_DISABLE_JS_PARSER */ } /* jerry_parse */ /** - * Parse script and construct an ECMAScript function. The lexical - * environment is set to the global lexical environment. The name - * (usually a file name) is also passed to this function which is - * used by the debugger to find the source code. - * - * @return function object value - if script was parsed successfully, - * thrown error - otherwise - */ -jerry_value_t -jerry_parse_named_resource (const jerry_char_t *resource_name_p, /**< resource name (usually a file name) */ - size_t resource_name_length, /**< length of resource name */ - const jerry_char_t *source_p, /**< script source */ - size_t source_size, /**< script source size */ - bool is_strict) /**< strict mode */ -{ -#if defined JERRY_DEBUGGER && !defined JERRY_DISABLE_JS_PARSER - if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED) - { - jerry_debugger_send_string (JERRY_DEBUGGER_SOURCE_CODE_NAME, - JERRY_DEBUGGER_NO_SUBTYPE, - resource_name_p, - resource_name_length); - } -#else /* !(JERRY_DEBUGGER && !JERRY_DISABLE_JS_PARSER) */ - JERRY_UNUSED (resource_name_p); - JERRY_UNUSED (resource_name_length); -#endif /* JERRY_DEBUGGER && !JERRY_DISABLE_JS_PARSER */ - - return jerry_parse (source_p, source_size, is_strict); -} /* jerry_parse_named_resource */ - -/** * Parse function and construct an EcmaScript function. The lexical * environment is set to the global lexical environment. * @@ -477,7 +461,7 @@ jerry_parse_function (const jerry_char_t *resource_name_p, /**< resource name (u size_t arg_list_size, /**< script source size */ const jerry_char_t *source_p, /**< script source */ size_t source_size, /**< script source size */ - bool is_strict) /**< strict mode */ + uint32_t parse_opts) /**< jerry_parse_opts_t option bits */ { #if defined JERRY_DEBUGGER && !defined JERRY_DISABLE_JS_PARSER if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED) @@ -508,7 +492,7 @@ jerry_parse_function (const jerry_char_t *resource_name_p, /**< resource name (u arg_list_size, source_p, source_size, - is_strict, + (parse_opts & JERRY_PARSE_STRICT_MODE) != 0, &bytecode_data_p); if (ECMA_IS_VALUE_ERROR (parse_status)) @@ -529,7 +513,7 @@ jerry_parse_function (const jerry_char_t *resource_name_p, /**< resource name (u JERRY_UNUSED (arg_list_size); JERRY_UNUSED (source_p); JERRY_UNUSED (source_size); - JERRY_UNUSED (is_strict); + JERRY_UNUSED (parse_opts); return jerry_throw (ecma_raise_syntax_error (ECMA_ERR_MSG ("The parser has been disabled."))); #endif /* !JERRY_DISABLE_JS_PARSER */ diff --git a/jerry-core/include/jerryscript-core.h b/jerry-core/include/jerryscript-core.h index 7a0811c1..b349b16a 100644 --- a/jerry-core/include/jerryscript-core.h +++ b/jerry-core/include/jerryscript-core.h @@ -99,6 +99,15 @@ typedef enum } jerry_feature_t; /** + * Option flags for jerry_parse and jerry_parse_function functions. + */ +typedef enum +{ + JERRY_PARSE_NO_OPTS = 0, /**< no options passed */ + JERRY_PARSE_STRICT_MODE = (1 << 0), /**< enable strict mode */ +} jerry_parse_opts_t; + +/** * Character type of JerryScript. */ typedef uint8_t jerry_char_t; @@ -308,12 +317,11 @@ bool jerry_get_memory_stats (jerry_heap_stats_t *out_stats_p); * Parser and executor functions. */ bool jerry_run_simple (const jerry_char_t *script_source_p, size_t script_source_size, jerry_init_flag_t flags); -jerry_value_t jerry_parse (const jerry_char_t *source_p, size_t source_size, bool is_strict); -jerry_value_t jerry_parse_named_resource (const jerry_char_t *resource_name_p, size_t resource_name_length, - const jerry_char_t *source_p, size_t source_size, bool is_strict); +jerry_value_t jerry_parse (const jerry_char_t *resource_name_p, size_t resource_name_length, + const jerry_char_t *source_p, size_t source_size, uint32_t parse_opts); jerry_value_t jerry_parse_function (const jerry_char_t *resource_name_p, size_t resource_name_length, const jerry_char_t *arg_list_p, size_t arg_list_size, - const jerry_char_t *source_p, size_t source_size, bool is_strict); + const jerry_char_t *source_p, size_t source_size, uint32_t parse_opts); jerry_value_t jerry_run (const jerry_value_t func_val); jerry_value_t jerry_eval (const jerry_char_t *source_p, size_t source_size, bool is_strict); diff --git a/jerry-main/main-unix-test.c b/jerry-main/main-unix-test.c index 1fe10fdc..a67eb3ed 100644 --- a/jerry-main/main-unix-test.c +++ b/jerry-main/main-unix-test.c @@ -96,7 +96,7 @@ main (int argc, } else { - ret_value = jerry_parse (source_p, source_size, false); + ret_value = jerry_parse (NULL, 0, source_p, source_size, JERRY_PARSE_NO_OPTS); if (!jerry_value_has_error_flag (ret_value)) { diff --git a/jerry-main/main-unix.c b/jerry-main/main-unix.c index 1cde7626..8f3faa94 100644 --- a/jerry-main/main-unix.c +++ b/jerry-main/main-unix.c @@ -236,11 +236,11 @@ wait_for_source_callback (const jerry_char_t *resource_name_p, /**< resource nam size_t source_size, /**< source code size */ void *user_p __attribute__((unused))) /**< user pointer */ { - jerry_value_t ret_val = jerry_parse_named_resource (resource_name_p, - resource_name_size, - source_p, - source_size, - false); + jerry_value_t ret_val = jerry_parse (resource_name_p, + resource_name_size, + source_p, + source_size, + JERRY_PARSE_NO_OPTS); if (!jerry_value_has_error_flag (ret_val)) { @@ -597,11 +597,11 @@ main (int argc, break; } - ret_value = jerry_parse_named_resource ((jerry_char_t *) file_names[i], - strlen (file_names[i]), - source_p, - source_size, - false); + ret_value = jerry_parse ((jerry_char_t *) file_names[i], + strlen (file_names[i]), + source_p, + source_size, + JERRY_PARSE_NO_OPTS); if (!jerry_value_has_error_flag (ret_value) && !is_parse_only) { diff --git a/targets/mbed/source/jerry_run.cpp b/targets/mbed/source/jerry_run.cpp index 4b8a4b54..2e6f3b80 100644 --- a/targets/mbed/source/jerry_run.cpp +++ b/targets/mbed/source/jerry_run.cpp @@ -30,7 +30,7 @@ int js_entry (const char *source_p, const size_t source_size) js_register_functions (); - jerry_value_t parsed_code = jerry_parse (jerry_src, source_size, false); + jerry_value_t parsed_code = jerry_parse (NULL, 0, jerry_src, source_size, JERRY_PARSE_NO_OPTS); if (!jerry_value_has_error_flag (parsed_code)) { diff --git a/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-launcher/source/launcher.cpp b/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-launcher/source/launcher.cpp index 7379faba..c51143b7 100644 --- a/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-launcher/source/launcher.cpp +++ b/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-launcher/source/launcher.cpp @@ -42,7 +42,7 @@ static int load_javascript() { const jerry_char_t* code = reinterpret_cast<const jerry_char_t*>(js_codes[src].source); const size_t length = js_codes[src].length; - jerry_value_t parsed_code = jerry_parse(code, length, false); + jerry_value_t parsed_code = jerry_parse(NULL, 0, code, length, JERRY_PARSE_NO_OPTS); if (jerry_value_has_error_flag(parsed_code)) { LOG_PRINT_ALWAYS("jerry_parse failed [%s]\r\n", js_codes[src].name); diff --git a/targets/nuttx-stm32f4/jerry_main.c b/targets/nuttx-stm32f4/jerry_main.c index 5184189b..1775e326 100644 --- a/targets/nuttx-stm32f4/jerry_main.c +++ b/targets/nuttx-stm32f4/jerry_main.c @@ -395,7 +395,7 @@ int jerry_main (int argc, char *argv[]) const jerry_char_t script[] = "var str = 'Hello World'; print(str + ' from JerryScript')"; size_t script_size = strlen ((const char *) script); - ret_value = jerry_parse (script, script_size, false); + ret_value = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS); if (!jerry_value_has_error_flag (ret_value)) { @@ -415,11 +415,11 @@ int jerry_main (int argc, char *argv[]) return JERRY_STANDALONE_EXIT_CODE_FAIL; } - ret_value = jerry_parse_named_resource ((jerry_char_t *) file_names[i], - strlen (file_names[i]), - source_p, - source_size, - false); + ret_value = jerry_parse ((jerry_char_t *) file_names[i], + strlen (file_names[i]), + source_p, + source_size, + JERRY_PARSE_NO_OPTS); if (!jerry_value_has_error_flag (ret_value)) { diff --git a/targets/riot-stm32f4/source/main-riotos.c b/targets/riot-stm32f4/source/main-riotos.c index 3a803f8f..ab419e7c 100644 --- a/targets/riot-stm32f4/source/main-riotos.c +++ b/targets/riot-stm32f4/source/main-riotos.c @@ -66,7 +66,7 @@ int test_jerry (int argc, char **argv) register_js_function ("print", jerryx_handler_print); /* Setup Global scope code */ - ret_value = jerry_parse (script, script_size, false); + ret_value = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS); if (!jerry_value_has_error_flag (ret_value)) { diff --git a/targets/tizenrt-artik053/apps/jerryscript/jerry_main.c b/targets/tizenrt-artik053/apps/jerryscript/jerry_main.c index 71f08777..53d365a9 100644 --- a/targets/tizenrt-artik053/apps/jerryscript/jerry_main.c +++ b/targets/tizenrt-artik053/apps/jerryscript/jerry_main.c @@ -371,7 +371,7 @@ jerry_cmd_main (int argc, char *argv[]) const jerry_char_t script[] = "var str = 'Hello World'; print(str + ' from JerryScript')"; size_t script_size = strlen ((const char *) script); - ret_value = jerry_parse (script, script_size, false); + ret_value = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS); if (!jerry_value_has_error_flag (ret_value)) { @@ -391,11 +391,11 @@ jerry_cmd_main (int argc, char *argv[]) return JERRY_STANDALONE_EXIT_CODE_FAIL; } - ret_value = jerry_parse_named_resource ((jerry_char_t *) file_names[i], - strlen (file_names[i]), - source_p, - source_size, - false); + ret_value = jerry_parse ((jerry_char_t *) file_names[i], + strlen (file_names[i]), + source_p, + source_size, + JERRY_PARSE_NO_OPTS); if (!jerry_value_has_error_flag (ret_value)) { diff --git a/tests/unit-core/test-abort.c b/tests/unit-core/test-abort.c index 9a716ab9..88f15d10 100644 --- a/tests/unit-core/test-abort.c +++ b/tests/unit-core/test-abort.c @@ -62,9 +62,11 @@ main (void) " }\n" "}"); - jerry_value_t parsed_code_val = jerry_parse ((jerry_char_t *) inf_loop_code_src_p, + jerry_value_t parsed_code_val = jerry_parse (NULL, + 0, + (jerry_char_t *) inf_loop_code_src_p, strlen (inf_loop_code_src_p), - false); + JERRY_PARSE_NO_OPTS); TEST_ASSERT (!jerry_value_has_error_flag (parsed_code_val)); res = jerry_run (parsed_code_val); @@ -93,9 +95,11 @@ main (void) "with({})\n" " f();\n"); - parsed_code_val = jerry_parse ((jerry_char_t *) inf_loop_code_src_p, + parsed_code_val = jerry_parse (NULL, + 0, + (jerry_char_t *) inf_loop_code_src_p, strlen (inf_loop_code_src_p), - false); + JERRY_PARSE_NO_OPTS); TEST_ASSERT (!jerry_value_has_error_flag (parsed_code_val)); res = jerry_run (parsed_code_val); diff --git a/tests/unit-core/test-api.c b/tests/unit-core/test-api.c index 96ccda5f..d6a30ed4 100644 --- a/tests/unit-core/test-api.c +++ b/tests/unit-core/test-api.c @@ -365,7 +365,11 @@ main (void) jerry_init (JERRY_INIT_EMPTY); - parsed_code_val = jerry_parse ((jerry_char_t *) test_source, strlen (test_source), false); + parsed_code_val = jerry_parse (NULL, + 0, + (jerry_char_t *) test_source, + strlen (test_source), + JERRY_PARSE_NO_OPTS); TEST_ASSERT (!jerry_value_has_error_flag (parsed_code_val)); res = jerry_run (parsed_code_val); @@ -1023,7 +1027,7 @@ main (void) strlen (func_arg_list), (const jerry_char_t *) func_src, strlen (func_src), - false); + JERRY_PARSE_NO_OPTS); TEST_ASSERT (!jerry_value_has_error_flag (func_val)); @@ -1066,9 +1070,11 @@ main (void) jerry_init (JERRY_INIT_SHOW_OPCODES); const char *parser_err_src_p = "b = 'hello';\nvar a = (;"; - parsed_code_val = jerry_parse ((jerry_char_t *) parser_err_src_p, + parsed_code_val = jerry_parse (NULL, + 0, + (jerry_char_t *) parser_err_src_p, strlen (parser_err_src_p), - false); + JERRY_PARSE_NO_OPTS); TEST_ASSERT (jerry_value_has_error_flag (parsed_code_val)); jerry_value_clear_error_flag (&parsed_code_val); jerry_value_t err_str_val = jerry_value_to_string (parsed_code_val); @@ -1094,7 +1100,11 @@ main (void) magic_string_lengths); const char *ms_code_src_p = "var global = {}; var console = [1]; var process = 1;"; - parsed_code_val = jerry_parse ((jerry_char_t *) ms_code_src_p, strlen (ms_code_src_p), false); + parsed_code_val = jerry_parse (NULL, + 0, + (jerry_char_t *) ms_code_src_p, + strlen (ms_code_src_p), + JERRY_PARSE_NO_OPTS); TEST_ASSERT (!jerry_value_has_error_flag (parsed_code_val)); res = jerry_run (parsed_code_val); diff --git a/tests/unit-core/test-exec-stop.c b/tests/unit-core/test-exec-stop.c index c9ef7f21..94b1d7ea 100644 --- a/tests/unit-core/test-exec-stop.c +++ b/tests/unit-core/test-exec-stop.c @@ -50,9 +50,11 @@ main (void) jerry_set_vm_exec_stop_callback (vm_exec_stop_callback, &countdown, 16); const char *inf_loop_code_src_p = "while(true) {}"; - jerry_value_t parsed_code_val = jerry_parse ((jerry_char_t *) inf_loop_code_src_p, + jerry_value_t parsed_code_val = jerry_parse (NULL, + 0, + (jerry_char_t *) inf_loop_code_src_p, strlen (inf_loop_code_src_p), - false); + JERRY_PARSE_NO_OPTS); TEST_ASSERT (!jerry_value_has_error_flag (parsed_code_val)); jerry_value_t res = jerry_run (parsed_code_val); @@ -72,9 +74,11 @@ main (void) inf_loop_code_src_p = ("function f() { while (true) ; }\n" "try { f(); } catch(e) {}"); - parsed_code_val = jerry_parse ((jerry_char_t *) inf_loop_code_src_p, + parsed_code_val = jerry_parse (NULL, + 0, + (jerry_char_t *) inf_loop_code_src_p, strlen (inf_loop_code_src_p), - false); + JERRY_PARSE_NO_OPTS); TEST_ASSERT (!jerry_value_has_error_flag (parsed_code_val)); res = jerry_run (parsed_code_val); diff --git a/tests/unit-core/test-mem-stats.c b/tests/unit-core/test-mem-stats.c index 13c27850..0bb0772c 100644 --- a/tests/unit-core/test-mem-stats.c +++ b/tests/unit-core/test-mem-stats.c @@ -30,7 +30,11 @@ int main (void) ); jerry_init (JERRY_INIT_EMPTY); - jerry_value_t parsed_code_val = jerry_parse ((jerry_char_t *) test_source, strlen (test_source), false); + jerry_value_t parsed_code_val = jerry_parse (NULL, + 0, + (jerry_char_t *) test_source, + strlen (test_source), + JERRY_PARSE_NO_OPTS); TEST_ASSERT (!jerry_value_has_error_flag (parsed_code_val)); jerry_value_t res = jerry_run (parsed_code_val); diff --git a/tests/unit-core/test-objects-foreach.c b/tests/unit-core/test-objects-foreach.c index fef7094d..b4c7250f 100644 --- a/tests/unit-core/test-objects-foreach.c +++ b/tests/unit-core/test-objects-foreach.c @@ -70,7 +70,11 @@ main (void) jerry_init (JERRY_INIT_EMPTY); /* Render strict-equal as a function. */ - jerry_value_t parse_result = jerry_parse ((jerry_char_t *) strict_equal_source, strlen (strict_equal_source), true); + jerry_value_t parse_result = jerry_parse (NULL, + 0, + (jerry_char_t *) strict_equal_source, + strlen (strict_equal_source), + JERRY_PARSE_STRICT_MODE); TEST_ASSERT (!jerry_value_has_error_flag (parse_result)); jerry_value_t strict_equal = jerry_run (parse_result); TEST_ASSERT (!jerry_value_has_error_flag (strict_equal)); diff --git a/tests/unit-core/test-promise.c b/tests/unit-core/test-promise.c index 07e95377..621ebe43 100644 --- a/tests/unit-core/test-promise.c +++ b/tests/unit-core/test-promise.c @@ -148,7 +148,11 @@ main (void) register_js_function ("create_promise2", create_promise2_handler); register_js_function ("assert", assert_handler); - jerry_value_t parsed_code_val = jerry_parse ((jerry_char_t *) test_source, strlen (test_source), false); + jerry_value_t parsed_code_val = jerry_parse (NULL, + 0, + (jerry_char_t *) test_source, + strlen (test_source), + JERRY_PARSE_NO_OPTS); TEST_ASSERT (!jerry_value_has_error_flag (parsed_code_val)); jerry_value_t res = jerry_run (parsed_code_val); diff --git a/tests/unit-ext/test-ext-arg.c b/tests/unit-ext/test-ext-arg.c index 5ccfad4f..e79c2767 100644 --- a/tests/unit-ext/test-ext-arg.c +++ b/tests/unit-ext/test-ext-arg.c @@ -660,7 +660,11 @@ main (void) register_js_function ("test_validator_array1", test_validator_array1_handler); register_js_function ("test_validator_array2", test_validator_array2_handler); - jerry_value_t parsed_code_val = jerry_parse ((jerry_char_t *) test_source, strlen (test_source), false); + jerry_value_t parsed_code_val = jerry_parse (NULL, + 0, + (jerry_char_t *) test_source, + strlen (test_source), + JERRY_PARSE_NO_OPTS); TEST_ASSERT (!jerry_value_has_error_flag (parsed_code_val)); jerry_value_t res = jerry_run (parsed_code_val); |