diff --git a/document/core/appendix/custom.rst b/document/core/appendix/custom.rst index 6980d3e61..9766a7b85 100644 --- a/document/core/appendix/custom.rst +++ b/document/core/appendix/custom.rst @@ -5,7 +5,7 @@ Custom Sections and Annotations This appendix defines dedicated :ref:`custom sections ` for WebAssembly's :ref:`binary format ` and :ref:`annotations ` for the text format. Such sections or annotations do not contribute to, or otherwise affect, the WebAssembly semantics, and may be ignored by an implementation. -However, they provide useful meta data that implementations can make use of to improve user experience or take compilation hints. +However, they provide useful metadata that implementations can make use of to improve user experience or take compilation hints. @@ -31,7 +31,7 @@ Subsections ........... The :ref:`data ` of a name section consists of a sequence of *subsections*. -Each subsection consists of a +Each subsection consists of: * a one-byte subsection *id*, * the |U32| *size* of the contents, in bytes, @@ -54,7 +54,9 @@ Each subsection consists of a \Belemnamesubsec^? \\ &&& \Bdatanamesubsec^? \\ &&& \Bfieldnamesubsec^? \\ &&& - \Btagnamesubsec^? \\ + \Btagnamesubsec^? \\ &&& + \Bparamnamesubsec^? \\ &&& + \Btagparamnamesubsec^? \\ \production{name subsection} & \Bnamesubsection_N(\B{B}) &::=& N{:}\Bbyte~~\X{size}{:}\Bu32~~\B{B} & (\iff \X{size} = ||\B{B}||) \\ @@ -77,6 +79,8 @@ Id Subsection 9 :ref:`data segment names ` 10 :ref:`field names ` 11 :ref:`tag names ` +12 :ref:`parameter names ` +13 :ref:`tag parameter names ` == =========================================== Each subsection may occur at most once, and in order of increasing id. @@ -155,6 +159,9 @@ Local Names The *local name subsection* has the id 2. It consists of an :ref:`indirect name map ` assigning local names to :ref:`local indices ` grouped by :ref:`function indices `. +.. note:: + This includes the function's parameters, and can therefore be used for both defined and imported functions. + .. math:: \begin{array}{llclll} \production{local name subsection} & \Blocalnamesubsec &::=& @@ -306,6 +313,41 @@ It consists of a :ref:`name map ` assigning tag names to :ref:`t \end{array} +.. index:: parameter, parameter index +.. _binary-paramnamesec: + +Parameter Names +............... + +The *parameter name subsection* has the id 12. +It consists of an :ref:`indirect name map ` assigning parameter names to parameter :ref:`indices ` grouped by the :ref:`type indices ` of their respective :ref:`function types `. + +.. note:: + This section only applies to :ref:`function types `, not :ref:`type uses `. Per-function parameter names are assigned in the :ref:`local name subsection `, and per-tag parameter names are assigned in the :ref:`tag parameter name subsection `. + +.. math:: + \begin{array}{llclll} + \production{parameter name subsection} & \Bparamnamesubsec &::=& + \Bnamesubsection_{12}(\Bindirectnamemap) \\ + \end{array} + + +.. index:: tag, tag parameter, tag parameter index +.. _binary-tagparamnamesec: + +Tag Parameter Names +................... + +The *tag parameter name subsection* has the id 13. +It consists of an :ref:`indirect name map ` assigning parameter names to tag parameter :ref:`indices ` grouped by their respective :ref:`tag indices `. + +.. math:: + \begin{array}{llclll} + \production{tag parameter name subsection} & \Btagparamnamesubsec &::=& + \Bnamesubsection_{13}(\Bindirectnamemap) \\ + \end{array} + + .. index:: ! name annotation, name, Unicode UTF-8 .. _text-nameannot: diff --git a/document/core/util/macros.def b/document/core/util/macros.def index 730999870..717cb83b8 100644 --- a/document/core/util/macros.def +++ b/document/core/util/macros.def @@ -1824,6 +1824,8 @@ .. |Bdatanamesubsec| mathdef:: \xref{appendix/custom}{binary-datanamesec}{\B{datanamesubsec}} .. |Bfieldnamesubsec| mathdef:: \xref{appendix/custom}{binary-fieldnamesec}{\B{fieldnamesubsec}} .. |Btagnamesubsec| mathdef:: \xref{appendix/custom}{binary-tagnamesec}{\B{tagnamesubsec}} +.. |Bparamnamesubsec| mathdef:: \xref{appendix/custom}{binary-paramnamesec}{\B{paramnamesubsec}} +.. |Btagparamnamesubsec| mathdef:: \xref{appendix/custom}{binary-tagparamnamesec}{\B{tagparamnamesubsec}} .. Annotations diff --git a/proposals/extended-name-section/Overview.md b/proposals/extended-name-section/Overview.md index c8b6c6971..e9a038654 100644 --- a/proposals/extended-name-section/Overview.md +++ b/proposals/extended-name-section/Overview.md @@ -18,6 +18,8 @@ The following new subsections are defined for the custom name section: | [global names](#global-names) | `7` | | [element segment names](#element-segment-names) | `8` | | [data segment names](#data-segment-names) | `9` | +| [parameter names](#parameter-names) | `12` | +| [tag parameter names](#tag-parameter-names) | `13` | ### Label Names @@ -44,3 +46,15 @@ The *element segment name subsection* has the id 8. It consists of a [name map]( ### Data Segment Names The *data segment name subsection* has the id 9. It consists of a [name map](https://webassembly.github.io/spec/core/appendix/custom.html#binary-namemap) assigning data segment names to [data segment indices](https://webassembly.github.io/spec/core/binary/modules.html#binary-dataidx). + +### Parameter Names + +The *parameter name subsection* has the id 12. It consists of an [indirect name map](https://webassembly.github.io/spec/core/appendix/custom.html#binary-indirectnamemap) assigning parameter names to parameter indices grouped by [type indices](https://webassembly.github.io/spec/core/syntax/modules.html#syntax-typeidx) for function types. + +Note that this section assigns names to parameters in *function types*, not type uses (i.e. parameters written inline in function definitions or imports). Such parameters are already covered by the local name subsection. + +### Tag Parameter Names + +The *tag parameter name subsection* has the id 13. It consists of an [indirect name map](https://webassembly.github.io/spec/core/appendix/custom.html#binary-indirectnamemap) assigning parameter names to parameter indices grouped by [tag indices](https://webassembly.github.io/spec/core/syntax/modules.html#syntax-tagidx). + +This subsection exists because the names assigned to tag parameters belong to a type use, not a type definition, but because the type use is not associated with a function, the local name subsection cannot be used.