diff --git a/design/mvp/Binary.md b/design/mvp/Binary.md index 9a82702a..e4f1fdf6 100644 --- a/design/mvp/Binary.md +++ b/design/mvp/Binary.md @@ -36,6 +36,7 @@ section ::= section_0() => ϵ | s: section_9() => [s] | i*:section_10(vec()) => i* | e*:section_11(vec()) => e* + | v*:section_12(vec()) => v* ``` Notes: * Reused Core binary rules: [`core:section`], [`core:custom`], [`core:module`] @@ -346,6 +347,57 @@ Notes: * `` is as defined by the [SRI](https://www.w3.org/TR/SRI/#dfn-integrity-metadata) spec. +## Value Definitions + +(See [Value Definitions](Explainer.md#value-definitions) in the explainer.) + +```ebnf +value ::= t: v: => (value t v) +val(bool) ::= 0x00 => false + | 0x01 => true +val(u8) ::= v: => v +val(s8) ::= v: => v +val(s16) ::= v: => v +val(u16) ::= v: => v +val(s32) ::= v: => v +val(u32) ::= v: => v +val(s64) ::= v: => v +val(u64) ::= v: => v +val(f32) ::= v: => v +val(f64) ::= v: => v +val(char) ::= v: => v +val(string) ::= v: => v +val(i:) ::= v: => v (if (type t) = type-index-space[i]) +defval((record lt+)) ::= (v:)^n => v^n (if |lt*| > 0 and n = |lt*|) +defval((variant case*)) ::= i: v:caseval(c) => i v (if i < |case*| and c = case[i]) +defval((list t)) ::= vec() +defval((tuple t+)) ::= (v:)^n => v^n (if |t*| > 0 and n = |t*|) +defval((flags l+)) ::= v: => v (if |l*| > 0 and v < 2^|l*|) +defval((enum l*)) ::= i: => i v (if i < |l*|) +defval((option t)) ::= 0x00 => none + | 0x01 v: => (some v) +defval((result t? (error u)?)) ::= 0x00 => ok + | 0x00 v: => (ok v) + | 0x01 => error + | 0x01 v: => (error v) +fieldval((field l t)) ::= v: => v +caseval((case l t?)) ::= v?:? => v? +``` + +Notes: +* Reused Core binary rules: + - [`core:name`] + - [`core:s8`] + - [`core:s16`] + - [`core:s32`] + - [`core:s64`] + - [`core:u8`] + - [`core:u16`] + - [`core:u32`] + - [`core:u64`] + - [`core:f32`] + - [`core:f64`] + ## Name Section Like the core wasm [name @@ -375,7 +427,16 @@ appear once within a `name` section, for example component instances can only be named once. +[`core:s8`]: https://webassembly.github.io/spec/core/binary/values.html#integers +[`core:u8`]: https://webassembly.github.io/spec/core/binary/values.html#integers +[`core:s16`]: https://webassembly.github.io/spec/core/binary/values.html#integers +[`core:u16`]: https://webassembly.github.io/spec/core/binary/values.html#integers +[`core:s32`]: https://webassembly.github.io/spec/core/binary/values.html#integers [`core:u32`]: https://webassembly.github.io/spec/core/binary/values.html#integers +[`core:s64`]: https://webassembly.github.io/spec/core/binary/values.html#integers +[`core:u64`]: https://webassembly.github.io/spec/core/binary/values.html#integers +[`core:f32`]: https://webassembly.github.io/spec/core/binary/values.html#floating-point +[`core:f64`]: https://webassembly.github.io/spec/core/binary/values.html#floating-point [`core:section`]: https://webassembly.github.io/spec/core/binary/modules.html#binary-section [`core:custom`]: https://webassembly.github.io/spec/core/binary/modules.html#custom-section [`core:module`]: https://webassembly.github.io/spec/core/binary/modules.html#binary-module diff --git a/design/mvp/Explainer.md b/design/mvp/Explainer.md index aabc221e..3b6e21f3 100644 --- a/design/mvp/Explainer.md +++ b/design/mvp/Explainer.md @@ -25,6 +25,7 @@ JavaScript runtimes. For a more user-focussed explanation, take a look at the * [Canonical built-ins](#canonical-built-ins) * [Start definitions](#-start-definitions) * [Import and export definitions](#import-and-export-definitions) + * [Value definitions](#value-definitions) * [Component invariants](#component-invariants) * [JavaScript embedding](#JavaScript-embedding) * [JS API](#JS-API) @@ -87,6 +88,7 @@ definition ::= core-prefix() | 🪺 | | + | where core-prefix(X) parses '(' 'core' Y ')' when X parses '(' Y ')' ``` @@ -1633,7 +1635,12 @@ the standard [avoidance problem] that appears in module systems with abstract types. In particular, it ensures that a client of a component is able to externally define a type compatible with the exports of the component. +### 🪙 Value Definitions +Components may define values in the value index +```ebnf +value ::= t: v: => (value t v) +``` ## Component Invariants As a consequence of the shared-nothing design described above, all calls into