Skip to content

Commit

Permalink
Execute js_std_loop uniformly before exiting main
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanson committed Nov 1, 2023
1 parent f4c2577 commit c0566e8
Showing 1 changed file with 4 additions and 29 deletions.
33 changes: 4 additions & 29 deletions quickjs/qjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,50 +336,25 @@ int main(int argc, const char **argv) {
if (c_bool) {
JS_SetModuleLoaderFunc(rt, NULL, js_module_dummy_loader, NULL);
err = compile_from_file(ctx);
CHECK(err);
} else if (e_data) {
err = eval_buf(ctx, e_data, strlen(e_data), "<cmdline>", 0);
if (err == 0) {
js_std_loop(ctx);
}
CHECK(err);
} else if (r_bool && f_bool) {
err = run_from_local_file(ctx, true);
if (err == 0) {
js_std_loop(ctx);
}
CHECK(err);
} else if (r_bool) {
err = run_from_local_file(ctx, false);
if (err == 0) {
js_std_loop(ctx);
}
CHECK(err);
} else if (t_data && f_bool) {
err = run_from_target(ctx, t_data, true);
if (err == 0) {
js_std_loop(ctx);
}
CHECK(err);
} else if (t_data) {
err = run_from_target(ctx, t_data, false);
if (err == 0) {
js_std_loop(ctx);
}
CHECK(err);
} else if (f_bool) {
err = run_from_cell_data(ctx, true);
if (err == 0) {
js_std_loop(ctx);
}
CHECK(err);
} else {
err = run_from_cell_data(ctx, false);
if (err == 0) {
js_std_loop(ctx);
}
CHECK(err);
}
if (err == 0) {
js_std_loop(ctx);
}
CHECK(err);

#ifdef MEMORY_USAGE
size_t heap_usage = malloc_usage();
Expand Down

0 comments on commit c0566e8

Please sign in to comment.