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

Module Visitor Pattern for manipulating BinaryModules #4

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

jtenner
Copy link
Contributor

@jtenner jtenner commented Sep 4, 2024

The visitor pattern looks something like this in pseudocode:

fn do_visit_type(ctx, value, visitor) {
  use #(ctx, value) <- try(do_visit(ctx, value, visitor.on_enter_type))
  use #(ctx, value) <- try(case value {
    Variant -> do_visit(ctx, value, visitor.on_enter_variant)
    // ..
  })
  use #(ctx, child_element) <- try(do_visit_child_element(ctx, value.child_element, visitor))
  
  use #(ctx, value) <- try(case value {
    Variant -> do_visit(ctx, value, visitor.on_exit_variant)
    // ..
  })
 
  do_visit(ctx, value, visitor.on_exit_type)   
}

Steps:

  1. Visit Type on_enter
  2. Visit variant on_enter
  3. Visit all children elements (based on type too)
  4. Visit variant on_exit
  5. Visit Type on_exit

What do you think?

@jtenner jtenner added enhancement New feature or request question Further information is requested labels Sep 4, 2024
@jtenner jtenner requested a review from rishitc September 4, 2024 23:11
@jtenner jtenner self-assigned this Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants