Skip to content

Commit 3f74cc6

Browse files
committed
Switch variant/result case payloads from T* to T?
1 parent 6d2d81f commit 3f74cc6

File tree

5 files changed

+241
-249
lines changed

5 files changed

+241
-249
lines changed

design/mvp/Binary.md

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -151,59 +151,61 @@ Notes:
151151
means that the maximum `ct` in an MVP `alias` declarator is `1`.
152152

153153
```
154-
type ::= dt:<deftype> => (type dt)
155-
deftype ::= dvt:<defvaltype> => dvt
156-
| ft:<functype> => ft
157-
| ct:<componenttype> => ct
158-
| it:<instancetype> => it
159-
primvaltype ::= 0x7f => bool
160-
| 0x7e => s8
161-
| 0x7d => u8
162-
| 0x7c => s16
163-
| 0x7b => u16
164-
| 0x7a => s32
165-
| 0x79 => u32
166-
| 0x78 => s64
167-
| 0x77 => u64
168-
| 0x76 => float32
169-
| 0x75 => float64
170-
| 0x74 => char
171-
| 0x73 => string
172-
defvaltype ::= pvt:<primvaltype> => pvt
173-
| 0x72 nt*:vec(<namedtype>) => (record (field nt)*)
174-
| 0x71 case*:vec(<case>) => (variant case*)
175-
| 0x70 t:<valtype> => (list t)
176-
| 0x6f t*:vec(<valtype>) => (tuple t*)
177-
| 0x6e n*:vec(<name>) => (flags n*)
178-
| 0x6d n*:vec(<name>) => (enum n*)
179-
| 0x6c t*:vec(<valtype>) => (union t*)
180-
| 0x6b t:<valtype> => (option t)
181-
| 0x6a t*:vec(<valtype>) u*:vec(<valtype>) => (result t* (error u*))
182-
namedtype ::= n:<name> t:<valtype> => (field n t)
183-
case ::= n:<name> t*:vec(<valtype>) 0x0 => (case n t*)
184-
| n:<name> t*:vec(<valtype>) 0x1 i:<u32> => (case n t* (refines case-label[i]))
185-
valtype ::= i:<typeidx> => i
186-
| pvt:<primvaltype> => pvt
187-
functype ::= 0x40 p*:<prlist> r*:<prlist> => (func (param p)* (result r)*)
188-
prlist ::= 0x00 t:<valtype> => [t]
189-
| 0x01 nt*:vec(<namedtype>) => nt*
190-
componenttype ::= 0x41 cd*:vec(<componentdecl>) => (component cd*)
191-
instancetype ::= 0x42 id*:vec(<instancedecl>) => (instance id*)
192-
componentdecl ::= 0x03 id:<importdecl> => id
193-
| id:<instancedecl> => id
194-
instancedecl ::= 0x00 t:<core:type> => t
195-
| 0x01 t:<type> => t
196-
| 0x02 a:<alias> => a
197-
| 0x04 ed:<exportdecl> => ed
198-
importdecl ::= n:<name> ed:<externdesc> => (import n ed)
199-
exportdecl ::= n:<name> ed:<externdesc> => (export n ed)
200-
externdesc ::= 0x00 0x11 i:<core:typeidx> => (core module (type i))
201-
| 0x01 i:<typeidx> => (func (type i))
202-
| 0x02 t:<valtype> => (value t)
203-
| 0x03 b:<typebound> => (type b)
204-
| 0x04 i:<typeidx> => (instance (type i))
205-
| 0x05 i:<typeidx> => (component (type i))
206-
typebound ::= 0x00 i:<typeidx> => (eq i)
154+
type ::= dt:<deftype> => (type dt)
155+
deftype ::= dvt:<defvaltype> => dvt
156+
| ft:<functype> => ft
157+
| ct:<componenttype> => ct
158+
| it:<instancetype> => it
159+
primvaltype ::= 0x7f => bool
160+
| 0x7e => s8
161+
| 0x7d => u8
162+
| 0x7c => s16
163+
| 0x7b => u16
164+
| 0x7a => s32
165+
| 0x79 => u32
166+
| 0x78 => s64
167+
| 0x77 => u64
168+
| 0x76 => float32
169+
| 0x75 => float64
170+
| 0x74 => char
171+
| 0x73 => string
172+
defvaltype ::= pvt:<primvaltype> => pvt
173+
| 0x72 nt*:vec(<namedvaltype>) => (record (field nt)*)
174+
| 0x71 case*:vec(<case>) => (variant case*)
175+
| 0x70 t:<valtype> => (list t)
176+
| 0x6f t*:vec(<valtype>) => (tuple t*)
177+
| 0x6e n*:vec(<name>) => (flags n*)
178+
| 0x6d n*:vec(<name>) => (enum n*)
179+
| 0x6c t*:vec(<valtype>) => (union t*)
180+
| 0x6b t:<valtype> => (option t)
181+
| 0x6a t?:<casetype> u?:<casetype> => (result t? (error u)?)
182+
namedvaltype ::= n:<name> t:<valtype> => n t
183+
case ::= n:<name> t?:<casetype> 0x0 => (case n t?)
184+
| n:<name> t?:<casetype> 0x1 i:<u32> => (case n t? (refines case-label[i]))
185+
casetype ::= 0x00 =>
186+
| 0x01 t:<valtype> => t
187+
valtype ::= i:<typeidx> => i
188+
| pvt:<primvaltype> => pvt
189+
functype ::= 0x40 p*:<prlist> r*:<prlist> => (func (param p)* (result r)*)
190+
prlist ::= 0x00 t:<valtype> => [t]
191+
| 0x01 nt*:vec(<namedvaltype>) => nt*
192+
componenttype ::= 0x41 cd*:vec(<componentdecl>) => (component cd*)
193+
instancetype ::= 0x42 id*:vec(<instancedecl>) => (instance id*)
194+
componentdecl ::= 0x03 id:<importdecl> => id
195+
| id:<instancedecl> => id
196+
instancedecl ::= 0x00 t:<core:type> => t
197+
| 0x01 t:<type> => t
198+
| 0x02 a:<alias> => a
199+
| 0x04 ed:<exportdecl> => ed
200+
importdecl ::= n:<name> ed:<externdesc> => (import n ed)
201+
exportdecl ::= n:<name> ed:<externdesc> => (export n ed)
202+
externdesc ::= 0x00 0x11 i:<core:typeidx> => (core module (type i))
203+
| 0x01 i:<typeidx> => (func (type i))
204+
| 0x02 t:<valtype> => (value t)
205+
| 0x03 b:<typebound> => (type b)
206+
| 0x04 i:<typeidx> => (instance (type i))
207+
| 0x05 i:<typeidx> => (component (type i))
208+
typebound ::= 0x00 i:<typeidx> => (eq i)
207209
```
208210
Notes:
209211
* The type opcodes follow the same negative-SLEB128 scheme as Core WebAssembly,

0 commit comments

Comments
 (0)