Skip to content

Commit 9d0a345

Browse files
committed
Add a custom name section specification
This is intended to assist with debugging/reading/writing the text format of components by avoiding the need to have everything be numbers and allowing tools to annotate names of items optionally (or have the names preserved from the text format). Closes #14
1 parent 5754989 commit 9d0a345

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

design/mvp/Binary.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,3 +325,51 @@ Notes:
325325
[module-linking]: https://github.com/WebAssembly/module-linking/blob/main/proposals/module-linking/Explainer.md
326326

327327
[Basic URL Parser]: https://url.spec.whatwg.org/#concept-basic-url-parser
328+
329+
## Name Section
330+
331+
Like the core wasm [name
332+
section](https://webassembly.github.io/spec/core/appendix/custom.html#name-section)
333+
a similar `name` custom section is specified here for components to be able to
334+
name all the declarations that can happen within a component. Similarly like its
335+
core wasm counterpart validity of this custom section is not required and
336+
engines should not reject components which have an invalid `name` section.
337+
338+
```
339+
namesec ::= section_0(namedata)
340+
namedata ::= n:<name> (if n = 'name')
341+
sections*:<subsection>*
342+
subsection ::= 0x00 0x00 funcs:<corefuncsubsec>
343+
0x00 0x01 tables:<coretablesubsec>
344+
0x00 0x02 memories:<corememorysubsec>
345+
0x00 0x03 globals:<coreglobalsubsec>
346+
0x00 0x10 types:<coretypesubsec>
347+
0x00 0x11 modules:<coremodulesubsec>
348+
0x00 0x12 instances:<coreinstancesubsec>
349+
0x01 funcs:<funcsubsec>
350+
0x02 values:<valuesubsec>
351+
0x03 types:<typesubsec>
352+
0x04 components:<componentsubsec>
353+
0x05 instances:<instancesubsec>
354+
355+
corefuncsubsec ::= map:<namemap>
356+
coretablesubsec ::= map:<namemap>
357+
corememorysubsec ::= map:<namemap>
358+
coreglobalsubsec ::= map:<namemap>
359+
coretypesubsec ::= map:<namemap>
360+
coremodulesubsec ::= map:<namemap>
361+
coreinstancesubsec ::= map:<namemap>
362+
363+
funcsubsec ::= map:<namemap>
364+
valuesubsec ::= map:<namemap>
365+
typesubsec ::= map:<namemap>
366+
componentsubsec ::= map:<namemap>
367+
instancesubsec ::= map:<namemap>
368+
369+
namemap ::= names:vec(<nameassoc>)
370+
nameassoc ::= idx:<u32> name:<name>
371+
```
372+
373+
where `namemap` is the same as for core wasm. A particular `sort` should only
374+
appear once within a `name` section, for example component instances can only be
375+
named once.

0 commit comments

Comments
 (0)