@@ -486,6 +486,7 @@ A :ref:`start function <syntax-start>` is defined in terms of its index.
486486.. _text-elem :
487487.. _text-elemlist :
488488.. _text-elemexpr :
489+ .. _text-tableuse :
489490
490491Element Segments
491492~~~~~~~~~~~~~~~~
@@ -497,13 +498,16 @@ Element segments allow for an optional :ref:`table index <text-tableidx>` to ide
497498 \production {element segment} & \Telem _I &::=&
498499 \text {(}~\text {elem}~~\Tid ^?~~(et, y^\ast ){:}\Telemlist ~\text {)} \\ &&& \qquad
499500 \Rightarrow \quad \{ \ETYPE ~et, \EINIT ~y^\ast , \EMODE ~\EPASSIVE \} \\ &&|&
500- \text {(}~\text {elem}~~\Tid ^?~~\text {(}~ \text {table}~~ x{:}\Ttableidx _I ~ \text {)} ~~\text {(}~\text {offset}~~e{:}\Texpr _I~\text {)}~~(et, y^\ast ){:}\Telemlist ~\text {)} \\ &&& \qquad
501+ \text {(}~\text {elem}~~\Tid ^?~~x{:}\Ttableuse _I ~~\text {(}~\text {offset}~~e{:}\Texpr _I~\text {)}~~(et, y^\ast ){:}\Telemlist ~\text {)} \\ &&& \qquad
501502 \Rightarrow \quad \{ \ETYPE ~et, \EINIT ~y^\ast , \EMODE ~\EACTIVE ~\{ \ETABLE ~x, \EOFFSET ~e \} \} \\
502503 \production {element list} & \Telemlist &::=&
503504 et{:}\Telemtype ~~y^\ast {:}\Tvec (\Telemexpr _I) \qquad \Rightarrow \quad ( \ETYPE ~et, \EINIT ~y^\ast ) \\
504505 \production {element expression} & \Telemexpr &::=&
505506 \text {(}~\text {ref.null}~\text {)} \\ &&|&
506507 \text {(}~\text {ref.func}~~\Tfuncidx _I~\text {)} \\
508+ \production {table use} & \Ttableuse _I &::=&
509+ \text {(}~\text {table}~~x{:}\Ttableidx _I ~\text {)}
510+ \quad \Rightarrow \quad x \\
507511 \end {array}
508512
509513 .. note ::
@@ -532,17 +536,16 @@ Also, the element list may be written as just a sequence of :ref:`function indic
532536 \text {funcref}~~\Tvec (\text {(}~\text {ref.func}~~\Tfuncidx _I~\text {)})
533537 \end {array}
534538
535- Also, the table index can be omitted, defaulting to :math: `\T {0 }`.
536- Furthermore, for backwards compatibility with earlier versions of WebAssembly, if the table index is omitted, the :math: `\text {func}` keyword can be omitted as well.
539+ Also, a table use can be omitted, defaulting to :math: `\T {0 }`.
540+ Furthermore, for backwards compatibility with earlier versions of WebAssembly, if the table use is omitted, the :math: `\text {func}` keyword can be omitted as well.
537541
538542.. math ::
539- \begin {array}{ll}
543+ \begin {array}{llclll}
544+ \production {table use} &
545+ \epsilon &\equiv & \text {(}~\text {table}~~\text {0 }~\text {)} \\
540546 \production {element segment} &
541- \text {(}~\text {elem}~~\Tid ^?~~\text {(}~\text {offset}~~\Texpr _I~\text {)}~~\Telemlist ~\text {)}
542- \quad \equiv \\&
543- \text {(}~\text {elem}~~\Tid ^?~~\text {(}~\text {table}~~\text {0 }~\text {)}~~\text {(}~\text {offset}~~\Texpr _I~\text {)}~~\Telemlist ~\text {)} \\
544- \text {(}~\text {elem}~~\Tid ^?~~\text {(}~\text {offset}~~\Texpr _I~\text {)}~~\Tvec (\Tfuncidx _I)~\text {)}
545- \quad \equiv \\&
547+ \text {(}~\text {elem}~~\Tid ^?~~\text {(}~\text {offset}~~\Texpr _I~\text {)}~~\Tvec (\Tfuncidx _I)~\text {)}
548+ &\equiv &
546549 \text {(}~\text {elem}~~\Tid ^?~~\text {(}~\text {table}~~\text {0 }~\text {)}~~\text {(}~\text {offset}~~\Texpr _I~\text {)}~~\text {func}~~\Tvec (\Tfuncidx _I)~\text {)}
547550 \end {array}
548551
@@ -555,6 +558,7 @@ As another abbreviation, element segments may also be specified inline with :ref
555558 single: data; segment
556559.. _text-datastring :
557560.. _text-data :
561+ .. _test-memuse :
558562
559563Data Segments
560564~~~~~~~~~~~~~
@@ -567,10 +571,13 @@ The data is written as a :ref:`string <text-string>`, which may be split up into
567571 \production {data segment} & \Tdata _I &::=&
568572 \text {(}~\text {data}~~\Tid ^?~~b^\ast {:}\Tdatastring ~\text {)} \\ &&& \qquad
569573 \Rightarrow \quad \{ \DINIT ~b^\ast , \DMODE ~\DPASSIVE \} \\ &&|&
570- \text {(}~\text {data}~~\Tid ^?~~\text {(}~ \text {memory}~~ x{:}\Tmemidx _I ~ \text {)} ~~\text {(}~\text {offset}~~e{:}\Texpr _I~\text {)}~~b^\ast {:}\Tdatastring ~\text {)} \\ &&& \qquad
574+ \text {(}~\text {data}~~\Tid ^?~~x{:}\Tmemuse _I ~~\text {(}~\text {offset}~~e{:}\Texpr _I~\text {)}~~b^\ast {:}\Tdatastring ~\text {)} \\ &&& \qquad
571575 \Rightarrow \quad \{ \DINIT ~b^\ast , \DMODE ~\DACTIVE ~\{ \DMEM ~x', \DOFFSET ~e \} \} \\
572576 \production {data string} & \Tdatastring &::=&
573577 (b^\ast {:}\Tstring )^\ast \quad \Rightarrow \quad \concat ((b^\ast )^\ast ) \\
578+ \production {memory use} & \Tmemuse _I &::=&
579+ \text {(}~\text {memory}~~x{:}\Tmemidx _I ~\text {)}
580+ \quad \Rightarrow \quad x \\
574581 \end {array}
575582
576583 .. note ::
@@ -590,14 +597,12 @@ As an abbreviation, a single instruction may occur in place of the offset of an
590597 \text {(}~\text {offset}~~\Tinstr ~\text {)}
591598 \end {array}
592599
593- Also, the memory index can be omitted, defaulting to :math: `\T {0 }`.
600+ Also, a memory use can be omitted, defaulting to :math: `\T {0 }`.
594601
595602.. math ::
596603 \begin {array}{llclll}
597- \production {data segment} &
598- \text {(}~\text {data}~~\Tid ^?~~\text {(}~\text {offset}~~\Texpr _I~\text {)}~~\dots ~\text {)}
599- &\equiv &
600- \text {(}~\text {data}~~\Tid ^?~~\text {(}~\text {memory}~~\text {0 }~\text {)}~~\text {(}~\text {offset}~~\Texpr _I~\text {)}~~\dots ~\text {)}
604+ \production {memory use} &
605+ \epsilon &\equiv & \text {(}~\text {memory}~~\text {0 }~\text {)} \\
601606 \end {array}
602607
603608 As another abbreviation, data segments may also be specified inline with :ref: `memory <text-mem >` definitions; see the respective section.
0 commit comments