Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
experimental option to dump JS from AST
Summary: Add a new module `AST2JS` which takes AST as input and generates JavaScript source. It has an optional "pretty" mode where spaces, newlines and indentation are inserted for readability. Long expressions however are not split into multiple lines - that would require a whole new level of complexity. The purpose here is not to implement a JS auto-formatter, but simply to emit fairly readable code. When "pretty" mode is disabled, no spaces and new lines are emitted (except where required). It does not support all AST constructs yet - I had no time to add all of them, but adding more is easy using the existing patterns. It crashes when encountering an unsupported AST kind. It works well enough to generate the `richards.js` benchmark. The easiest way to implement all missing nodes is to delete `void GenJS::visit(Node *n)`, which will cause compiler errors until they are all added. New command line options: `-dump-js`, `-dump-transformed-js`. Reviewed By: avp Differential Revision: D25295347 fbshipit-source-id: 201140c0465de87602a344d9e6a4a021238d94df
- Loading branch information