Change HIR visitor pattern
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 19h 55m
- Merged PRs (30d)
- 67
Description
HIR is in a bad state, multiple efforts could be started to improve the current situation. One of those could reduce the amount of code by removing boilerplate code within HIR visitors.
Most visitors currently have to redefine over and over traversal functions even when the visitor per se should only act on a few components.
Some proposals have been made to improve the general state of visitors within the project:
- https://github.com/Rust-GCC/gccrs/pull/2904#issuecomment-1995337505
- Separate walk from visit
- Provide a default walk/visit implementation to fall back on when no implementation is provided.
In the long run we should probably separate visit from walk in all our visitors but this requires an extensive refactor of multiple parts of the code base and multiple question remains (some AST visitors require infix operations).
We already provide an interface for HIR visitors: HIRFullVisitor.
- Take a look at the AST visitor mechanisms (
ASTDefaultVisitor,ASTVisitor,ASTContextualVisitor...) - Provide a default implementation for the HIR visitor.
- Remove empty visits functions from HIR visitor implementors
- Identify implementations in HIR visitor implementors where it could be replaced by a single call to parents' visit function.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing HIRFullVisitor interface and the AST visitor mechanisms named in the issue: ASTDefaultVisitor, ASTVisitor, and ASTContextualVisitor. Determine how a default HIR visitor implementation could support inherited traversal and which HIR visitor implementations contain empty or redundant visits. Done means the agreed visitor design is implemented and the affected implementations are simplified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100