Skip to content

Latest commit

 

History

History
173 lines (132 loc) · 4.06 KB

types.rst

File metadata and controls

173 lines (132 loc) · 4.06 KB
.. index:: type
   pair: text format; type

Types

.. index:: number type
   pair: text format; number type

Number Types

\begin{array}{llcll@{\qquad\qquad}l}
\production{number type} & \Tnumtype &::=&
  \text{i32} &\Rightarrow& \I32 \\ &&|&
  \text{i64} &\Rightarrow& \I64 \\ &&|&
  \text{f32} &\Rightarrow& \F32 \\ &&|&
  \text{f64} &\Rightarrow& \F64 \\
\end{array}
.. index:: vector type
   pair: text format; vector type

Vector Types

\begin{array}{llcll@{\qquad\qquad}l}
\production{vector type} & \Tvectype &::=&
  \text{v128} &\Rightarrow& \V128 \\
\end{array}
.. index:: reference type
   pair: text format; reference type

Reference Types

\begin{array}{llcll@{\qquad\qquad}l}
\production{reference type} & \Treftype &::=&
  \text{funcref} &\Rightarrow& \FUNCREF \\ &&|&
  \text{externref} &\Rightarrow& \EXTERNREF \\
\production{heap type} & \Theaptype &::=&
  \text{func} &\Rightarrow& \FUNCREF \\ &&|&
  \text{extern} &\Rightarrow& \EXTERNREF \\
\end{array}
.. index:: value type, number type, vector type, reference type
   pair: text format; value type

Value Types

\begin{array}{llcll@{\qquad\qquad}l}
\production{value type} & \Tvaltype &::=&
  t{:}\Tnumtype &\Rightarrow& t \\ &&|&
  t{:}\Tvectype &\Rightarrow& t \\ &&|&
  t{:}\Treftype &\Rightarrow& t \\
\end{array}
.. index:: function type, value type, result type
   pair: text format; function type

Function Types

\begin{array}{llclll@{\qquad\qquad}l}
\production{function type} & \Tfunctype &::=&
  \text{(}~\text{func}~~t_1^\ast{:\,}\Tvec(\Tparam)~~t_2^\ast{:\,}\Tvec(\Tresult)~\text{)}
    &\Rightarrow& [t_1^\ast] \to [t_2^\ast] \\
\production{parameter} & \Tparam &::=&
  \text{(}~\text{param}~~\Tid^?~~t{:}\Tvaltype~\text{)}
    &\Rightarrow& t \\
\production{result} & \Tresult &::=&
  \text{(}~\text{result}~~t{:}\Tvaltype~\text{)}
    &\Rightarrow& t \\
\end{array}

Note

The optional identifier names for parameters in a function type only have documentation purpose. They cannot be referenced from anywhere.

Abbreviations

Multiple anonymous parameters or results may be combined into a single declaration:

\begin{array}{llclll}
\production{parameter} &
  \text{(}~~\text{param}~~\Tvaltype^\ast~~\text{)} &\equiv&
  (\text{(}~~\text{param}~~\Tvaltype~~\text{)})^\ast \\
\production{result} &
  \text{(}~~\text{result}~~\Tvaltype^\ast~~\text{)} &\equiv&
  (\text{(}~~\text{result}~~\Tvaltype~~\text{)})^\ast \\
\end{array}
.. index:: limits
   pair: text format; limits

Limits

\begin{array}{llclll}
\production{limits} & \Tlimits &::=&
  n{:}\Tu32 &\Rightarrow& \{ \LMIN~n, \LMAX~\epsilon \} \\ &&|&
  n{:}\Tu32~~m{:}\Tu32 &\Rightarrow& \{ \LMIN~n, \LMAX~m \} \\
\end{array}
.. index:: memory type, limits, page size
   pair: text format; memory type

Memory Types

\begin{array}{llclll@{\qquad\qquad}l}
\production{memory type} & \Tmemtype &::=&
  \X{lim}{:}\Tlimits &\Rightarrow& \X{lim} \\
\end{array}
.. index:: table type, reference type, limits
   pair: text format; table type

Table Types

\begin{array}{llclll}
\production{table type} & \Ttabletype &::=&
  \X{lim}{:}\Tlimits~~\X{et}{:}\Treftype &\Rightarrow& \X{lim}~\X{et} \\
\end{array}
.. index:: global type, mutability, value type
   pair: text format; global type
   pair: text format; mutability

Global Types

\begin{array}{llclll}
\production{global type} & \Tglobaltype &::=&
  t{:}\Tvaltype &\Rightarrow& \MCONST~t \\ &&|&
  \text{(}~\text{mut}~~t{:}\Tvaltype~\text{)} &\Rightarrow& \MVAR~t \\
\end{array}