Skip to content

Commit 4d1e879

Browse files
committed
Switch (back) to multi-return, remove unit, s/expected/result/
Resolves #41
1 parent 1e29f9a commit 4d1e879

File tree

6 files changed

+292
-214
lines changed

6 files changed

+292
-214
lines changed

design/mvp/Binary.md

Lines changed: 56 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -151,60 +151,59 @@ 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 => unit
160-
| 0x7e => bool
161-
| 0x7d => s8
162-
| 0x7c => u8
163-
| 0x7b => s16
164-
| 0x7a => u16
165-
| 0x79 => s32
166-
| 0x78 => u32
167-
| 0x77 => s64
168-
| 0x76 => u64
169-
| 0x75 => float32
170-
| 0x74 => float64
171-
| 0x73 => char
172-
| 0x72 => string
173-
defvaltype ::= pvt:<primvaltype> => pvt
174-
| 0x71 field*:vec(<field>) => (record field*)
175-
| 0x70 case*:vec(<case>) => (variant case*)
176-
| 0x6f t:<valtype> => (list t)
177-
| 0x6e t*:vec(<valtype>) => (tuple t*)
178-
| 0x6d n*:vec(<name>) => (flags n*)
179-
| 0x6c n*:vec(<name>) => (enum n*)
180-
| 0x6b t*:vec(<valtype>) => (union t*)
181-
| 0x6a t:<valtype> => (option t)
182-
| 0x69 t:<valtype> u:<valtype> => (expected t u)
183-
field ::= n:<name> t:<valtype> => (field n t)
184-
case ::= n:<name> t:<valtype> 0x0 => (case n t)
185-
| n:<name> t:<valtype> 0x1 i:<u32> => (case n t (refines case-label[i]))
186-
valtype ::= i:<typeidx> => i
187-
| pvt:<primvaltype> => pvt
188-
functype ::= 0x40 param*:vec(<param>) t:<valtype> => (func param* (result t))
189-
param ::= 0x00 t:<valtype> => (param t)
190-
| 0x01 n:<name> t:<valtype> => (param n t)
191-
componenttype ::= 0x41 cd*:vec(<componentdecl>) => (component cd*)
192-
instancetype ::= 0x42 id*:vec(<instancedecl>) => (instance id*)
193-
componentdecl ::= 0x03 id:<importdecl> => id
194-
| id:<instancedecl> => id
195-
instancedecl ::= 0x00 t:<core:type> => t
196-
| 0x01 t:<type> => t
197-
| 0x02 a:<alias> => a
198-
| 0x04 ed:<exportdecl> => ed
199-
importdecl ::= n:<name> ed:<externdesc> => (import n ed)
200-
exportdecl ::= n:<name> ed:<externdesc> => (export n ed)
201-
externdesc ::= 0x00 0x11 i:<core:typeidx> => (core module (type i))
202-
| 0x01 i:<typeidx> => (func (type i))
203-
| 0x02 t:<valtype> => (value t)
204-
| 0x03 b:<typebound> => (type b)
205-
| 0x04 i:<typeidx> => (instance (type i))
206-
| 0x05 i:<typeidx> => (component (type i))
207-
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(<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 ::= nt*:vec(<namedtype>) 0x0 => (case nt*)
184+
| nt*:vec(<namedtype>) 0x1 i:<u32> => (case nt* (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)
208207
```
209208
Notes:
210209
* The type opcodes follow the same negative-SLEB128 scheme as Core WebAssembly,
@@ -218,9 +217,9 @@ Notes:
218217
in type definitions from containing components.
219218
* Validation of `externdesc` requires the various `typeidx` type constructors
220219
to match the preceding `sort`.
221-
* Validation of record field names, variant case names, flag names, and enum case
222-
names requires that the name be unique for the record, variant, flags, or enum
223-
type definition.
220+
* Validation of function parameter and result names, record field names,
221+
variant case names, flag names, and enum case names requires that the name be
222+
unique for the func, record, variant, flags, or enum type definition.
224223
* Validation of the optional `refines` clause of a variant case requires that
225224
the case index is less than the current case's index (and therefore
226225
cases are acyclic).

0 commit comments

Comments
 (0)