@@ -73,6 +73,7 @@ instance ::= ie:<instanceexpr> => (i
7373instanceexpr ::= 0x00 c:<componentidx> arg*:vec(<instantiatearg>) => (instantiate c arg*)
7474 | 0x01 e*:vec(<inlineexport>) => e*
7575instantiatearg ::= n:<string> si:<sortidx> => (with n si)
76+ string ::= s:<core:name> => s
7677sortidx ::= sort:<sort> idx:<u32> => (sort idx)
7778sort ::= 0x00 cs:<core:sort> => core cs
7879 | 0x01 => func
@@ -81,16 +82,6 @@ sort ::= 0x00 cs:<core:sort> => co
8182 | 0x04 => component
8283 | 0x05 => instance
8384inlineexport ::= n:<exportname> si:<sortidx> => (export n si)
84- string ::= s:<core:name> => s
85- name ::= len:<u32> n:<name-chars> => n (if len = |n|)
86- name-chars ::= l:<label> => l
87- | '[constructor]' r:<label> => [constructor]r
88- | '[method]' r:<label> '.' m:<label> => [method]r.m
89- | '[static]' r:<label> '.' s:<label> => [static]r.s
90- label ::= w:<word> => w
91- | l:<label> '-' w:<word> => l-w
92- word ::= w:[0x61-0x7a] x*:[0x30-0x39,0x61-0x7a]* => char(w)char(x)*
93- | W:[0x41-0x5a] X*:[0x30-0x39,0x41-0x5a]* => char(W)char(X)*
9485```
9586Notes:
9687* Reused Core binary rules: [ ` core:name ` ] , (variable-length encoded) [ ` core:u32 ` ]
@@ -104,25 +95,15 @@ Notes:
10495 for aliases (below).
10596* Validation of ` core:instantiatearg ` initially only allows the ` instance `
10697 sort, but would be extended to accept other sorts as core wasm is extended.
107- * Validation of ` instantiate ` requires each ` <name> ` , ` <iid> ` , ` <pkgid> ` or
108- ` <pkgidset> ` in an ` importname ` in ` c ` to match a ` string ` in a ` with `
109- argument and for the types to match.
98+ * Validation of ` instantiate ` requires each ` <importname> ` in ` c ` to match a
99+ ` string ` in a ` with ` argument (compared as strings) and for the types to
100+ match.
110101* When validating ` instantiate ` , after each individual type-import is supplied
111102 via ` with ` , the actual type supplied is immediately substituted for all uses
112103 of the import, so that subsequent imports and all exports are now specialized
113104 to the actual type.
114105* The indices in ` sortidx ` are validated according to their ` sort ` 's index
115106 spaces, which are built incrementally as each definition is validated.
116- * Validation requires that annotated ` name ` s only occur on ` func ` imports or
117- exports and that the ` r:<label> ` matches the ` name ` of a preceding ` resource `
118- import or export, respectively, in the same scope (component, component type
119- or instance type).
120- * Validation of ` [constructor] ` names requires that the ` func ` returns a
121- ` (result (own $R)) ` , where ` $R ` is the resource labeled ` r ` .
122- * Validation of ` [method] ` names requires the first parameter of the function
123- to be ` (param "self" (borrow $R)) ` , where ` $R ` is the resource labeled ` r ` .
124- * Validation of ` [method] ` and ` [static] ` names ensures that all field names
125- are disjoint.
126107
127108
128109## Alias Definitions
@@ -204,14 +185,15 @@ defvaltype ::= pvt:<primvaltype> => pvt
204185 | 0x71 case*:vec(<case>) => (variant case*)
205186 | 0x70 t:<valtype> => (list t)
206187 | 0x6f t*:vec(<valtype>) => (tuple t+) (if |t*| > 0)
207- | 0x6e l*:vec(<label>) => (flags l+) (if |l*| > 0)
208- | 0x6d l*:vec(<label>) => (enum l*)
188+ | 0x6e l*:vec(<label'>) => (flags l+) (if |l*| > 0)
189+ | 0x6d l*:vec(<label'>) => (enum l*)
209190 | 0x6b t:<valtype> => (option t)
210191 | 0x6a t?:<valtype>? u?:<valtype>? => (result t? (error u)?)
211192 | 0x69 i:<typeidx> => (own i)
212193 | 0x68 i:<typeidx> => (borrow i)
213- labelvaltype ::= l:<label> t:<valtype> => l t
214- case ::= l:<label> t?:<valtype>? 0x00 => (case l t?)
194+ labelvaltype ::= l:<label'> t:<valtype> => l t
195+ case ::= l:<label'> t?:<valtype>? 0x00 => (case l t?)
196+ label' ::= len:<u32> l:<label> => l (if len = |l|)
215197<T>? ::= 0x00 =>
216198 | 0x01 t:<T> => t
217199valtype ::= i:<typeidx> => i
@@ -266,13 +248,12 @@ Notes:
266248* Validation rejects ` resourcetype ` type definitions inside ` componenttype ` and
267249 ` instancettype ` . Thus, handle types inside a ` componenttype ` can only refer
268250 to resource types that are imported or exported.
269- * The uniqueness validation rules for ` importname ` and ` exportname `
270- described below are also applied at the instance- and component-type level.
251+ * All parameter labels, result labels, record field labels, variant case
252+ labels, flag labels, enum case labels, component import names, component
253+ export names, instance import names and instance export names must be
254+ unique in their containing scope.
271255* Validation of ` externdesc ` requires the various ` typeidx ` type constructors
272256 to match the preceding ` sort ` .
273- * Validation of function parameter and result names, record field names,
274- variant case names, flag names, and enum case names requires that the name be
275- unique for the func, record, variant, flags, or enum type definition.
276257* (The ` 0x00 ` immediate of ` case ` may be reinterpreted in the future as the
277258 ` none ` case of an optional immediate.)
278259
@@ -329,20 +310,10 @@ flags are set.
329310(See [ Import and Export Definitions] ( Explainer.md#import-and-export-definitions )
330311in the explainer.)
331312``` ebnf
332- import ::= in:<importname> ed:<externdesc> => (import in ed)
333- export ::= en:<exportname> si:<sortidx> ed?:<externdesc>? => (export en si ed?)
334- exportname ::= 0x00 n:<name> => n
335- | 0x01 i:<iid'> => (interface i)
336- iid' ::= len:<u32> i:<iid> => "i" (if len = |i|)
337- importname ::= en:<exportname> => en
338- | 0x02 n:<name> s:<string> i?:<integrity'>? => n (url s i?)
339- | 0x03 n:<name> s:<string> i?:<integrity'>? => n (relative-url s i?)
340- | 0x04 n:<name> i:<integrity'> => n i
341- | 0x05 p:<pkgid'> i?:<integrity'>? => (locked-dep p i?)
342- | 0x06 p:<pkgidset'> => (unlocked-dep p)
343- pkgid' ::= len:<u32> p:<pkgid> => "p" (if len = |p|)
344- pkgidset' ::= len:<u32> p:<pkgidset> => "p" (if len = |p|)
345- integrity' ::= len:<u32> im:<integrity-metadata> => (integrity "im") (if len = |im|)
313+ import ::= en:<importname'> ed:<externdesc> => (import in ed)
314+ export ::= en:<exportname'> si:<sortidx> ed?:<externdesc>? => (export en si ed?)
315+ importname' ::= 0x00 len:<u32> in:<importname> => in (if len = |in|)
316+ exportname' ::= 0x00 len:<u32> en:<exportname> => en (if len = |en|)
346317```
347318
348319Notes:
@@ -354,10 +325,21 @@ Notes:
354325 (which disallows core sorts other than ` core module ` ). When the optional
355326 ` externdesc ` immediate is present, validation requires it to be a supertype
356327 of the inferred ` externdesc ` of the ` sortidx ` .
357- * The ` <name> ` , ` <iid> ` , ` <pkgid> ` and ` <pkgidset> ` of imports must be relatively unique.
358- * The ` <name> ` and ` <iid> ` of exports must be relatively unique.
359- * ` <iid> ` , ` <pkgid> ` and ` <pkgidset> ` refer to the grammatical productions defined in
360- the [ text format] ( #import-and-export-definitions ) .
328+ * ` <importname> ` and ` <exportname> ` refer to the productions defined in the
329+ [ text format] ( Explainer.md#import-and-export-definitions ) .
330+ * The ` <importname> ` s of a component must be unique and the ` <exportname> ` s of
331+ a component must be unique as well (defined in terms of raw string equality).
332+ * Validation requires that annotated ` plainname ` s only occur on ` func ` imports
333+ or exports and that the first label of a ` [constructor] ` , ` [method] ` or
334+ ` [static] ` matches the ` plainname ` of a preceding ` resource ` import or
335+ export, respectively, in the same scope (component, component type or
336+ instance type).
337+ * Validation of ` [constructor] ` names requires that the ` func ` returns a
338+ ` (result (own $R)) ` , where ` $R ` is the resource labeled ` r ` .
339+ * Validation of ` [method] ` names requires the first parameter of the function
340+ to be ` (param "self" (borrow $R)) ` , where ` $R ` is the resource labeled ` r ` .
341+ * Validation of ` [method] ` and ` [static] ` names ensures that all field names
342+ are disjoint.
361343* ` <valid semver> ` is as defined by [ https://semver.org ] ( https://semver.org/ )
362344* ` <integrity-metadata> ` is as defined by the
363345 [ SRI] ( https://www.w3.org/TR/SRI/#dfn-integrity-metadata ) spec.
0 commit comments