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

Transform example #868

Closed
DanielMazurkiewicz opened this issue Sep 24, 2019 · 4 comments
Closed

Transform example #868

DanielMazurkiewicz opened this issue Sep 24, 2019 · 4 comments
Labels

Comments

@DanielMazurkiewicz
Copy link

Looking for transform examples, would appreciate some :-)

@dcodeIO
Copy link
Member

dcodeIO commented Sep 25, 2019

There are no specific transform examples yet, but this is how it works: The afterParse hook of the transform specified with --transform is called with the Parser instance when parsing has finished, containing the (yet uninitialized) Program instance that has an array of the parsed Sources, with each source node containing its respective AST. At this stage, the AST can be traversed and possibly modified, for example by looking for custom decorators that trigger injection of additional code.

@DanielMazurkiewicz
Copy link
Author

@dcodeIO I think that is already helpful - thank you!

@MaxGraey
Copy link
Member

MaxGraey commented Sep 25, 2019

You could see this example about usage transform function. But it pretty old and some part could be different for now

@willemneal
Copy link
Contributor

@DanielMazurkiewicz This is also a good example: https://github.com/nearprotocol/assemblyscript/tree/master/bindings/src

It's used to add JSON serialization to objects and exported functions.

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

No branches or pull requests

4 participants