Skip to content

Commit

Permalink
Desugar type use abbreviation (#16)
Browse files Browse the repository at this point in the history
As an abbreviation [0], a type use [1] can be replaced by inline
parameter and result declarations: instead of writing e.g. `(func (type
$t) …)` and defining `$t` elsewhere in the module with `(type $t (func
(param i32) (result i64)))`, we can write the more concise and
expressive `(func (param i32) (result i64) …)`.

To support this abbreviation, a WebAssembly implementation must
automatically insert a type index referring either to a matching type
definition in the current module (e.g. `$t` above) or a newly-inserted
type definition if no matching one exists.

This commit implements desugaring for this abbreviation in the
preprocessor and removes support for it from the AST parser. It relies
upon machinery introduced in #14 and #15 which allows type definitions
to be collected while preprocessing a module’s fields and then provided
to the deferred result to yield the final S-expressions.

[0] https://webassembly.github.io/spec/core/text/modules.html#abbreviations
[1] https://webassembly.github.io/spec/core/text/modules.html#type-uses
  • Loading branch information
tomstuart committed Jul 20, 2023
2 parents 370c28a + a998b64 commit 59e4f32
Show file tree
Hide file tree
Showing 3 changed files with 415 additions and 173 deletions.

0 comments on commit 59e4f32

Please sign in to comment.