-
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
Refactor interface type representation in wast
#607
Merged
alexcrichton
merged 2 commits into
bytecodealliance:main
from
alexcrichton:intertype-primitive-not-through-ref
May 18, 2022
Merged
Refactor interface type representation in wast
#607
alexcrichton
merged 2 commits into
bytecodealliance:main
from
alexcrichton:intertype-primitive-not-through-ref
May 18, 2022
Conversation
This file contains 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
This commit updates the `wast` representation of interface types to match more closely what `wasmparser` does. Previously `wast` primarily used `ComponentTypeUse<'_, InterType<'_>>` for references and `InterType<'_>` for definitions. This meant, though, that references could not use primitives by-value. Additionally it also meant that the parsing for `ComponentTypeUse` actually used `IndexOrRef` to parse either `$t` or `(type $t)` but `ComponentTypeUse` is used for many other constructs where it would not be appropriate for a bare index `$t` to be parsed, for example this should not parse: (component (type $ty (module)) (import "" (module $m $ty))) This commit instead refactors all uses of `ComponentTypeUse<'_, InterType<'_>>` to instead use a new `InterTypeRef<'_>` construct. Additionally a `Primitive` was split out from the existing `InterType<'_>` and added as a variant to the `InterTypeRef<'_>` enum as well. This reflects the organization in the `wasmparser` crate and means that primitive types can be used inline instead of references and such. Closes bytecodealliance#600
peterhuene
approved these changes
May 18, 2022
crates/wast/src/component/expand.rs
Outdated
} | ||
// And if this type isn't already defined we append it to the index | ||
// space with a fresh and unique name. | ||
let span = Span::from_offset(0); // FIXME: don't manufacture |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need an issue to track this FIXME
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure yeah, I'll tag a few places with this.
code-terror
pushed a commit
to code-terror/wasm-tools
that referenced
this pull request
Aug 24, 2022
* Refactor interface type representation in `wast` This commit updates the `wast` representation of interface types to match more closely what `wasmparser` does. Previously `wast` primarily used `ComponentTypeUse<'_, InterType<'_>>` for references and `InterType<'_>` for definitions. This meant, though, that references could not use primitives by-value. Additionally it also meant that the parsing for `ComponentTypeUse` actually used `IndexOrRef` to parse either `$t` or `(type $t)` but `ComponentTypeUse` is used for many other constructs where it would not be appropriate for a bare index `$t` to be parsed, for example this should not parse: (component (type $ty (module)) (import "" (module $m $ty))) This commit instead refactors all uses of `ComponentTypeUse<'_, InterType<'_>>` to instead use a new `InterTypeRef<'_>` construct. Additionally a `Primitive` was split out from the existing `InterType<'_>` and added as a variant to the `InterTypeRef<'_>` enum as well. This reflects the organization in the `wasmparser` crate and means that primitive types can be used inline instead of references and such. Closes bytecodealliance#600 * List an issue in FIXME annotations
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 updates the
wast
representation of interface types tomatch more closely what
wasmparser
does. Previouslywast
primarilyused
ComponentTypeUse<'_, InterType<'_>>
for references andInterType<'_>
for definitions. This meant, though, that referencescould not use primitives by-value. Additionally it also meant that the
parsing for
ComponentTypeUse
actually usedIndexOrRef
to parseeither
$t
or(type $t)
butComponentTypeUse
is used for many otherconstructs where it would not be appropriate for a bare index
$t
to beparsed, for example this should not parse:
This commit instead refactors all uses of
ComponentTypeUse<'_, InterType<'_>>
to instead use a newInterTypeRef<'_>
construct. Additionally aPrimitive
was split outfrom the existing
InterType<'_>
and added as a variant to theInterTypeRef<'_>
enum as well. This reflects the organization in thewasmparser
crate and means that primitive types can be used inlineinstead of references and such.
Closes #600