Skip to content

Commit 1bd1266

Browse files
authored
Merge pull request #198 from alexcrichton/import-export-changes
Update WIT and binary import/export syntax
2 parents 093579d + 49ce239 commit 1bd1266

File tree

2 files changed

+422
-323
lines changed

2 files changed

+422
-323
lines changed

design/mvp/Binary.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,16 @@ core:inlineexport ::= n:<core:name> si:<core:sortidx> => (e
7070
instance ::= ie:<instanceexpr> => (instance ie)
7171
instanceexpr ::= 0x00 c:<componentidx> arg*:vec(<instantiatearg>) => (instantiate c arg*)
7272
| 0x01 e*:vec(<inlineexport>) => e*
73-
instantiatearg ::= n:<name> si:<sortidx> => (with n si)
73+
instantiatearg ::= n:<string> si:<sortidx> => (with n si)
7474
sortidx ::= sort:<sort> idx:<u32> => (sort idx)
7575
sort ::= 0x00 cs:<core:sort> => core cs
7676
| 0x01 => func
7777
| 0x02 => value
7878
| 0x03 => type
7979
| 0x04 => component
8080
| 0x05 => instance
81-
inlineexport ::= n:<name> si:<sortidx> => (export n si)
81+
inlineexport ::= n:<externname> si:<sortidx> => (export n si)
82+
string ::= s:<core:name> => s
8283
name ::= len:<u32> n:<name-chars> => n (if len = |n|)
8384
name-chars ::= l:<label> => l
8485
| '[constructor]' r:<label> => [constructor]r
@@ -126,7 +127,7 @@ Notes:
126127
(See [Alias Definitions](Explainer.md#alias-definitions) in the explainer.)
127128
```
128129
alias ::= s:<sort> t:<aliastarget> => (alias t (s))
129-
aliastarget ::= 0x00 i:<instanceidx> n:<name> => export i n
130+
aliastarget ::= 0x00 i:<instanceidx> n:<string> => export i n
130131
| 0x01 i:<core:instanceidx> n:<core:name> => core export i n
131132
| 0x02 ct:<u32> idx:<u32> => outer ct idx
132133
```
@@ -328,11 +329,23 @@ in the explainer.)
328329
```
329330
import ::= en:<externname> ed:<externdesc> => (import en ed)
330331
export ::= en:<externname> si:<sortidx> ed?:<externdesc>? => (export en si ed?)
331-
externname ::= n:<name> ea:<externattrs> => n ea
332-
externattrs ::= 0x00 => ϵ
333-
| 0x01 url:<URL> => (id url)
334-
URL ::= b*:vec(byte) => char(b)*, if char(b)* parses as a URL
332+
externname ::= 0x00 n:<name> => n
333+
| 0x01 n:<id> => (interface n)
334+
id ::= len:<u32> n:<id-chars> => n (if len = |n|)
335+
336+
id-chars ::= ns:<label> ':' pkg:<label> '/' n:<label> v:<id-version> => ns:pkg/nv
337+
id-version ::= => ϵ
338+
| '@' version:<version> pre:<verpre> build:<verbuild> => version pre build
339+
340+
version ::= major:<num> '.' minor:<num> '.' patch:<num> => major.minor.patch
341+
version-number ::= digit+:[0x30-0x39] => char(digit)+
342+
343+
verpre ::= => ϵ
344+
| '-' (a:<label> '.') b:<label> => -(a.*)b
345+
verbuild ::= => ϵ
346+
| '+' (a:<label> '.') b:<label> => +(a.*)b
335347
```
348+
336349
Notes:
337350
* All exports (of all `sort`s) introduce a new index that aliases the exported
338351
definition and can be used by all subsequent definitions just like an alias.

0 commit comments

Comments
 (0)