Skip to content

Commit 9784159

Browse files
authored
Merge pull request #124 from alexcrichton/name-section
Add a custom `name` section specification
2 parents 111a408 + 983f01c commit 9784159

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

design/mvp/Binary.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,34 @@ Notes:
310310
independently unique among imports and exports, respectively.
311311
* URLs are compared for equality by plain byte identity.
312312

313+
## Name Section
314+
315+
Like the core wasm [name
316+
section](https://webassembly.github.io/spec/core/appendix/custom.html#name-section)
317+
a similar `name` custom section is specified here for components to be able to
318+
name all the declarations that can happen within a component. Similarly like its
319+
core wasm counterpart validity of this custom section is not required and
320+
engines should not reject components which have an invalid `name` section.
321+
322+
```
323+
namesec ::= section_0(namedata)
324+
namedata ::= n:<name> (if n = 'component-name')
325+
name:<componentnamesubsec>?
326+
sortnames*:<sortnamesubsec>*
327+
namesubsection_N(B) ::= N:<byte> size:<u32> B (if size == |B|)
328+
329+
componentnamesubsec ::= namesubsection_0(<name>)
330+
sortnamesubsec ::= namesubsection_1(<sortnames>)
331+
sortnames ::= sort:<sort> names:<namemap>
332+
333+
namemap ::= names:vec(<nameassoc>)
334+
nameassoc ::= idx:<u32> name:<name>
335+
```
336+
337+
where `namemap` is the same as for core wasm. A particular `sort` should only
338+
appear once within a `name` section, for example component instances can only be
339+
named once.
340+
313341

314342
[`core:u32`]: https://webassembly.github.io/spec/core/binary/values.html#integers
315343
[`core:section`]: https://webassembly.github.io/spec/core/binary/modules.html#binary-section

0 commit comments

Comments
 (0)