Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 264aedf

Browse files
committed
[jerryscript] Rebase to latest JerryScript
Signed-off-by: Jimmy Huang <[email protected]>
1 parent f90d9d1 commit 264aedf

19 files changed

+71
-54
lines changed

deps/jerryscript

Submodule jerryscript updated 265 files

src/ashell/jerry-code.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static jerry_value_t parsed_code = 0;
3535
void javascript_eval_code(const char *source_buffer, ssize_t size)
3636
{
3737
ZVAL ret_val = jerry_eval((jerry_char_t *)source_buffer, size, false);
38-
if (jerry_value_has_error_flag(ret_val)) {
38+
if (jerry_value_is_error(ret_val)) {
3939
printf("[ERR] failed to evaluate JS\n");
4040
zjs_print_error_message(ret_val, ZJS_UNDEFINED);
4141
}
@@ -63,8 +63,9 @@ int javascript_parse_code(const char *file_name)
6363

6464
if (buf && size > 0) {
6565
/* Setup Global scope code */
66-
parsed_code = jerry_parse((const jerry_char_t *)buf, size, false);
67-
if (jerry_value_has_error_flag(parsed_code)) {
66+
parsed_code = jerry_parse(NULL, 0, (const jerry_char_t *)buf, size,
67+
JERRY_PARSE_NO_OPTS);
68+
if (jerry_value_is_error(parsed_code)) {
6869
DBG_PRINT("Error parsing JS\n");
6970
zjs_print_error_message(parsed_code, ZJS_UNDEFINED);
7071
jerry_release_value(parsed_code);
@@ -85,7 +86,7 @@ void javascript_run_code(const char *file_name)
8586
/* Execute the parsed source code in the Global scope */
8687
ZVAL ret_value = jerry_run(parsed_code);
8788

88-
if (jerry_value_has_error_flag(ret_value)) {
89+
if (jerry_value_is_error(ret_value)) {
8990
DBG_PRINT("Error running JS\n");
9091
zjs_print_error_message(ret_value, ZJS_UNDEFINED);
9192
}

src/jerry-port/zjs_jerry_port.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,13 @@ void jerry_port_log(jerry_log_level_t level, const char *format, ...)
5757
#endif /* JERRY_DEBUGGER */
5858
va_end(args);
5959
}
60+
61+
void jerry_port_sleep (uint32_t sleep_time)
62+
{
63+
#ifdef ZJS_LINUX_BUILD
64+
usleep ((useconds_t) sleep_time * 1000);
65+
#else
66+
k_sleep ((useconds_t) sleep_time);
67+
#endif
68+
(void) sleep_time;
69+
}

src/main.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,13 @@ int main(int argc, char *argv[])
293293
#endif
294294

295295
#ifndef ZJS_SNAPSHOT_BUILD
296-
code_eval = jerry_parse_named_resource((jerry_char_t *)file_name,
297-
file_name_len,
298-
(jerry_char_t *)script,
299-
script_len,
300-
false);
296+
code_eval = jerry_parse((jerry_char_t *)file_name,
297+
file_name_len,
298+
(jerry_char_t *)script,
299+
script_len,
300+
JERRY_PARSE_NO_OPTS);
301301

302-
if (jerry_value_has_error_flag(code_eval)) {
302+
if (jerry_value_is_error(code_eval)) {
303303
DBG_PRINT("Error parsing JS\n");
304304
zjs_print_error_message(code_eval, ZJS_UNDEFINED);
305305
goto error;
@@ -311,12 +311,16 @@ int main(int argc, char *argv[])
311311
#endif
312312

313313
#ifdef ZJS_SNAPSHOT_BUILD
314-
result = jerry_exec_snapshot(snapshot_bytecode, snapshot_len, false);
314+
result = jerry_exec_snapshot(snapshot_bytecode,
315+
snapshot_len,
316+
0,
317+
JERRY_SNAPSHOT_EXEC_COPY_DATA);
318+
315319
#else
316320
result = jerry_run(code_eval);
317321
#endif
318322

319-
if (jerry_value_has_error_flag(result)) {
323+
if (jerry_value_is_error(result)) {
320324
DBG_PRINT("Error running JS\n");
321325
zjs_print_error_message(result, ZJS_UNDEFINED);
322326
goto error;
@@ -406,7 +410,7 @@ int main(int argc, char *argv[])
406410
#ifdef BUILD_MODULE_PROMISE
407411
// run queued jobs for promises
408412
result = jerry_run_all_enqueued_jobs();
409-
if (jerry_value_has_error_flag(result)) {
413+
if (jerry_value_is_error(result)) {
410414
DBG_PRINT("Error running JS in promise jobqueue\n");
411415
zjs_print_error_message(result, ZJS_UNDEFINED);
412416
goto error;

src/sensors/zjs_sensor_accel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static ZJS_DECL_FUNC(zjs_sensor_constructor)
4747
zjs_sensor_create, g_instance, SENSOR_CHAN_ACCEL_XYZ, ACCEL_DEVICE_NAME,
4848
0, 800, onchange, NULL, onstop);
4949

50-
if (!jerry_value_has_error_flag(sensor_obj)) {
50+
if (!jerry_value_is_error(sensor_obj)) {
5151
ZVAL null_val = jerry_create_null();
5252
zjs_set_readonly_property(sensor_obj, "x", null_val);
5353
zjs_set_readonly_property(sensor_obj, "y", null_val);

src/sensors/zjs_sensor_gyro.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static ZJS_DECL_FUNC(zjs_sensor_constructor)
4747
ZJS_CHAIN_FUNC_ARGS(zjs_sensor_create, g_instance, SENSOR_CHAN_GYRO_XYZ,
4848
GYRO_DEVICE_NAME, 0, 800, onchange, NULL, onstop);
4949

50-
if (!jerry_value_has_error_flag(sensor_obj)) {
50+
if (!jerry_value_is_error(sensor_obj)) {
5151
ZVAL null_val = jerry_create_null();
5252
zjs_set_readonly_property(sensor_obj, "x", null_val);
5353
zjs_set_readonly_property(sensor_obj, "y", null_val);

src/sensors/zjs_sensor_light.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static ZJS_DECL_FUNC(zjs_sensor_constructor)
4141
ZJS_CHAIN_FUNC_ARGS(zjs_sensor_create, g_instance, SENSOR_CHAN_LIGHT,
4242
ADC_DEVICE_NAME, -1, 100, onchange, NULL, onstop);
4343

44-
if (!jerry_value_has_error_flag(sensor_obj)) {
44+
if (!jerry_value_is_error(sensor_obj)) {
4545
ZVAL null_val = jerry_create_null();
4646
zjs_set_readonly_property(sensor_obj, "illuminance", null_val);
4747
}

src/sensors/zjs_sensor_magn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static ZJS_DECL_FUNC(zjs_sensor_constructor)
4747
ZJS_CHAIN_FUNC_ARGS(zjs_sensor_create, g_instance, SENSOR_CHAN_MAGN_XYZ,
4848
MAGN_DEVICE_NAME, 0, 800, onchange, NULL, onstop);
4949

50-
if (!jerry_value_has_error_flag(sensor_obj)) {
50+
if (!jerry_value_is_error(sensor_obj)) {
5151
ZVAL null_val = jerry_create_null();
5252
zjs_set_readonly_property(sensor_obj, "x", null_val);
5353
zjs_set_readonly_property(sensor_obj, "y", null_val);

src/sensors/zjs_sensor_temp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static ZJS_DECL_FUNC(zjs_sensor_constructor)
4141
ZJS_CHAIN_FUNC_ARGS(zjs_sensor_create, g_instance, SENSOR_CHAN_TEMP,
4242
TEMP_DEVICE_NAME, 0, 800, onchange, NULL, onstop);
4343

44-
if (!jerry_value_has_error_flag(sensor_obj)) {
44+
if (!jerry_value_is_error(sensor_obj)) {
4545
ZVAL null_val = jerry_create_null();
4646
zjs_set_readonly_property(sensor_obj, "celsius", null_val);
4747
}

src/zjs_aio_a101.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ static ZJS_DECL_FUNC(zjs_aio_open)
239239
send.data.aio.pin = pin;
240240

241241
ZVAL result = zjs_aio_call_remote_function(&send);
242-
if (jerry_value_has_error_flag(result))
242+
if (jerry_value_is_error(result))
243243
return result;
244244

245245
// create the AIOPin object

0 commit comments

Comments
 (0)