@@ -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,57 @@ 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 lt+)) ::= (v:<fieldval(f:lt)>)^n => v^n (if |lt*| > 0 and n = |lt*|)
372+ defval((variant case*)) ::= i:<core:u32> v:caseval(c) => i v (if i < |case*| and c = case[i])
373+ defval((list t)) ::= vec(<val(t)>)
374+ defval((tuple t+)) ::= (v:<val(e:t)>)^n => v^n (if |t*| > 0 and n = |t*|)
375+ defval((flags l+)) ::= v:<core:u32> => v (if |l*| > 0 and v < 2^|l*|)
376+ defval((enum l*)) ::= i:<core:u32> => i v (if i < |l*|)
377+ defval((option t)) ::= 0x00 => none
378+ | 0x01 v:<val(t)> => (some v)
379+ defval((result t? (error u)?)) ::= 0x00 => ok
380+ | 0x00 v:<val(t)> => (ok v)
381+ | 0x01 => error
382+ | 0x01 v:<val(u)> => (error v)
383+ fieldval((field l t)) ::= v:<val(t)> => v
384+ caseval((case l t?)) ::= v?:<val(t)>? => v?
385+ ```
386+
387+ Notes:
388+ * Reused Core binary rules:
389+ - [ ` core:name ` ]
390+ - [ ` core:s8 ` ]
391+ - [ ` core:s16 ` ]
392+ - [ ` core:s32 ` ]
393+ - [ ` core:s64 ` ]
394+ - [ ` core:u8 ` ]
395+ - [ ` core:u16 ` ]
396+ - [ ` core:u32 ` ]
397+ - [ ` core:u64 ` ]
398+ - [ ` core:f32 ` ]
399+ - [ ` core:f64 ` ]
400+
349401## Name Section
350402
351403Like the core wasm [ name
@@ -375,7 +427,16 @@ appear once within a `name` section, for example component instances can only be
375427named once.
376428
377429
430+ [ `core:s8` ] : https://webassembly.github.io/spec/core/binary/values.html#integers
431+ [ `core:u8` ] : https://webassembly.github.io/spec/core/binary/values.html#integers
432+ [ `core:s16` ] : https://webassembly.github.io/spec/core/binary/values.html#integers
433+ [ `core:u16` ] : https://webassembly.github.io/spec/core/binary/values.html#integers
434+ [ `core:s32` ] : https://webassembly.github.io/spec/core/binary/values.html#integers
378435[ `core:u32` ] : https://webassembly.github.io/spec/core/binary/values.html#integers
436+ [ `core:s64` ] : https://webassembly.github.io/spec/core/binary/values.html#integers
437+ [ `core:u64` ] : https://webassembly.github.io/spec/core/binary/values.html#integers
438+ [ `core:f32` ] : https://webassembly.github.io/spec/core/binary/values.html#floating-point
439+ [ `core:f64` ] : https://webassembly.github.io/spec/core/binary/values.html#floating-point
379440[ `core:section` ] : https://webassembly.github.io/spec/core/binary/modules.html#binary-section
380441[ `core:custom` ] : https://webassembly.github.io/spec/core/binary/modules.html#custom-section
381442[ `core:module` ] : https://webassembly.github.io/spec/core/binary/modules.html#binary-module
0 commit comments