diff --git a/examples/javascript/main.c b/examples/javascript/main.c index 18d7523c9ff9b8b2e5de05e5234196ef7f05197e..a71d8eb44c043cf362bede25db464e5d8892a528 100644 --- a/examples/javascript/main.c +++ b/examples/javascript/main.c @@ -31,30 +31,34 @@ int js_run(const jerry_char_t *script, size_t script_size) { - jerry_value_t ret_value; - /* Initialize engine */ + jerry_value_t parsed_code, ret_value; + int res = 0; + + /* Initialize engine, no flags, default configuration */ + jerry_init(JERRY_INIT_EMPTY); /* Register the print function in the global object. */ - jerryx_handler_register_global((const jerry_char_t *) "print", jerryx_handler_print); - /* Setup Global scope code */ - ret_value = jerry_parse(script, script_size, false); + jerryx_handler_register_global((const jerry_char_t *) "print", + jerryx_handler_print); - if (!jerry_value_has_error_flag(ret_value)) { - /* Execute the parsed source code in the Global scope */ - ret_value = jerry_run(ret_value); - } + /* Setup Global scope code */ - int res = 0; + parsed_code = jerry_parse(NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS); - if (jerry_value_has_error_flag(ret_value)) { - printf("js_run(): Script Error!"); - res = -1; + if (!jerry_value_is_error(parsed_code)) { + /* Execute the parsed source code in the Global scope */ + ret_value = jerry_run(parsed_code); + if (jerry_value_is_error(ret_value)) { + printf("js_run(): Script Error!"); + res = -1; + } + jerry_release_value(ret_value); } - jerry_release_value(ret_value); + jerry_release_value(parsed_code); /* Cleanup engine */ jerry_cleanup(); diff --git a/pkg/jerryscript/Makefile b/pkg/jerryscript/Makefile index b9c4095215a6846b44d09300dbaf4406a06e795d..eafcaba81ef51bb8f8687f61defc79c067b1aeda 100644 --- a/pkg/jerryscript/Makefile +++ b/pkg/jerryscript/Makefile @@ -1,6 +1,6 @@ PKG_NAME=jerryscript PKG_URL=https://github.com/jerryscript-project/jerryscript.git -PKG_VERSION=bd574956e3702bc5b0512ad835b1df896cf00626 +PKG_VERSION=e1af56586cf9beeafbc67172b05cad28eca289cb PKG_LICENSE=Apache-2.0 .PHONY: all