@@ -36,6 +36,7 @@ section ::= section_0(<core:custom>) => ϵ
3636 | s: section_9(<start>) => [s]
3737 | i*:section_10(vec(<import>)) => i*
3838 | e*:section_11(vec(<export>)) => e*
39+ | v*:section_12(vec(<value>)) => v*
3940```
4041Notes:
4142* Reused Core binary rules: [ ` core:section ` ] , [ ` core:custom ` ] , [ ` core:module ` ]
@@ -346,6 +347,59 @@ Notes:
346347* ` <integrity-metadata> ` is as defined by the
347348 [ SRI] ( https://www.w3.org/TR/SRI/#dfn-integrity-metadata ) spec.
348349
350+ ## Value Definitions
351+
352+ (See [ Value Definitions] ( Explainer.md#value-definitions ) in the explainer.)
353+
354+ ``` ebnf
355+ value ::= t:<valtype> v:<val(t)> => (value t v)
356+ val(bool) ::= 0x00 => false
357+ | 0x01 => true
358+ val(u8) ::= v:<core:u8> => v
359+ val(s8) ::= v:<core:s8> => v
360+ val(s16) ::= v:<core:s16> => v
361+ val(u16) ::= v:<core:u16> => v
362+ val(s32) ::= v:<core:s32> => v
363+ val(u32) ::= v:<core:u32> => v
364+ val(s64) ::= v:<core:s64> => v
365+ val(u64) ::= v:<core:u64> => v
366+ val(f32) ::= v:<core:f32> => v
367+ val(f64) ::= v:<core:f64> => v
368+ val(char) ::= v:<core:u32> => v
369+ val(string) ::= v:<core:name> => v
370+ val(i:<typeidx>) ::= v:<defval(t)> => v (if (type t) = type-index-space[i])
371+ defval((record (field l t)+)) ::= v+:<val(t)>+ => { (l: v,)^(n-1) l[n-1]: v[n-1] } (if n = |l*|)
372+ defval((variant (case l t?)+) ::= i:<core:u32> v:val(t[i]) => l[i](v)
373+ defval((list t)) ::= v:vec(<val(t)>) => [v]
374+ defval((tuple t+)) ::= v+:<val(t)>+ => (v+)
375+ defval((flags l+)) ::= v:<core:u32> => ((l[i] (if and(v, 2^|i|) > 0))^(i:|l*|))
376+ defval((enum l*)) ::= i:<core:u32> => l[i]
377+ defval((option t)) ::= 0x00 => none
378+ | 0x01 v:<val(t)> => (some v)
379+ defval((result)) ::= 0x00 => ok
380+ | 0x01 => error
381+ defval((result t)) ::= 0x00 v:<val(t)> => (ok v)
382+ | 0x01 => error
383+ defval((result (error u))) ::= 0x00 => ok
384+ | 0x01 v:<val(u)> => (error v)
385+ defval((result t (error u))) ::= 0x00 v:<val(t)> => (ok v)
386+ | 0x01 v:<val(u)> => (error v)
387+ ```
388+
389+ Notes:
390+ * Reused Core binary rules:
391+ - [ ` core:name ` ]
392+ - [ ` core:s8 ` ]
393+ - [ ` core:s16 ` ]
394+ - [ ` core:s32 ` ]
395+ - [ ` core:s64 ` ]
396+ - [ ` core:u8 ` ]
397+ - [ ` core:u16 ` ]
398+ - [ ` core:u32 ` ]
399+ - [ ` core:u64 ` ]
400+ - [ ` core:f32 ` ]
401+ - [ ` core:f64 ` ]
402+
349403## Name Section
350404
351405Like the core wasm [ name
@@ -375,7 +429,16 @@ appear once within a `name` section, for example component instances can only be
375429named once.
376430
377431
432+ [ `core:s8` ] : https://webassembly.github.io/spec/core/binary/values.html#integers
433+ [ `core:u8` ] : https://webassembly.github.io/spec/core/binary/values.html#integers
434+ [ `core:s16` ] : https://webassembly.github.io/spec/core/binary/values.html#integers
435+ [ `core:u16` ] : https://webassembly.github.io/spec/core/binary/values.html#integers
436+ [ `core:s32` ] : https://webassembly.github.io/spec/core/binary/values.html#integers
378437[ `core:u32` ] : https://webassembly.github.io/spec/core/binary/values.html#integers
438+ [ `core:s64` ] : https://webassembly.github.io/spec/core/binary/values.html#integers
439+ [ `core:u64` ] : https://webassembly.github.io/spec/core/binary/values.html#integers
440+ [ `core:f32` ] : https://webassembly.github.io/spec/core/binary/values.html#floating-point
441+ [ `core:f64` ] : https://webassembly.github.io/spec/core/binary/values.html#floating-point
379442[ `core:section` ] : https://webassembly.github.io/spec/core/binary/modules.html#binary-section
380443[ `core:custom` ] : https://webassembly.github.io/spec/core/binary/modules.html#custom-section
381444[ `core:module` ] : https://webassembly.github.io/spec/core/binary/modules.html#binary-module
0 commit comments