Skip to content

Commit d2efa00

Browse files
committed
Implement a new use syntax
This commit implements a new `use` syntax which changes (use "foo.witx") to (use $some $type $names from $foo) This change ended up being much larger than originally intended. While at a surface level switching this style of `use` statements isn't too bad it has large ramifications on the mental model of how to interpret and work with `*.witx` files. This necessitated some internal refactorings which ended up as a bit of a yak shave. The other changes here are: * The `polyfill` module is removed. I confirmed with Pat that this isn't used anymore and this came about trying to update it from the below refactorings. * The `render` module is removed. Documents can no longer be serialized to a standalone s-expression because they can refer to other documents in a structured manner. It's also believed there are no current users of this functionality. * The `representation` module was removed since it was largely only used by the `polyfill` module. * The `Document` type was renamed to `Module`, and the ability for a document to contain multiple modules has been removed. When working with multiple modules this must now be done so explicitly instead of having it all lumped into one parsed object. This means that `Module` is now a list of types and a list of functions. * Documentation has changed to document a set of modules instead of a single module. Additionally this is nontrivially changed to load types transitively from all modules referenced to ensure that all relevant types are documented. * Internal refactorings in the validation phase have been done to streamline a few things and consolidate where possible with this new structuring. * `InterfaceFunc` is now named `Function` * `InterfaceFuncParam` is now named `Param` * `Module` has a `name` (as before) which is now inferred from the filename it's loaded from. * `Module` has a `ModuleId` now to represent types that are defined in other modules, where `ModuleId` is intended to be a unique identifier amongst a set of modules. For now it's just a path name but can likely get more fancy in the future if needed. All `*.witx` files have been updated to the new syntax in this repository. Lots of changes look like they happened to the proposal documentation, but that's just because the documentation order of types has been shuffled around. I've checked to make sure no actual items were lost from the documentation. Closes #378 Closes #379
1 parent a9671af commit d2efa00

39 files changed

+2298
-3586
lines changed

phases/ephemeral/docs.md

Lines changed: 527 additions & 553 deletions
Large diffs are not rendered by default.

phases/ephemeral/witx/wasi_ephemeral_args.witx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/tree/master/docs/witx.md)
44
;; for an explanation of what that means.
55

6-
(use "typenames.witx")
6+
(use $errno $size from $typenames)
77

88
(module $wasi_ephemeral_args
9-
;;; Linear memory to be accessed by WASI functions that need it.
10-
(import "memory" (memory))
11-
129
;;; Read command-line argument data.
1310
;;; The size of the array should match that returned by `sizes_get`.
1411
;;; Each argument is expected to be `\0` terminated.

phases/ephemeral/witx/wasi_ephemeral_clock.witx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@
55
;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/tree/master/docs/witx.md)
66
;; for an explanation of what that means.
77

8-
(use "typenames.witx")
8+
(use $clockid $timestamp $errno from $typenames)
99

1010
(module $wasi_ephemeral_clock
11-
;;; Linear memory to be accessed by WASI functions that need it.
12-
(import "memory" (memory))
13-
1411
;;; Return the resolution of a clock.
1512
;;; Implementations are required to provide a non-zero value for supported clocks. For unsupported clocks,
1613
;;; return `errno::inval`.

phases/ephemeral/witx/wasi_ephemeral_environ.witx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/tree/master/docs/witx.md)
44
;; for an explanation of what that means.
55

6-
(use "typenames.witx")
6+
(use $errno $size from $typenames)
77

88
(module $wasi_ephemeral_environ
9-
;;; Linear memory to be accessed by WASI functions that need it.
10-
(import "memory" (memory))
11-
129
;;; Read environment variable data.
1310
;;; The sizes of the buffers should match that returned by `sizes_get`.
1411
;;; Key/value pairs are expected to be joined with `=`s, and terminated with `\0`s.

phases/ephemeral/witx/wasi_ephemeral_fd.witx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@
55
;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/tree/master/docs/witx.md)
66
;; for an explanation of what that means.
77

8-
(use "typenames.witx")
8+
(use * from $typenames)
99

1010
(module $wasi_ephemeral_fd
11-
;;; Linear memory to be accessed by WASI functions that need it.
12-
(import "memory" (memory))
13-
1411
;;; Provide file advisory information on a file descriptor.
1512
;;; Note: This is similar to `posix_fadvise` in POSIX.
1613
(@interface func (export "advise")

phases/ephemeral/witx/wasi_ephemeral_path.witx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@
55
;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/tree/master/docs/witx.md)
66
;; for an explanation of what that means.
77

8-
(use "typenames.witx")
8+
(use * from $typenames)
99

1010
(module $wasi_ephemeral_path
11-
;;; Linear memory to be accessed by WASI functions that need it.
12-
(import "memory" (memory))
13-
1411
;;; Create a directory.
1512
;;; Note: This is similar to `mkdirat` in POSIX.
1613
(@interface func (export "create_directory")

phases/ephemeral/witx/wasi_ephemeral_poll.witx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@
55
;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/tree/master/docs/witx.md)
66
;; for an explanation of what that means.
77

8-
(use "typenames.witx")
8+
(use $event $subscription $size $errno from $typenames)
99

1010
(module $wasi_ephemeral_poll
11-
;;; Linear memory to be accessed by WASI functions that need it.
12-
(import "memory" (memory))
13-
1411
;;; Concurrently poll for the occurrence of a set of events.
1512
;;;
1613
;;; If `nsubscriptions` is 0, returns `errno::inval`.

phases/ephemeral/witx/wasi_ephemeral_proc.witx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/tree/master/docs/witx.md)
66
;; for an explanation of what that means.
77

8-
(use "typenames.witx")
8+
(use $exitcode from $typenames)
99

1010
(module $wasi_ephemeral_proc
1111
;;; Terminate the process normally. An exit code of `$exitcode::success`

phases/ephemeral/witx/wasi_ephemeral_random.witx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@
55
;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/tree/master/docs/witx.md)
66
;; for an explanation of what that means.
77

8-
(use "typenames.witx")
8+
(use $errno $size from $typenames)
99

1010
(module $wasi_ephemeral_random
11-
;;; Linear memory to be accessed by WASI functions that need it.
12-
(import "memory" (memory))
13-
1411
;;; Write high-quality random data into a buffer.
1512
;;; This function blocks when the implementation is unable to immediately
1613
;;; provide sufficient high-quality random data.

phases/ephemeral/witx/wasi_ephemeral_sched.witx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/tree/master/docs/witx.md)
66
;; for an explanation of what that means.
77

8-
(use "typenames.witx")
8+
(use $errno from $typenames)
99

1010
(module $wasi_ephemeral_sched
1111
;;; Temporarily yield execution of the calling thread.

phases/ephemeral/witx/wasi_ephemeral_sock.witx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@
55
;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/tree/master/docs/witx.md)
66
;; for an explanation of what that means.
77

8-
(use "typenames.witx")
8+
(use * from $typenames)
99

1010
(module $wasi_ephemeral_sock
11-
;;; Linear memory to be accessed by WASI functions that need it.
12-
(import "memory" (memory))
13-
1411
;;; Receive a message from a socket.
1512
;;; Note: This is similar to `recv` in POSIX, though it also supports reading
1613
;;; the data into multiple buffers in the manner of `readv`.

0 commit comments

Comments
 (0)