Skip to content

Commit 07479f0

Browse files
authored
Allow imports to name implementations (#222)
* Add support for implementation imports * Rename <export> to <projection> to avoid clash * Change , separator to space for consistency * Add semver range note * Fix semver range ordering text * Add naked integrity hash import name * Fill in missing OCI Registry reference
1 parent cf8c769 commit 07479f0

File tree

2 files changed

+225
-89
lines changed

2 files changed

+225
-89
lines changed

design/mvp/Binary.md

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ sort ::= 0x00 cs:<core:sort> => co
7878
| 0x03 => type
7979
| 0x04 => component
8080
| 0x05 => instance
81-
inlineexport ::= n:<externname> si:<sortidx> => (export n si)
81+
inlineexport ::= n:<exportname> si:<sortidx> => (export n si)
8282
string ::= s:<core:name> => s
8383
name ::= len:<u32> n:<name-chars> => n (if len = |n|)
8484
name-chars ::= l:<label> => l
@@ -102,9 +102,9 @@ Notes:
102102
for aliases (below).
103103
* Validation of `core:instantiatearg` initially only allows the `instance`
104104
sort, but would be extended to accept other sorts as core wasm is extended.
105-
* Validation of `instantiate` requires that each `<name>` or `<iid>` in an
106-
imported `externname` in `c` matches a `string` in a `with` argument and that
107-
the argument's type matches the import's type.
105+
* Validation of `instantiate` requires each `<name>`, `<regid>` or
106+
`<regidset>` in an `importname` in `c` to match a `string` in a `with`
107+
argument and for the types to match.
108108
* When validating `instantiate`, after each individual type-import is supplied
109109
via `with`, the actual type supplied is immediately substituted for all uses
110110
of the import, so that subsequent imports and all exports are now specialized
@@ -226,8 +226,8 @@ instancedecl ::= 0x00 t:<core:type> => t
226226
| 0x01 t:<type> => t
227227
| 0x02 a:<alias> => a
228228
| 0x04 ed:<exportdecl> => ed
229-
importdecl ::= en:<externname> ed:<externdesc> => (import en ed)
230-
exportdecl ::= en:<externname> ed:<externdesc> => (export en ed)
229+
importdecl ::= in:<importname> ed:<externdesc> => (import in ed)
230+
exportdecl ::= en:<exportname> ed:<externdesc> => (export en ed)
231231
externdesc ::= 0x00 0x11 i:<core:typeidx> => (core module (type i))
232232
| 0x01 i:<typeidx> => (func (type i))
233233
| 0x02 t:<valtype> => (value t)
@@ -263,8 +263,8 @@ Notes:
263263
* Validation rejects `resourcetype` type definitions inside `componenttype` and
264264
`instancettype`. Thus, handle types inside a `componenttype` can only refer
265265
to resource types that are imported or exported.
266-
* The uniqueness validation rules for `externname` described below are also
267-
applied at the instance- and component-type level.
266+
* The uniqueness validation rules for `importname` and `exportname`
267+
described below are also applied at the instance- and component-type level.
268268
* Validation of `externdesc` requires the various `typeidx` type constructors
269269
to match the preceding `sort`.
270270
* Validation of function parameter and result names, record field names,
@@ -327,14 +327,19 @@ flags are set.
327327
(See [Import and Export Definitions](Explainer.md#import-and-export-definitions)
328328
in the explainer.)
329329
```
330-
import ::= en:<externname> ed:<externdesc> => (import en ed)
331-
export ::= en:<externname> si:<sortidx> ed?:<externdesc>? => (export en si ed?)
332-
externname ::= 0x00 n:<name> => n
333-
| 0x01 iid:<iid> => (interface iid)
334-
iid ::= len:<u32> c:<iid-chars> => c (if len = |c|)
335-
iid-chars ::= ns:<label> ':' pkg:<label> '/' n:<label> v:<version> => ns:pkg/nv
336-
version ::= => ϵ
337-
| '@' v:<valid semver> => @v
330+
import ::= in:<importname> ed:<externdesc> => (import in ed)
331+
export ::= en:<exportname> si:<sortidx> ed?:<externdesc>? => (export en si ed?)
332+
exportname ::= 0x00 n:<name> => n
333+
| 0x01 ri:<regid'> => (interface ri)
334+
importname ::= en:<exportname> => en
335+
| 0x02 n:<name> s:<string> i?:<integrity'>? => n (url s i?)
336+
| 0x03 n:<name> s:<string> i?:<integrity'>? => n (relative-url s i?)
337+
| 0x04 n:<name> i:<integrity'> => n i
338+
| 0x05 ri:<regid'> i?:<integrity'>? => (locked-dep ri i?)
339+
| 0x06 ris:<regidset'> => (unlocked-dep ris)
340+
regid' ::= len:<u32> ri:<regid> => "ri" (if len = |ri|)
341+
regidset' ::= len:<u32> ris:<regidset> => "ris" (if len = |ris|)
342+
integrity' ::= len:<u32> im:<integrity-metadata> => (integrity "im") (if len = |im|)
338343
```
339344

340345
Notes:
@@ -346,13 +351,18 @@ Notes:
346351
(which disallows core sorts other than `core module`). When the optional
347352
`externdesc` immediate is present, validation requires it to be a supertype
348353
of the inferred `externdesc` of the `sortidx`.
349-
* The `name` fields of `externname` must be unique among all imports and exports
350-
in the containing component definition, component type or instance type. (An
351-
import and export cannot use the same `name`.)
352-
* The `id` fields of `externname` (that are present) must independently be
353-
unique among imports and exports, respectively. (An import and export *may*
354-
have the same `id`.)
354+
* The `name` fields of `exportname` and `importname` must be unique among all
355+
imports and exports in the containing component definition, component type or
356+
instance type. (An import and export cannot use the same `name`.)
357+
* The `regid` and `regidset` of `importname` and `exportname` must be
358+
unique only among imports or exports. That is, two imports may *not*
359+
have the same `regid`(`set`), but an import and export *may* have the same
360+
`regid`.
361+
* `<regid>` and `<regidset>` refer to the grammatical productions defined in
362+
the [text format](#import-and-export-definitions).
355363
* `<valid semver>` is as defined by [https://semver.org](https://semver.org/)
364+
* `<integrity-metadata>` is as defined by the
365+
[SRI](https://www.w3.org/TR/SRI/#dfn-integrity-metadata) spec.
356366

357367
## Name Section
358368

0 commit comments

Comments
 (0)