Skip to content

[spec] Fix typing rule for module instances #1516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion document/core/appendix/index-rules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Construct Judgement
:ref:`Table instance <valid-tableinst>` :math:`S \vdashtableinst \tableinst : \tabletype`
:ref:`Memory instance <valid-meminst>` :math:`S \vdashmeminst \meminst : \memtype`
:ref:`Global instance <valid-globalinst>` :math:`S \vdashglobalinst \globalinst : \globaltype`
:ref:`Element instance <valid-eleminst>` :math:`S \vdasheleminst \eleminst \ok`
:ref:`Element instance <valid-eleminst>` :math:`S \vdasheleminst \eleminst : t`
:ref:`Data instance <valid-datainst>` :math:`S \vdashdatainst \datainst \ok`
:ref:`Export instance <valid-exportinst>` :math:`S \vdashexportinst \exportinst \ok`
:ref:`Module instance <valid-moduleinst>` :math:`S \vdashmoduleinst \moduleinst : C`
Expand Down
28 changes: 17 additions & 11 deletions document/core/appendix/properties.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Module instances are classified by *module contexts*, which are regular :ref:`co

* Each :ref:`global instance <syntax-globalinst>` :math:`\globalinst_i` in :math:`S.\SGLOBALS` must be :ref:`valid <valid-globalinst>` with some :ref:`global type <syntax-globaltype>` :math:`\globaltype_i`.

* Each :ref:`element instance <syntax-eleminst>` :math:`\eleminst_i` in :math:`S.\SELEMS` must be :ref:`valid <valid-eleminst>`.
* Each :ref:`element instance <syntax-eleminst>` :math:`\eleminst_i` in :math:`S.\SELEMS` must be :ref:`valid <valid-eleminst>` with some :ref:`reference type <syntax-reftype>` :math:`\reftype_i`.

* Each :ref:`data instance <syntax-datainst>` :math:`\datainst_i` in :math:`S.\SDATAS` must be :ref:`valid <valid-datainst>`.

Expand All @@ -105,7 +105,7 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
\qquad
(S \vdashglobalinst \globalinst : \globaltype)^\ast
\\
(S \vdasheleminst \eleminst \ok)^\ast
(S \vdasheleminst \eleminst : \reftype)^\ast
\qquad
(S \vdashdatainst \datainst \ok)^\ast
\\
Expand Down Expand Up @@ -285,13 +285,13 @@ Module instances are classified by *module contexts*, which are regular :ref:`co

* The :ref:`reference <syntax-ref>` :math:`\reff_i` must be :ref:`valid <valid-ref>` with :ref:`reference type <syntax-reftype>` :math:`t`.

* Then the table instance is valid.
* Then the element instance is valid with :ref:`reference type <syntax-reftype>` :math:`t`.

.. math::
\frac{
(S \vdash \reff : t)^\ast
}{
S \vdasheleminst \{ \EITYPE~t, \EIELEM~\reff^\ast \} \ok
S \vdasheleminst \{ \EITYPE~t, \EIELEM~\reff^\ast \} : t
}


Expand Down Expand Up @@ -344,7 +344,7 @@ Module instances are classified by *module contexts*, which are regular :ref:`co

* For each :ref:`global address <syntax-globaladdr>` :math:`\globaladdr_i` in :math:`\moduleinst.\MIGLOBALS`, the :ref:`external value <syntax-externval>` :math:`\EVGLOBAL~\globaladdr_i` must be :ref:`valid <valid-externval-global>` with some :ref:`external type <syntax-externtype>` :math:`\ETGLOBAL~\globaltype_i`.

* For each :ref:`element address <syntax-elemaddr>` :math:`\elemaddr_i` in :math:`\moduleinst.\MIELEMS`, the :ref:`element instance <syntax-eleminst>` :math:`S.\SELEMS[\elemaddr_i]` must be :ref:`valid <valid-eleminst>`.
* For each :ref:`element address <syntax-elemaddr>` :math:`\elemaddr_i` in :math:`\moduleinst.\MIELEMS`, the :ref:`element instance <syntax-eleminst>` :math:`S.\SELEMS[\elemaddr_i]` must be :ref:`valid <valid-eleminst>` with some :ref:`reference type <syntax-reftype>` :math:`\reftype_i`.

* For each :ref:`data address <syntax-dataaddr>` :math:`\dataaddr_i` in :math:`\moduleinst.\MIDATAS`, the :ref:`data instance <syntax-datainst>` :math:`S.\SDATAS[\dataaddr_i]` must be :ref:`valid <valid-datainst>`.

Expand All @@ -360,8 +360,12 @@ Module instances are classified by *module contexts*, which are regular :ref:`co

* Let :math:`\globaltype^\ast` be the concatenation of all :math:`\globaltype_i` in order.

* | Then the module instance is valid with :ref:`context <context>`
| :math:`\{\CTYPES~\functype^\ast, \CFUNCS~{\functype'}^\ast, \CTABLES~\tabletype^\ast, \CMEMS~\memtype^\ast, \CGLOBALS~\globaltype^\ast\}`.
* Let :math:`\reftype^\ast` be the concatenation of all :math:`\reftype_i` in order.

* Let :math:`n` be the length of :math:`\moduleinst.\MIDATAS`.

* Then the module instance is valid with :ref:`context <context>`
:math:`\{\CTYPES~\functype^\ast,` :math:`\CFUNCS~{\functype'}^\ast,` :math:`\CTABLES~\tabletype^\ast,` :math:`\CMEMS~\memtype^\ast,` :math:`\CGLOBALS~\globaltype^\ast,` :math:`\CELEMS~\reftype^\ast,` :math:`\CDATAS~{\ok}^n\}`.

.. math::
~\\[-1ex]
Expand All @@ -377,9 +381,9 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
\qquad
(S \vdashexternval \EVGLOBAL~\globaladdr : \ETGLOBAL~\globaltype)^\ast
\\
(S \vdasheleminst S.\SELEMS[\elemaddr] \ok)^\ast
(S \vdasheleminst S.\SELEMS[\elemaddr] : \reftype)^\ast
\qquad
(S \vdashdatainst S.\SDATAS[\dataaddr] \ok)^\ast
(S \vdashdatainst S.\SDATAS[\dataaddr] \ok)^n
\\
(S \vdashexportinst \exportinst \ok)^\ast
\qquad
Expand All @@ -394,14 +398,16 @@ Module instances are classified by *module contexts*, which are regular :ref:`co
\MIMEMS & \memaddr^\ast, \\
\MIGLOBALS & \globaladdr^\ast, \\
\MIELEMS & \elemaddr^\ast, \\
\MIDATAS & \dataaddr^\ast, \\
\MIDATAS & \dataaddr^n, \\
\MIEXPORTS & \exportinst^\ast ~\} : \{
\begin{array}[t]{@{}l@{~}l@{}}
\CTYPES & \functype^\ast, \\
\CFUNCS & {\functype'}^\ast, \\
\CTABLES & \tabletype^\ast, \\
\CMEMS & \memtype^\ast, \\
\CGLOBALS & \globaltype^\ast ~\}
\CGLOBALS & \globaltype^\ast, \\
\CELEMS & \reftype^\ast, \\
\CDATAS & {\ok}^n ~\}
\end{array}
\end{array}
}
Expand Down