Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(cli): Refactor execution & microtasks into CliRunner struct #344

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

andreubotella
Copy link
Collaborator

In order to add a repl to the cli, #323 moved the initialize_global_object and exit_with_parse_errors functions into a new helper module. However, this still left duplicate code between the eval and repl commands.

This patch moves the isolate and realm initialization, as well as the script execution and microtask checkpoint, to a new CliRunner struct that lives in the helper module.

Aside from just refactoring, this patch makes two visible changes related to promise jobs:

  • When passing multiple files to eval, now promise jobs run after each script execution, rather than at the end.
  • In repl mode it used to be that promise jobs were never run. Now, all promise jobs enqueued when running a line of JS are run before the result is printed.

In order to add a repl to the cli, trynova#323 moved the
`initialize_global_object` and `exit_with_parse_errors` functions into
a new `helper` module. However, this still left duplicate code between
the `eval` and `repl` commands.

This patch moves the isolate and realm initialization, as well as the
script execution and microtask checkpoint, to a new `CliRunner` struct
that lives in the `helper` module.

Aside from just refactoring, this patch makes two visible changes
related to promise jobs:
  - When passing multiple files to `eval`, now promise jobs run after
    each script execution, rather than at the end.
  - In `repl` mode it used to be that promise jobs were never run.
    Now, all promise jobs enqueued when running a line of JS are run
    before the result is printed.
@aapoalas
Copy link
Collaborator

I'd kind of want to land #268 before this. Making GC work would be kind of nice, even if the API is pretty ugly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants