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

TIR: Add Map and Visit traits to the tir::Visitor in order to reduce code duplication #984

Merged
merged 4 commits into from
Sep 18, 2023

Conversation

kontheocharis
Copy link
Collaborator

Instead of having fmap_* and visit_* functions for each TIR node, this PR replaces those with implementations of Visit<*> and Map<*>, so that functions can be implemented for any T that has Map<T> or Visit<T>. This reduces a lot of duplication in TC substitutions, and allows specialised functions to be created generically, for example to copy nodes, or to visit infallibly.

@kontheocharis kontheocharis added type-system Issues related with typechecking sub-system. organisation labels Sep 18, 2023
@kontheocharis kontheocharis self-assigned this Sep 18, 2023
feds01
feds01 previously approved these changes Sep 18, 2023
compiler/hash-tir/src/visitor.rs Outdated Show resolved Hide resolved
@kontheocharis kontheocharis merged commit 812e78c into main Sep 18, 2023
1 check passed
@kontheocharis kontheocharis deleted the tir-visitor-traits branch September 18, 2023 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
organisation type-system Issues related with typechecking sub-system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants