Skip to content

Re-organize witx AST#154

Merged
pchickey merged 6 commits intomasterfrom
pch/reorg_ast
Nov 22, 2019
Merged

Re-organize witx AST#154
pchickey merged 6 commits intomasterfrom
pch/reorg_ast

Conversation

@pchickey
Copy link
Copy Markdown
Contributor

@pchickey pchickey commented Nov 22, 2019

The witx::ast types had some confusing choices that I blame on building the first draft of the tool in a hurry. This redesigns the AST a bit:

  • I used Datatype/datatype in a number of places where witx syntax and wasm just call things types. The data-prefix has been dropped in many places. StructDatatype, UnionDatatype and friends still retain the "data" part of the name, but that seems less problematic.
  • instead of two enumerations (DatatypeIdent and DatatypeVariant) holding different variations (arrays and pointers and builtins falling under Ident, everything else in variant) there is now just one enum Type that has each possible variation in a datatype
  • Types can either be anonymous (e.g. an (array u8) in a function argument) or named (by (typename ...). An enum TypeRef gives a type either by Value(Type) or Name(NamedType).
  • Only NamedTypes have docs.
  • Instead of considering Aliases as a variation of a datatype, they are now encoded using TypeRef: (typename $a u32) is a NamedType { name: "a", dt: TypeRef::Value(Type::Builtin(BuiltinType::U32)) }.

I was able to change the wasi-headers tool over in wasi-libc to consume the new witx ast pretty quickly, and it even managed to fix a minor bug involving aliasing. I'll send a PR there and also to the other witx-using crate in https://github.com/bytecodealliance/wasi shortly.

Copy link
Copy Markdown
Contributor

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks and sounds great to me!

Copy link
Copy Markdown
Member

@sunfishcode sunfishcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! This should enable some nice simplifications.

@pchickey pchickey merged commit 8ff4e84 into master Nov 22, 2019
@pchickey pchickey deleted the pch/reorg_ast branch November 22, 2019 17:52
yoshuawuyts pushed a commit to yoshuawuyts/WASI that referenced this pull request Nov 25, 2025
The witx::ast types had some confusing choices that I blame on building the first draft of the tool in a hurry. This redesigns the AST a bit:

I used Datatype/datatype in a number of places where witx syntax and wasm just call things types. The data-prefix has been dropped in many places. StructDatatype, UnionDatatype and friends still retain the "data" part of the name, but that seems less problematic.
instead of two enumerations (DatatypeIdent and DatatypeVariant) holding different variations (arrays and pointers and builtins falling under Ident, everything else in variant) there is now just one enum Type that has each possible variation in a datatype
Types can either be anonymous (e.g. an (array u8) in a function argument) or named (by (typename ...). An enum TypeRef gives a type either by Value(Type) or Name(NamedType).
Only NamedTypes have docs.
Instead of considering Aliases as a variation of a datatype, they are now encoded using TypeRef: (typename $a u32) is a NamedType { name: "a", dt: TypeRef::Value(Type::Builtin(BuiltinType::U32)) }.


* witx: reorganize the AST

this has highlighted some issues with the grammar, unfortunately

* wip

* continued work on tests

* witx: all tests pass!!

* rename Datatype to Type, so ast is closer to syntax

* fix docs output
yoshuawuyts pushed a commit to yoshuawuyts/WASI that referenced this pull request Nov 25, 2025
The witx::ast types had some confusing choices that I blame on building the first draft of the tool in a hurry. This redesigns the AST a bit:

I used Datatype/datatype in a number of places where witx syntax and wasm just call things types. The data-prefix has been dropped in many places. StructDatatype, UnionDatatype and friends still retain the "data" part of the name, but that seems less problematic.
instead of two enumerations (DatatypeIdent and DatatypeVariant) holding different variations (arrays and pointers and builtins falling under Ident, everything else in variant) there is now just one enum Type that has each possible variation in a datatype
Types can either be anonymous (e.g. an (array u8) in a function argument) or named (by (typename ...). An enum TypeRef gives a type either by Value(Type) or Name(NamedType).
Only NamedTypes have docs.
Instead of considering Aliases as a variation of a datatype, they are now encoded using TypeRef: (typename $a u32) is a NamedType { name: "a", dt: TypeRef::Value(Type::Builtin(BuiltinType::U32)) }.


* witx: reorganize the AST

this has highlighted some issues with the grammar, unfortunately

* wip

* continued work on tests

* witx: all tests pass!!

* rename Datatype to Type, so ast is closer to syntax

* fix docs output
yoshuawuyts pushed a commit to yoshuawuyts/WASI that referenced this pull request Nov 25, 2025
This commit changes wasi:http/types#body.finish to forward the
optionally present trailers, rather than retrieve them with the
possibility of generating an error along the way.

With this change, callers of `body.finish` will have to retreive
trailers on their own, which *may* produce an efficiency gain in the
case where trailers are present but not needed, and avoiding work of
checking for trailers in the first place.

Signed-off-by: Victor Adossi <vadossi@cosmonic.com>
yoshuawuyts pushed a commit to yoshuawuyts/WASI that referenced this pull request Nov 25, 2025
The witx::ast types had some confusing choices that I blame on building the first draft of the tool in a hurry. This redesigns the AST a bit:

I used Datatype/datatype in a number of places where witx syntax and wasm just call things types. The data-prefix has been dropped in many places. StructDatatype, UnionDatatype and friends still retain the "data" part of the name, but that seems less problematic.
instead of two enumerations (DatatypeIdent and DatatypeVariant) holding different variations (arrays and pointers and builtins falling under Ident, everything else in variant) there is now just one enum Type that has each possible variation in a datatype
Types can either be anonymous (e.g. an (array u8) in a function argument) or named (by (typename ...). An enum TypeRef gives a type either by Value(Type) or Name(NamedType).
Only NamedTypes have docs.
Instead of considering Aliases as a variation of a datatype, they are now encoded using TypeRef: (typename $a u32) is a NamedType { name: "a", dt: TypeRef::Value(Type::Builtin(BuiltinType::U32)) }.


* witx: reorganize the AST

this has highlighted some issues with the grammar, unfortunately

* wip

* continued work on tests

* witx: all tests pass!!

* rename Datatype to Type, so ast is closer to syntax

* fix docs output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants