Skip to content

Commit 7c9e3fb

Browse files
authored
Add definition of defaultable types (WebAssembly#62)
No rules for locals yet, since those are still being discussed.
1 parent 48bfb6d commit 7c9e3fb

File tree

5 files changed

+64
-2
lines changed

5 files changed

+64
-2
lines changed

document/core/exec/runtime.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ it is the respective value :math:`0` for :ref:`number types <syntax-numtype>`, :
5858
\begin{array}{lcl@{\qquad}l}
5959
\default_t &=& t{.}\CONST~0 & (\iff t = \numtype) \\
6060
\default_t &=& t{.}\CONST~0 & (\iff t = \vectype) \\
61-
\default_t &=& \REFNULL~t & (\iff t = \reftype) \\
61+
\default_t &=& \REFNULL~t & (\iff t = (\REF~\NULL~\heaptype)) \\
6262
\end{array}
6363
6464

document/core/syntax/types.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ A *concrete* heap type consists of a :ref:`type index <syntax-typeidx>` and clas
9999
pair: abstract syntax; reference type
100100
pair: reference; type
101101
.. _syntax-reftype:
102+
.. _syntax-nullable:
102103

103104
Reference Types
104105
~~~~~~~~~~~~~~~

document/core/util/macros.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,7 @@
878878
.. Notation
879879

880880
.. |ok| mathdef:: \mathrel{\mbox{ok}}
881+
.. |defaultable| mathdef:: \xref{valid/types}{valid-defaultable}{\mathrel{\mbox{defaultable}}}
881882
.. |const| mathdef:: \xref{valid/instructions}{valid-constant}{\mathrel{\mbox{const}}}
882883

883884
.. |matchesnumtype| mathdef:: \xref{valid/matching}{match-numtype}{\leq}
@@ -924,6 +925,9 @@
924925
.. |vdashglobaltype| mathdef:: \xref{valid/types}{valid-globaltype}{\vdash}
925926
.. |vdashexterntype| mathdef:: \xref{valid/types}{valid-externtype}{\vdash}
926927

928+
.. |vdashvaltypedefaultable| mathdef:: \xref{valid/types}{valid-defaultable}{\vdash}
929+
.. |vdashtabletypedefaultable| mathdef:: \xref{valid/types}{valid-defaultable}{\vdash}
930+
927931
.. |vdashnumtypematch| mathdef:: \xref{valid/matching}{match-numtype}{\vdash}
928932
.. |vdashheaptypematch| mathdef:: \xref{valid/matching}{match-heaptype}{\vdash}
929933
.. |vdashreftypematch| mathdef:: \xref{valid/matching}{match-reftype}{\vdash}

document/core/valid/modules.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Functions :math:`\func` are classified by :ref:`function types <syntax-functype>
4848
}
4949
5050
51-
.. index:: table, table type
51+
.. index:: table, table type, defaultable
5252
pair: validation; table
5353
single: abstract syntax; table
5454
.. _valid-table:
@@ -68,6 +68,8 @@ Tables :math:`\table` are classified by :ref:`table types <syntax-tabletype>`.
6868
.. math::
6969
\frac{
7070
C \vdashtabletype \tabletype \ok
71+
\qquad
72+
C \vdashtabletypedefaultable \tabletype \defaultable
7173
}{
7274
C \vdashtable \{ \TTYPE~\tabletype \} : \tabletype
7375
}

document/core/valid/types.rst

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,3 +397,58 @@ External Types
397397
}{
398398
C \vdashexterntype \ETGLOBAL~\globaltype \ok
399399
}
400+
401+
402+
.. index:: value type, ! defaultable, number type, vector type, reference type, table type
403+
.. _valid-defaultable:
404+
405+
Defaultable Types
406+
~~~~~~~~~~~~~~~~~
407+
408+
A type is *defaultable* if it has a :ref:`default value <default-val>` for initialization.
409+
410+
Value Types
411+
...........
412+
413+
* A defaultable :ref:`value type <syntax-valtype>` :math:`t` must be:
414+
415+
- either a :ref:`number type <syntax-numtype>`,
416+
417+
- or a :ref:`vector type <syntax-vectype>`,
418+
419+
- or a :ref:`nullable reference type <syntax-numtype>`.
420+
421+
422+
.. math::
423+
\frac{
424+
}{
425+
C \vdashvaltypedefaultable \numtype \defaultable
426+
}
427+
428+
.. math::
429+
\frac{
430+
}{
431+
C \vdashvaltypedefaultable \vectype \defaultable
432+
}
433+
434+
.. math::
435+
\frac{
436+
}{
437+
C \vdashvaltypedefaultable (\REF~\NULL~\heaptype) \defaultable
438+
}
439+
440+
441+
Table Types
442+
...........
443+
444+
* A defaultable :ref:`table type <syntax-tabletype>` must be:
445+
446+
- of the form :math:`\limits~t`, where `t` is a :ref:`defaultable <valid-defaultable>` :ref:`reference type <syntax-numtype>`.
447+
448+
449+
.. math::
450+
\frac{
451+
C \vdashvaltypedefaultable \reftype \defaultable
452+
}{
453+
C \vdashtabletypedefaultable \limits~\reftype \defaultable
454+
}

0 commit comments

Comments
 (0)