-
Notifications
You must be signed in to change notification settings - Fork 111
Open
Description
In Binary.md's Instance Definitions, the inlineexport production uses exportname (without prime):
inlineexport ::= n:<exportname> si:<sortidx> => (export n si)
However, wasm-tools encodes inline export names using exportname' (with the discriminator byte prefix), which is the same encoding used by top-level export and exportdecl:
export ::= en:<exportname'> si:<sortidx> ed?:<externdesc>? => (export en si ed?)
exportdecl ::= en:<exportname'> ed:<externdesc> => (export en ed)
Example
(component
(import "f" (func))
(instance $i (export "hello" (func 0)))
)wasm-tools parse produces the following bytes for the instance section (section ID 0x05):
0x17 | 05 0c | component instance section
0x19 | 01 | 1 count
0x1a | 01 01 >00< 05 | [instance 0] FromExports([ComponentExport { name: ComponentExportName("hello"), kind: Func, index: 0, ty: None }])
| 68 65 6c 6c
| 6f 01 00
The 0x00 byte before the name length is the exportname' discriminator. If the spec intended plain exportname (= name = core:name), this byte would not be present and the encoding would instead be:
05 0b ;; section 5 (instance), 11 bytes
01 ;; vec count: 1 instance
01 ;; instanceexpr flag: 0x01 = inline exports
01 ;; vec count: 1 inline export
;; spec no 00 here
05 68 65 6c 6c 6f ;; name length 5 + "hello" (no discriminator)
01 00 ;; sortidx: sort=0x01 (func), idx=0

Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels