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

Updating codegen #742

Open
disnet opened this issue Aug 21, 2017 · 1 comment
Open

Updating codegen #742

disnet opened this issue Aug 21, 2017 · 1 comment

Comments

@disnet
Copy link
Member

disnet commented Aug 21, 2017

I have a PR to add async/await support #741 and @slotik is working on adding type nodes to sweet's AST sweet-js/sweet-spec#4. Both of these efforts require some way of doing codegen but at the moment we are relying on shift-codegen which only supports ES2016 (no async/await). Shift-codegen will be updated to ES2017 soon but it is unlikely to get support for type annotations so what should we do?

There are a few options I can see.

  1. Fork shift-codgen and add type annotation support ourselves. This involves also forking shift-spec and shift-reducer.
  2. Write our own sweet-codegen using sweet-spec.
  3. Convert our AST to a babel AST (which supports type nodes) after expansion and let babel do our codegen.

At the moment I'm leaning towards the babel option since I think it's the least amount of work for us and often you want to use babel as a backend anyway. Arguably writing our own codgen is the best long-term since that give us the most flexibility (and it would allow us to do things like rendering syntax declarations syntax m = ctx => ...).

Thoughts? Am I forgetting an option?

/cc @gabejohnson

@gabejohnson
Copy link
Member

I'd be in favor of the Babel option. Perhaps even better would be to do an AST transform instead. Then handoff to Babel. See #515 and shapesecurity/shift-spidermonkey-converter-js#16

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

No branches or pull requests

2 participants