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

refactor PolicyExpr to use Visitor Pattern #458

Merged
merged 1 commit into from
Oct 11, 2024

Conversation

j-lanson
Copy link
Collaborator

Resolves #457 .

This is also a portion of the proposed changes in #456 RFD8 .

  1. Updates some Expr variants to have their own proper structs so we can have visit_X patterns on them
  2. Add Into<Expr> for each Expr sub-type to make it easier to turn a proper struct into its Expr variant
  3. Added ExprVisitor pattern
  4. Implemented ExprVisitor to perform policy expr execution, replaced pub(crate) eval() func

Currently ExprVisitor is implemented on Env<'_>, but as is mentioned in the RFD, we might want other "visitors" on an Expr tree. In a subsequent PR as it becomes relevant, I recommend changing it so Executor implments ExprVisitor and the env.rs functions like binary_primitive_op are changed to take a &Executor. This way, additional structs that take an Env can be created to impl ExprVisitor to do different behavior.

@j-lanson j-lanson added type: chore Clean up or management task. type: refactor Changes to code structure that do not impact functionality product: hc Relates to the core "hc" binary labels Sep 27, 2024
@j-lanson j-lanson added this to the 3.8.0 milestone Sep 27, 2024
@j-lanson j-lanson requested review from alilleybrinker and a team September 27, 2024 20:59
@alilleybrinker alilleybrinker merged commit c73d761 into main Oct 11, 2024
9 checks passed
@alilleybrinker alilleybrinker deleted the jlanson/policy-expr-visitor branch November 5, 2024 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product: hc Relates to the core "hc" binary type: chore Clean up or management task. type: refactor Changes to code structure that do not impact functionality
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Transition policy expression implementation to use the visitor pattern
2 participants