wast-parser: add support for '(module definition ...)'
WASM v3 spec tests added the '(module definition ...)' construct to WAST. This tells the test runner that the module should not be instantiated immediately. The '(module instance ...)' construct (not yet supported in wabt) instructs the test runner to instantiate the module.
This change adds an is_definition field to ScriptModule. The field reflects whether the definition keyword was encountered after the module keyword.
When WastParser encounters a TextModule in a script command, it now returns a ScriptModule with the corresponding ScriptTextModule if the module is definition-only.
This change allows wabt to parse WASM v3 spec tests that use the (module definition ...) construct (specifically, memory.wast), so that test runners built on wabt can support WASM v3 spec tests.
@zherczeg, have you run into this in any of your recent wasm-3.0 work on wabt? Is it part of one of you in-flight PRs maybe?
Is (module instance ...) the default behaviour? i.e. if you don't specify either instance or definition?
As far as I know, (module instance $x) instructs the test runner to instantiate a module that was defined like (module definition $x ...).
(module instance ...) is not allowed to have the actual definition.
No, this is not used by the GC proposal. I plan to continue working on WASM 3.0 later.
@sjamesr have you verified this fix works for your external use case? If so then landing this now (even though we don't need to locally) does not seem unreasonable.
Could you perhaps update the PR description mentioning why this is useful to you even though wabt itself doesn't currently use this?
I added a paragraph to the commit and PR descriptions.
I haven't actually tried it out against the v3 spec yet, so perhaps we can hold off on merging the request. I'll continue working on the assumption that we'll merge it or something like it. Just knowing that it's generally acceptable is useful, thanks!
The patch LGTM. If you are OK with waiting for our own wasm-3.0 update (not sue how long that might be sadly) that might be best, since then it will get a some real testing.
If you need the landed earlier thats probably fine too, just let us know,