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

Allow compiling async functions to generators #2102

Merged
merged 1 commit into from
Apr 7, 2016

Conversation

arv
Copy link
Collaborator

@arv arv commented Apr 4, 2016

This is done by setting --async-functions=generator --generators=parse.

Related to #1231
Fixes #1780

@arv
Copy link
Collaborator Author

arv commented Apr 4, 2016

@johnjbarton The feature tests now run all test/feature/AsyncFunctions twice. Once with whatever options are set in the prolog and once where we override the options to transform to generators. The code for this is pretty ugly. Suggestions welcome.

createIdentifierExpression(ARGUMENTS) :
createNullLiteral();
const statement = parseStatement
`return $traceurRuntime.spawn(this, ${argExpr}, function*() { ${body} });`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised to see es6-ish here. Is there no combination of options where this generator function parse will fail?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. This is only enabled if parsing generators is enabled.

@johnjbarton
Copy link
Contributor

Regarding the two-pass tests, duplicating the files with different options is not a horrible alternative and probably makes the system simpler. But it's ok this way.

LGTM

@arv
Copy link
Collaborator Author

arv commented Apr 4, 2016

There is also one more complication and that is that we need to detect if there is native support for generators. For example Node 0.10 does not have generators. I thought of doing some optional skip directive fur the test runner...

This is done by setting `--async-functions --generators=parse`.

Related to google#1231
Fixes google#1780
@arv
Copy link
Collaborator Author

arv commented Apr 7, 2016

I ended up duplicating the test and adding support for conditional skip to the feature test runner. I also changed the options slightly, so that if --generator=parse then we generate code that contains generators.

@arv arv merged commit 18900ad into google:master Apr 7, 2016
@arv arv deleted the async-to-generator branch April 7, 2016 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants