saulecabrera opened PR #5139 from expose-type-info-in-translation
to main
:
@alexcrichton following up from our Zulip discussion last week.
This adds a new field
types
toModuleTranslation
, so that consumers can have access to the module type information known after validation has finished. This change is useful when consumers want to have access to the type information in wasmparser's terms rather than in wasmtime_environ's equivalent types (e.g.WasmFuncType
).I went with the simplest approach, wrapping the
Types
withOption
, and introducing a method to get the types to preserve the invariant that after a successful translation, types should always be available. But I also considered some alternatives, so I'm happy to change this if any of the other alternatives are preferred.Other alternatives considered:
- Making
wasmparser::types::Types
deriveDefault
. To achieve this,wasmparser::validator::types::TypesKind
, should also need to deriveDefault
, and the question that pops up here is, which is a good default forTypesKind
? We could go with either or, but I'm not convinced that semantically it makes sense, IMO if we're going this route, it probably makes more sense to have an extra entry to represent the "untyped" state.- Introduce a module translation builder of some sort, and use that instead of
ModuleTranslation
for the translation/validation process. This would allow avoiding theOption
, but seems a lot of duplication for a single field.<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
alexcrichton submitted PR review.
alexcrichton merged PR #5139.
Last updated: Nov 22 2024 at 16:03 UTC