Skip to content

Commit 3cc92af

Browse files
committed
Adjust binary encoding of import/export names
The purpose of this commit is to address the discrepancy between the specification and wasm-tools discovered in #622. The history here is: * #222 - historical addition of `(interface "name")` as an import/export name. * #263 - moral revert of the previous change where the kind of name was now encoded in the name instead. At this point `Binary.md` mistakenly no longer reflected what wasm-tools parsed. * #536 - addition of more metadata to import/export names with a discriminator byte that overlapped the previous. This commit is is an adjustment to `Binary.md` to fix these discrepancies. Notably `exportname` and `importname` productions, previously absent. The `exportname'` and `importname'` productions are now renamed to `exportname` and `importname`. Additioanlly the production with `versionsuffix'` have been renumbered to `0x02` while an `0x01` production was added which is the exact same as `0x00` (intended for historical compat). A note was updated in the 1.0 binary adjustments to clean this up. Closes #622
1 parent 2e48008 commit 3cc92af

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

design/mvp/Binary.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ instancedecl ::= 0x00 t:<core:type> => t
228228
| 0x01 t:<type> => t
229229
| 0x02 a:<alias> => a
230230
| 0x04 ed:<exportdecl> => ed
231-
importdecl ::= in:<importname'> ed:<externdesc> => (import in ed)
232-
exportdecl ::= en:<exportname'> ed:<externdesc> => (export en ed)
231+
importdecl ::= in:<importname> ed:<externdesc> => (import in ed)
232+
exportdecl ::= en:<exportname> ed:<externdesc> => (export en ed)
233233
externdesc ::= 0x00 0x11 i:<core:typeidx> => (core module (type i))
234234
| 0x01 i:<typeidx> => (func (type i))
235235
| 0x02 b:<valuebound> => (value b) 🪙
@@ -386,13 +386,15 @@ flags are set.
386386
(See [Import and Export Definitions](Explainer.md#import-and-export-definitions)
387387
in the explainer.)
388388
```ebnf
389-
import ::= in:<importname'> ed:<externdesc> => (import in ed)
390-
export ::= en:<exportname'> si:<sortidx> ed?:<externdesc>? => (export en si ed?)
391-
importname' ::= 0x00 len:<u32> in:<importname> => in (if len = |in|)
392-
| 0x01 len:<u32> in:<importname> vs:<versionsuffix'> => in vs (if len = |in|) 🔗
393-
exportname' ::= 0x00 len:<u32> en:<exportname> => en (if len = |en|)
394-
| 0x01 len:<u32> en:<exportname> vs:<versionsuffix'> => in vs (if len = |in|) 🔗
395-
versionsuffix' ::= len:<u32> vs:<semversuffix> => (versionsuffix vs) (if len = |vs|) 🔗
389+
import ::= in:<importname> ed:<externdesc> => (import in ed)
390+
export ::= en:<exportname> si:<sortidx> ed?:<externdesc>? => (export en si ed?)
391+
importname ::= 0x00 len:<u32> in:<importname> => in (if len = |in|)
392+
| 0x01 len:<u32> in:<importname> => in (if len = |in|)
393+
| 0x02 len:<u32> in:<importname> vs:<versionsuffix> => in vs (if len = |in|) 🔗
394+
exoprtname ::= 0x00 len:<u32> in:<exoprtname> => in (if len = |in|)
395+
| 0x01 len:<u32> in:<exoprtname> => in (if len = |in|)
396+
| 0x02 len:<u32> in:<exoprtname> vs:<versionsuffix> => in vs (if len = |in|) 🔗
397+
versionsuffix ::= len:<u32> vs:<semversuffix> => (versionsuffix vs) (if len = |vs|) 🔗
396398
```
397399

398400
Notes:
@@ -406,6 +408,8 @@ Notes:
406408
of the inferred `externdesc` of the `sortidx`.
407409
* `<importname>` and `<exportname>` refer to the productions defined in the
408410
[text format](Explainer.md#import-and-export-definitions).
411+
* `<importname>` and `<exportname>` will [be cleaned up for a 1.0
412+
release](##binary-format-warts-to-fix-in-a-10-release).
409413
* The `<importname>`s of a component must all be [strongly-unique]. Separately,
410414
the `<exportname>`s of a component must also all be [strongly-unique].
411415
* Validation requires that annotated `plainname`s only occur on `func` imports
@@ -519,9 +523,9 @@ named once.
519523
* The two `depname` cases should be merged into one (`dep=<...>`)
520524
* The two `list` type codes should be merged into one with an optional immediate
521525
and similarly for `func`.
522-
* The `0x00` variant of `importname'` and `exportname'` will be removed. Any
523-
remaining variant(s) will be renumbered or the prefix byte will be removed or
524-
repurposed.
526+
* The `0x00` and `0x01` variant of `importname` and `exportname` will be
527+
removed. Any remaining variant(s) will be renumbered or the prefix byte will
528+
be removed or repurposed.
525529
* Most built-ins should have a `<canonopt>*` immediate instead of an ad hoc
526530
subset of `canonopt`s.
527531
* Add optional `shared` immediate to all canonical definitions (explicitly or

0 commit comments

Comments
 (0)