-
Notifications
You must be signed in to change notification settings - Fork 155
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
an attempt to implement pretty HIR dump #1933
Conversation
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.
This is good work, thank you for working on this :) I like the idea of not having empty vectors everywhere. I think for your proposal it might be nice to consider a new side of the HIR dump which would be a more configurable dump - so for example, it might be nice to have an option to disable the printing of HirId
s or NodId
s. They are useful but might clutter the output if one is not looking for them. I'm looking forward to your proposal!
gcc/rust/hir/rust-hir-dump.cc
Outdated
stream << "inner_attrs" | ||
<< ":" | ||
<< " " | ||
<< "["; |
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.
stream << "inner_attrs" | |
<< ":" | |
<< " " | |
<< "["; | |
stream << "inner_attrs: [" |
gcc/rust/hir/rust-hir-dump.cc
Outdated
stream << "]" | ||
<< "," << std::endl; |
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.
stream << "]" | |
<< "," << std::endl; | |
stream << "]," << std::endl; |
gcc/rust/hir/rust-hir-dump.cc
Outdated
indent++; | ||
// TODO: outer attributes | ||
stream << std::string (indent, indent_char); | ||
stream << "let "; |
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.
Probably clearer to have something like LetStmt:
like we have for Stmt:
, Expr:
, Function:
etc
Thanks for reviewing!
If I understand correctly, you mean introduce some more options other than |
Yes :) but we can see about this later down the line :) I think this PR is in a good enough state already if you fix the few suggestions I left, and we can merge it :) |
114584f
to
c532055
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.
Great stuff :) is this still a draft or are you happy enough for us to merge it?
Yes, I was just waiting for the checks to pass. |
…atic/logical expressions and literals. gcc/rust/ChangeLog: * hir/rust-hir-dump.cc (Dump::go): support inner attrs, crate items and node mappings (Dump::visit): support functions, arith/logical exprs, let stmts and literals Signed-off-by: Abdul Rafey <abdulrafeyq@gmail.com>
In this draft, I have attempted to implement some part of pretty HIR Dump to show the proposed format for HIR Dump. My approach in this is to avoid printing any empty fields of HIR nodes. In the pretty HIR dump of the code example given below, no attributes are present in the code for the crate, so you will not see inner attribute: [] at all. This makes the dump look cleaner as only the available information is printed.
Try this example for the dump
Seeking feedback for making it better :)
I will be making a GSOC proposal for this project.