Skip to content

Commit 88a0fbb

Browse files
authored
Clarify @Custom (#16)
1 parent fa76c71 commit 88a0fbb

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

document/core/appendix/custom.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ They must not be nested into other constructs.
273273
\text{start} \\ &&|&
274274
\text{elem} \\ &&|&
275275
\text{code} \\ &&|&
276-
\text{data} \\
276+
\text{data} \\ &&|&
277+
\text{datacount} \\
277278
\end{array}
278279
279280
The first :ref:`string <text-string>` in a custom annotation denotes the name of the custom section it represents.
@@ -282,6 +283,7 @@ The remaining strings collectively represent the section's payload data, written
282283
An arbitrary number of custom annotations (even of the same name) may occur in a module,
283284
each defining a separate custom section when converting to :ref:`binary format <binary>`.
284285
Placement of the sections in the binary can be customized via explicit *placement* directives, that position them either directly before or directly after a known section.
286+
That section must exist and be non-empty in the binary encoding of the annotated module.
285287
The placements :math:`\T{(before~first)}` and :math:`\T{(after~last)}` denote virtual sections before the first and after the last known section, respectively.
286288
When the placement directive is omitted, it defaults to :math:`\T{(after~last)}`.
287289

proposals/annotations/Overview.md

+25
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,31 @@ Extend the Appendix on the Custom Sections:
4141
They may be placed after the binder for any construct that can be named by the name section.
4242

4343
* Define annotation syntax expressing arbitrary custom sections; cf. https://gist.github.com/binji/d1cfff7faaebb2aa4f8b1c995234e5a0
44+
45+
With that, a custom section annotation is specified as follows:
46+
```
47+
custom ::= '(' '@custom' string place? datastring ')'
48+
place ::=
49+
| '(' 'before' section ')'
50+
| '(' 'after' section ')'
51+
| '(' 'before' 'first' ')'
52+
| '(' 'after' 'last' ')'
53+
section ::=
54+
| 'type'
55+
| 'import'
56+
| 'func'
57+
| 'table'
58+
| 'memory'
59+
| 'global'
60+
| 'export'
61+
| 'start'
62+
| 'elem'
63+
| 'code'
64+
| 'data'
65+
| 'datacount'
66+
```
67+
If placement relative to an explicit section is used, then that section must exist in the encoding of the annotated module.
68+
4469
As with any matter concerning annotations, it is up to implementations how they handle the case where an explicit custom section overlaps with individual annotations that are associated with the same custom section.
4570

4671

0 commit comments

Comments
 (0)