55
55
```
56
56
core:instance ::= ie:<instance-expr> => (instance ie)
57
57
core:instanceexpr ::= 0x00 m:<moduleidx> arg*:vec(<core:instantiatearg>) => (instantiate m arg*)
58
- | 0x01 e*:vec(<core:export>) => e*
59
- core:instantiatearg ::= n:<name> 0x12 i:<instanceidx> => (with n (instance i))
58
+ | 0x01 e*:vec(<core:inlineexport>) => e*
59
+ core:instantiatearg ::= n:<core: name> 0x12 i:<instanceidx> => (with n (instance i))
60
60
core:sortidx ::= sort:<core:sort> idx:<u32> => (sort idx)
61
61
core:sort ::= 0x00 => func
62
62
| 0x01 => table
@@ -65,11 +65,11 @@ core:sort ::= 0x00 => fu
65
65
| 0x10 => type
66
66
| 0x11 => module
67
67
| 0x12 => instance
68
- core:export ::= n:<name> si:<core:sortidx> => (export n si)
68
+ core:inlineexport ::= n:<core: name> si:<core:sortidx> => (export n si)
69
69
70
70
instance ::= ie:<instance-expr> => (instance ie)
71
71
instanceexpr ::= 0x00 c:<componentidx> arg*:vec(<instantiatearg>) => (instantiate c arg*)
72
- | 0x01 e*:vec(<export>) => e*
72
+ | 0x01 e*:vec(<inlineexport>) => e*
73
73
instantiatearg ::= n:<name> si:<sortidx> => (with n si)
74
74
sortidx ::= sort:<sort> idx:<u32> => (sort idx)
75
75
sort ::= 0x00 cs:<core:sort> => core cs
@@ -78,7 +78,12 @@ sort ::= 0x00 cs:<core:sort> => co
78
78
| 0x03 => type
79
79
| 0x04 => component
80
80
| 0x05 => instance
81
- export ::= n:<name> si:<sortidx> => (export n si)
81
+ inlineexport ::= n:<name> si:<sortidx> => (export n si)
82
+ name ::= len:<u32> n:<name-chars> => n (if len = |n|)
83
+ name-chars ::= w:<word> => w
84
+ | n:<name> 0x2d w:<word> => n-w
85
+ word ::= w:[0x61-0x7a] x*:[0x30-0x39,0x61-0x7a]* => char(w)char(x)*
86
+ | W:[0x41-0x5a] X*:[0x30-0x39,0x41-0x5a]* => char(W)char(X)*
82
87
```
83
88
Notes:
84
89
* Reused Core binary rules: [ ` core:name ` ] , (variable-length encoded) [ ` core:u32 ` ]
@@ -92,17 +97,19 @@ Notes:
92
97
for aliases (below).
93
98
* Validation of ` core:instantiatearg ` initially only allows the ` instance `
94
99
sort, but would be extended to accept other sorts as core wasm is extended.
100
+ * Validation of ` instantiate ` requires that ` name ` is present in an
101
+ ` externname ` of ` c ` (with a matching type).
95
102
* The indices in ` sortidx ` are validated according to their ` sort ` 's index
96
103
spaces, which are built incrementally as each definition is validated.
97
104
98
105
## Alias Definitions
99
106
100
107
(See [ Alias Definitions] ( Explainer.md#alias-definitions ) in the explainer.)
101
108
```
102
- alias ::= s:<sort> t:<aliastarget> => (alias t (s))
103
- aliastarget ::= 0x00 i:<instanceidx> n:<name> => export i n
104
- | 0x01 i:<core:instanceidx> n:<name> => core export i n
105
- | 0x02 ct:<u32> idx:<u32> => outer ct idx
109
+ alias ::= s:<sort> t:<aliastarget> => (alias t (s))
110
+ aliastarget ::= 0x00 i:<instanceidx> n:<name> => export i n
111
+ | 0x01 i:<core:instanceidx> n:<core: name> => core export i n
112
+ | 0x02 ct:<u32> idx:<u32> => outer ct idx
106
113
```
107
114
Notes:
108
115
* Reused Core binary rules: (variable-length encoded) [ ` core:u32 ` ]
@@ -133,7 +140,7 @@ core:moduledecl ::= 0x00 i:<core:import> => i
133
140
core:alias ::= s:<core:sort> t:<core:aliastarget> => (alias t (s))
134
141
core:aliastarget ::= 0x01 ct:<u32> idx:<u32> => outer ct idx
135
142
core:importdecl ::= i:<core:import> => i
136
- core:exportdecl ::= n:<name> d:<core:importdesc> => (export n d)
143
+ core:exportdecl ::= n:<core: name> d:<core:importdesc> => (export n d)
137
144
```
138
145
Notes:
139
146
* Reused Core binary rules: [ ` core:import ` ] , [ ` core:importdesc ` ] , [ ` core:functype ` ]
@@ -175,12 +182,11 @@ defvaltype ::= pvt:<primvaltype> => pvt
175
182
| 0x6d n*:vec(<name>) => (enum n*)
176
183
| 0x6c t*:vec(<valtype>) => (union t*)
177
184
| 0x6b t:<valtype> => (option t)
178
- | 0x6a t?:<casetype> u?:<casetype> => (result t? (error u)?)
185
+ | 0x6a t?:<valtype>? u?:<valtype>? => (result t? (error u)?)
179
186
namedvaltype ::= n:<name> t:<valtype> => n t
180
- case ::= n:<name> t?:<casetype> 0x0 => (case n t?)
181
- | n:<name> t?:<casetype> 0x1 i:<u32> => (case n t? (refines case-label[i]))
182
- casetype ::= 0x00 =>
183
- | 0x01 t:<valtype> => t
187
+ case ::= n:<name> t?:<valtype>? r?:<u32>? => (case n t? (refines case-label[r])?)
188
+ <T>? ::= 0x00 =>
189
+ | 0x01 t:<T> => t
184
190
valtype ::= i:<typeidx> => i
185
191
| pvt:<primvaltype> => pvt
186
192
functype ::= 0x40 ps:<paramlist> rs:<resultlist> => (func ps rs)
@@ -195,8 +201,8 @@ instancedecl ::= 0x00 t:<core:type> => t
195
201
| 0x01 t:<type> => t
196
202
| 0x02 a:<alias> => a
197
203
| 0x04 ed:<exportdecl> => ed
198
- importdecl ::= n:<name > ed:<externdesc> => (import n ed)
199
- exportdecl ::= n:<name > ed:<externdesc> => (export n ed)
204
+ importdecl ::= en:<externname > ed:<externdesc> => (import en ed)
205
+ exportdecl ::= en:<externname > ed:<externdesc> => (export en ed)
200
206
externdesc ::= 0x00 0x11 i:<core:typeidx> => (core module (type i))
201
207
| 0x01 i:<typeidx> => (func (type i))
202
208
| 0x02 t:<valtype> => (value t)
@@ -215,6 +221,8 @@ Notes:
215
221
* As described in the explainer, each component and instance type is validated
216
222
with an initially-empty type index space. Outer aliases can be used to pull
217
223
in type definitions from containing components.
224
+ * The uniqueness validation rules for ` externname ` described below are also
225
+ applied at the instance- and component-type level.
218
226
* Validation of ` externdesc ` requires the various ` typeidx ` type constructors
219
227
to match the preceding ` sort ` .
220
228
* Validation of function parameter and result names, record field names,
@@ -286,13 +294,21 @@ flags are set.
286
294
(See [ Import and Export Definitions] ( Explainer.md#import-and-export-definitions )
287
295
in the explainer.)
288
296
```
289
- import ::= n:<name> ed:<externdesc> => (import n ed)
290
- export ::= n:<name> si:<sortidx> => (export n si)
297
+ import ::= en:<externname> ed:<externdesc> => (import en ed)
298
+ export ::= en:<externname> si:<sortidx> => (export en si)
299
+ externname ::= n:<name> u?:<URL>? => n u?
300
+ URL ::= b*:vec(byte) => char(b)*, if char(b)* parses as a URL
291
301
```
292
302
Notes:
293
- * Validation requires all import and export ` name ` s are unique.
303
+ * The "parses as a URL" condition is defined by executing the [ basic URL
304
+ parser] with ` char(b)* ` as * input* , no optional parameters and non-fatal
305
+ validation errors (which coincides with definition of ` URL ` in JS and ` rust-url ` ).
294
306
* Validation requires any exported ` sortidx ` to have a valid ` externdesc `
295
307
(which disallows core sorts other than ` core module ` ).
308
+ * The ` name ` fields of ` externname ` must be unique among imports and exports,
309
+ respectively. The ` URL ` fields of ` externname ` (that are present) must
310
+ independently unique among imports and exports, respectively.
311
+ * URLs are compared for equality by plain byte identity.
296
312
297
313
298
314
[ `core:u32` ] : https://webassembly.github.io/spec/core/binary/values.html#integers
@@ -307,3 +323,5 @@ Notes:
307
323
308
324
[ type-imports ] : https://github.com/WebAssembly/proposal-type-imports/blob/master/proposals/type-imports/Overview.md
309
325
[ module-linking ] : https://github.com/WebAssembly/module-linking/blob/main/proposals/module-linking/Explainer.md
326
+
327
+ [ Basic URL Parser ] : https://url.spec.whatwg.org/#concept-basic-url-parser
0 commit comments