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

Handle each kind of module field separately in preprocessor #5

Merged
merged 24 commits into from
Jun 11, 2023

Commits on Jun 11, 2023

  1. Lift #read_list helper to the top of #process_field

    This does mean we have to temporarily match against the entire
    S-expression instead of peeking at it, but that’ll go away once we start
    consuming it incrementally. For now the priority is to get #read_list
    lifted out of #process_field so that it’s operating entirely inside a
    list like all the other methods do.
    tomstuart committed Jun 11, 2023
    Configuration menu
    Copy the full SHA
    41a1d6c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6ec6531 View commit details
    Browse the repository at this point in the history
  3. Remove redundant #read_list

    We were only wrapping `field` in a single-element array because it was
    being passed to the #read_list helper inside #process_field, but now the
    helper’s moved next to the array, the two cancel each other out.
    tomstuart committed Jun 11, 2023
    Configuration menu
    Copy the full SHA
    c93f005 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    a9cea18 View commit details
    Browse the repository at this point in the history
  5. Use #process_fields helper to recursively desugar inline export

    Although this is slightly less efficient, it more directly resembles the
    specification of export abbreviations (e.g. [0]) and so should be easier
    to understand at a glance.
    
    [0] https://webassembly.github.io/spec/core/text/modules.html#text-global-abbrev
    tomstuart committed Jun 11, 2023
    Configuration menu
    Copy the full SHA
    0fb3f0d View commit details
    Browse the repository at this point in the history
  6. Use the same recursive desugaring technique in #expand_inline_module

    Just as in #expand_inline_export, we can use #process_command to desugar
    the result of expanding the module abbreviation [0].
    
    [0] https://webassembly.github.io/spec/core/text/modules.html#id10
    tomstuart committed Jun 11, 2023
    Configuration menu
    Copy the full SHA
    02c988e View commit details
    Browse the repository at this point in the history
  7. Allow field-processing methods to return an array of fields

    This makes it possible for each method to expand inline exports, which
    produce multiple fields. In practice it’s only #process_function that
    needs to do this, but I’ve made the same change to #process_type
    and #process_import to keep all of the field-processing methods
    consistent.
    tomstuart committed Jun 11, 2023
    Configuration menu
    Copy the full SHA
    9b15b3a View commit details
    Browse the repository at this point in the history
  8. Add _definition suffix to #process_function and #process_type

    The spec calls these fields “function definitions” [0] and “type
    definitions” [1], so we should use the same terminology here.
    
    [0] https://webassembly.github.io/spec/core/text/modules.html#functions
    [1] https://webassembly.github.io/spec/core/text/modules.html#types
    tomstuart committed Jun 11, 2023
    Configuration menu
    Copy the full SHA
    37daf8f View commit details
    Browse the repository at this point in the history
  9. Expand inline imports & exports inside #process_function_definition

    This removes the need to support inline imports & exports for functions
    in #process_field.
    tomstuart committed Jun 11, 2023
    Configuration menu
    Copy the full SHA
    f07b595 View commit details
    Browse the repository at this point in the history
  10. Remove inline function import & export support from #process_field

    It’s handled in #process_function_definition now.
    tomstuart committed Jun 11, 2023
    Configuration menu
    Copy the full SHA
    af35a58 View commit details
    Browse the repository at this point in the history
  11. Add handler for inline imports & exports in table/memory/global defin…

    …itions
    
    This removes the need to support inline imports & exports for any kind
    of field in #process_field.
    tomstuart committed Jun 11, 2023
    Configuration menu
    Copy the full SHA
    c78852a View commit details
    Browse the repository at this point in the history
  12. Remove inline import & export support from #process_field

    It’s entirely handled in field-specific methods now.
    tomstuart committed Jun 11, 2023
    Configuration menu
    Copy the full SHA
    93ea808 View commit details
    Browse the repository at this point in the history
  13. Move inline import & export methods further down the file

    They’re called by both #process_function_definition
    and #process_table_memory_global_definition, and the code is easier to
    read if callers come before callees.
    tomstuart committed Jun 11, 2023
    Configuration menu
    Copy the full SHA
    52fd493 View commit details
    Browse the repository at this point in the history
  14. Lift field kind #read out of #expand_inline_import & #expand_inline_e…

    …xport
    
    We really want to get the optional ID out of the way, but we have to
    read the field kind first.
    tomstuart committed Jun 11, 2023
    Configuration menu
    Copy the full SHA
    5d5082f View commit details
    Browse the repository at this point in the history
  15. Lift field kind #read to the top of #process_function_definition & #p…

    …rocess_table_memory_global_definition
    tomstuart committed Jun 11, 2023
    Configuration menu
    Copy the full SHA
    80d5218 View commit details
    Browse the repository at this point in the history
  16. Extract helpers for handling inline imports & exports together

    We need to do the same work to handle inline imports & exports for
    function and table/memory/global definitions, so it’s convenient to move
    the duplicated code into helpers.
    tomstuart committed Jun 11, 2023
    Configuration menu
    Copy the full SHA
    d818769 View commit details
    Browse the repository at this point in the history
  17. Decouple ID #read from the rest of #expand_inline_export

    We’d like to lift the #read out of this method, so we can’t use it
    directly in a conditional. Fortunately we can check its side-effect (of
    assigning to `id`) instead.
    tomstuart committed Jun 11, 2023
    Configuration menu
    Copy the full SHA
    9b9d070 View commit details
    Browse the repository at this point in the history
  18. Reorganise #expand_inline_export to look more like #expand_inline_import

    Rather than doing the reads inline when they’re needed, we read
    everything together first and then build the result. The increased
    similarity to #expand_inline_import makes the methods easier to compare
    at a glance.
    tomstuart committed Jun 11, 2023
    Configuration menu
    Copy the full SHA
    0621dd7 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    bed6db7 View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    7d457fb View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    810a53b View commit details
    Browse the repository at this point in the history
  22. Lift ID #read to the top of #process_function_definition & #process_t…

    …able_memory_global_definition
    tomstuart committed Jun 11, 2023
    Configuration menu
    Copy the full SHA
    3355307 View commit details
    Browse the repository at this point in the history
  23. Detect inline imports & exports by peeking

    We now only need to look at the next thing we’ll read, not the entire
    S-expression.
    tomstuart committed Jun 11, 2023
    Configuration menu
    Copy the full SHA
    baca242 View commit details
    Browse the repository at this point in the history
  24. Split #process_table_memory_global_definition into per-field methods

    Table, memory and global definitions support different abbreviations, so
    each will need its own slightly different method.
    tomstuart committed Jun 11, 2023
    Configuration menu
    Copy the full SHA
    3e961a6 View commit details
    Browse the repository at this point in the history