-
Notifications
You must be signed in to change notification settings - Fork 280
Refactor the AST of types in the witx
crate
#391
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
Merged
sunfishcode
merged 10 commits into
WebAssembly:main
from
alexcrichton:refactor-type-ast
Feb 11, 2021
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3bcf82b
Rename `Array` to `List`
alexcrichton 1fc1dd2
Rename structs to records
alexcrichton e6451fb
Add initial support for `variant` type
alexcrichton ce0c8c1
Remove `IntDatatype`
alexcrichton 01360e1
Implement enums in terms of `Variant`
alexcrichton 616dac9
Define `Flags` in terms of integers
alexcrichton de0b5ff
Represent strings as lists of `char` internally
alexcrichton cf29081
Implement Union in terms of Variant
alexcrichton a958d6a
Embed type-hint declarations in AST payloads
alexcrichton 2cdd6be
Address some review feedback
alexcrichton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
Oops, something went wrong.
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.
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.
It's not immediately clear why some
union
s such asevent_u
are migrated tovariant
and others, such assubscription_u
here, are left asunion
.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.
The desugaring is a bit tricky with the current ABI, but I generally tried to keep things as
union
where possible. By using@witx tag
theunion
's types must all mattch up exactly with the variants of thetag
(which should be anenum
).One place this was tripped up though was the
empty
case parsing for unions. That was where one entry of theunion
didn't have any payload. This didn't have any translation to this updatedunion
syntax where it must be a set of types that are union'd, so anything usingempty
was switch to the explicitvariant
.In general it doesn't matter too too much except from a readability perspective since this all desugars to the same thing in the AST, which is to say a tagged
variant
.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.
Is
variant
a superset of the functionality ofunion
? If so, I think it's ok to migrate tovariant
over time. To help readers, I do want to aim for a single syntax, but we can finish the migration later.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.
It is, yeah, mostly because
variant
is the actual thing in the AST whereasunion
is just syntax sugar as seen here .This will hopefully become less important over time as
@witx tag
is migrated away from perhaps? Otherwise though there could perhaps be more syntax sugar for aunion
where one of the cases is empty.