Rust-GCC / Rust-GCC/gccrs

Change HIR visitor pattern

Open
#3,160 5 comments 0 reactions 0 assignees View on GitHub

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:

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.