-
Notifications
You must be signed in to change notification settings - Fork 244
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
proposal: wit-parser: create distinct imported and exported TypeDefs, Functions, and Interfaces in a Resolve #1497
Comments
I will take a look at this issue if no one has started looking into it |
Thanks @Mossaka! This is going to touch a lot of places in wasm-tools in some subtle ways, but in the end everything should be pretty straightforward except for the As usual I'm happy to help out with any questions and such, just ping me! |
Exported types referencing imported types should be interesting! |
Would it make sense for each Interface, TypeDef, and Function to have a reference to its symmetric other (import vs export) if it exists? |
This seems relevant to the discussion here: |
I feel this change could potentially also facilitate the solution we postponed as too complicated in #1438 (comment) - here only borrowed and exported resource handles should be considered as a pointer, all else as an s32. |
Indeed yeah this change should make that trivial |
@Mossaka you've probably realized or encountered this already: but I think this proposal means that every WorldItem would be duplicated at least once for each World in a Resolve. |
We propose to move logic from
wit-bindgen
into thewit-parser
crate that determines whether an interface, type, or function in aResolve
structure is either imported or exported, and label those structures as such.Interface
,Function
, andTypeDef
structs to indicate whether it is imported or exported.World
would be duplicated (if necessary) and have the relevant import/export attribute.Resolve
(e.g.wasm-tools component wit -j ...
) to include the import/export attribute.Context
This is a followup from a conversation in Zulip regarding imported and exported types in a
Resolve
.Currently, any types (represented as a
TypeDef
), functions (Function
), and interfaces (Interface
) are represented once in theResolve
data structure (and its JSON representation). This means that each bindings generator that depends on thewit-parser
crate must reimplement the heuristic to determine when to use an imported type versus an exported type.Per @alexcrichton:
For given interface
utils
, and a typefd
defined in a different interfacetypes
:This would simplify the implementation of bindings generators, such as wit-bindgen-go, which could then depend on the import/export resolution in
wit-parser
.The text was updated successfully, but these errors were encountered: