-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Add support for Yul ASTs output #14177
Conversation
Thank you for your contribution to the Solidity compiler! A team member will follow up shortly. If you haven't read our contributing guidelines and our review checklist before, please do it now, this makes the reviewing process and accepting your contribution smoother. If you have any questions or need our help, feel free to post them in the PR or talk to us directly on the #solidity-dev channel on Matrix. |
For reference, since we talked about this in our call earlier today: Via command line this input/output mode is enabled via We can, for example, add |
One more thing I forgot to consider yesterday:
which encode the source locations of the original Solidity file. Furthermore, we will eventually also want to import the Yul ASTs back with the goal to have identical compiler outputs after exporting the Yul AST and then importing it back compared to a single-step compilation. Similarly, compiling to Yul first and then continuing compilation from Yul is supposed to yield identical compiler output as one-step compilation. This PR doesn't need to address any of this, we can take care of that in subsequent steps, but it has implications for the source locations in the Yul AST: If you start from Yul code that has comments like the ones the compiler produces when compiling solidity to IR code, the compiler should already pick up on those comments and parse the source locations - in that case those locations should also show up in the Now in the absence of such comments, i.e. when compiling standalone Yul, it's probably most consistent to still have both fields, In this model, we can actually even make it |
From what I understand, origin location and native location already behave as you describe (meaning e.g. that native and origin are the same in the case of standalone Yul input). So, would it suffice if there are two fields, namely |
Yes, that should work! |
FYI you can ignore the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much @GiokaMarkella for your contribution. I left some comments ;)
690bda6
to
30bb9f1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from the changelog, looks good, and is ready to be merged soon. We're gonna decide on the actual elements names exposed in the Standard JSON interface, and once we've got that sorted, we'll get back to you. The commits will also need to be squashed by the way.
We just discussed this internally a bit further: we want the output artifacts in standard json to be named Do you know when you'll be available for rebasing the PR, making this change and fixing the remaining style comments? |
@ekpyron Actually, we could use the BTW, just noticed that the output docs do not show the |
I actually meant |
I'll try to keep track of all the comments and make the changes today! :) |
Fair enough, though in that case I think we might still be better off with something like |
Let's keep it at |
c5540da
to
57f5d37
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR looks good now. Great work!
I did find some small things that could be improved but I don't want to drop another wall of comments so I just corrected them as I went through the review - see my fixups. Let me know if there's anything there that you don't like or is wrong. In any case, there was nothing that would require any bigger changes from your side.
So now we're almost done here. The last thing remaining is to squash the commits to keep history clean. Then I can approve. Actually, if you don't mind me squashing it all into a single commit, I can just do it on my end while merging, so just let me know.
By the way, don't worry too much about the failing |
Awesome, thanks! Sure, if you could do that, that'd be great! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok done. #14263 is also in develop
now so all tests should now pass.
Adds:
--ast-compact-json
with Yul input. This outputs the Yul AST in JSON compact format.--ir-ast-json
and--ir-optimized-ast-json
with Solidity input. Those options will produce the AST of the Yul-IR and the optimized Yul-IR, respectively, in JSON compact format.Resolves #9590. Although #9590 was grouped with #13720 which appears to have other dependencies, #9590 itself is pretty straightforward and can be implemented similarly to the Solidity ASTs that are already present.