Skip to content

Commit 040a222

Browse files
authored
wasmparser: Refactor canonical option validation and func type lowering (#2163)
* wasmparser: Refactor canonical option validation and func type lowering Rather than repeatedly searching the list of canonical options, create a `struct CanonicalOptions` that summarizes their meaning when taken altogether. This `struct` is returned from `check_options`, where some initial, light validation occurs. Then, additional methods like `options.require_memory()?` can be called on the resulting `struct` depending on the use site (e.g. lifting vs. lowering vs. `task.return` vs. etc...). This also makes it so that `check_options` does not require a `LoweringInfo` as a parameter. That presupposes that we already know the core function signature we will be lowering into. That will no longer be true with the combination of Wasm GC and the component model, where there will be a canonical option to specify the desired core function type, and this controls whether GC is used or not, among other things. Finally, the `ComponentFuncType::lower` method is now invoked after canonical options are checked and takes a `CanonicalOptions` argument. Rather than setting `info.requires_memory = true` when it determines that a memory is required (for example) which was then validated in `check_options` later on, it has become fallible and calls `options.require_memory()?` itself to validate that a memory is declared. Again, this fallibility will be required for Wasm GC and component model integration in the future. * make match more explicit
1 parent 4cb6e03 commit 040a222

File tree

7 files changed

+325
-294
lines changed

7 files changed

+325
-294
lines changed

0 commit comments

Comments
 (0)