Enable more than one handle type in *.witx#421
Merged
Conversation
This commit reworks how handle types work at the representation level in
`*.witx` file to follow the expected design of resources in the
interface types specification. Previously handle types were simply
`(handle)`, which meant that there could only be one actual handle type
in the world (structurally at least). After this commit, however, there
can be multiple handle types.
First abstract types must be introduced as a `resource`, for example:
(resource $fd)
This declares that the module exports a type named `$fd` and it's
abstract in that the representation is not known. At the interface layer
you can't pass an `$fd` directly because it's representation is not
known. To do that, however, you can do:
(param $x (handle $fd))
The `handle` type now refers to a particular `resource` that it refers
to. Values of type `handle T` can exist and are what's passed at the
boundaries.
This is all largely just an internal structuring concern at this point.
This has no ramifications for WASI which still has an `$fd` type for
functions that is represented with an `i32`. This is largely a
forward-looking change to allow multiple types of resources defined by
different modules and all used by one another.
This commit also updates `use` syntax where `use` will pull from either
the type or the resource namespace. Furthermore a new `(use ($foo as
$bar) ...)` syntax was added to locally renamed something within a module.
sunfishcode
approved these changes
Mar 30, 2021
sunfishcode
left a comment
Member
There was a problem hiding this comment.
Looks great!
It appears that handles aren't yet displayed in the docs.md; would it be a lot of work to add that? In any case though, I don't think it's urgent, because the doc comments on the handle types are where the main documentation is.
pchickey
approved these changes
Mar 30, 2021
Contributor
Author
|
Ah that's true, although it wouldn't be too hard to add documentation for |
cratelyn
pushed a commit
to cratelyn/WASI
that referenced
this pull request
Jun 21, 2021
…)" This reverts commit 834679b.
Merged
alexcrichton
pushed a commit
that referenced
this pull request
Jun 21, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit reworks how handle types work at the representation level in
*.witxfile to follow the expected design of resources in theinterface types specification. Previously handle types were simply
(handle), which meant that there could only be one actual handle typein the world (structurally at least). After this commit, however, there
can be multiple handle types.
First abstract types must be introduced as a
resource, for example:This declares that the module exports a type named
$fdand it'sabstract in that the representation is not known. At the interface layer
you can't pass an
$fddirectly because it's representation is notknown. To do that, however, you can do:
The
handletype now refers to a particularresourcethat it refersto. Values of type
handle Tcan exist and are what's passed at theboundaries.
This is all largely just an internal structuring concern at this point.
This has no ramifications for WASI which still has an
$fdtype forfunctions that is represented with an
i32. This is largely aforward-looking change to allow multiple types of resources defined by
different modules and all used by one another.
This commit also updates
usesyntax whereusewill pull from eitherthe type or the resource namespace. Furthermore a new
(use ($foo as $bar) ...)syntax was added to locally renamed something within a module.