Types¶
Number Types¶
\[\begin{split}\begin{array}{llcll@{\qquad\qquad}l}
\def\mathdef3842#1{{}}\mathdef3842{number type} & \href{../text/types.html#text-numtype}{\mathtt{numtype}} &::=&
\def\mathdef3881#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3881{i32} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{i32}} \\ &&|&
\def\mathdef3882#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3882{i64} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{i64}} \\ &&|&
\def\mathdef3883#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3883{f32} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{f32}} \\ &&|&
\def\mathdef3884#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3884{f64} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{f64}} \\
\end{array}\end{split}\]
Vector Types¶
\[\begin{split}\begin{array}{llcll@{\qquad\qquad}l}
\def\mathdef3842#1{{}}\mathdef3842{vector type} & \href{../text/types.html#text-vectype}{\mathtt{vectype}} &::=&
\def\mathdef3885#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3885{v128} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{v128}} \\
\end{array}\end{split}\]
Reference Types¶
\[\begin{split}\begin{array}{llcll@{\qquad\qquad}l}
\def\mathdef3842#1{{}}\mathdef3842{reference type} & \href{../text/types.html#text-reftype}{\mathtt{reftype}} &::=&
\def\mathdef3886#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3886{funcref} &\Rightarrow& \href{../syntax/types.html#syntax-reftype}{\mathsf{funcref}} \\ &&|&
\def\mathdef3887#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3887{externref} &\Rightarrow& \href{../syntax/types.html#syntax-reftype}{\mathsf{externref}} \\
\def\mathdef3842#1{{}}\mathdef3842{heap type} & \href{../text/types.html#text-heaptype}{\mathtt{heaptype}} &::=&
\def\mathdef3888#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3888{func} &\Rightarrow& \href{../syntax/types.html#syntax-reftype}{\mathsf{funcref}} \\ &&|&
\def\mathdef3889#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3889{extern} &\Rightarrow& \href{../syntax/types.html#syntax-reftype}{\mathsf{externref}} \\
\end{array}\end{split}\]
Value Types¶
\[\begin{split}\begin{array}{llcll@{\qquad\qquad}l}
\def\mathdef3842#1{{}}\mathdef3842{value type} & \href{../text/types.html#text-valtype}{\mathtt{valtype}} &::=&
t{:}\href{../text/types.html#text-numtype}{\mathtt{numtype}} &\Rightarrow& t \\ &&|&
t{:}\href{../text/types.html#text-vectype}{\mathtt{vectype}} &\Rightarrow& t \\ &&|&
t{:}\href{../text/types.html#text-reftype}{\mathtt{reftype}} &\Rightarrow& t \\
\end{array}\end{split}\]
Function Types¶
\[\begin{split}\begin{array}{llclll@{\qquad\qquad}l}
\def\mathdef3842#1{{}}\mathdef3842{function type} & \href{../text/types.html#text-functype}{\mathtt{functype}} &::=&
\def\mathdef3890#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3890{(}~\def\mathdef3891#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3891{func}~~t_1^\ast{:\,}\href{../text/conventions.html#text-vec}{\mathtt{vec}}(\href{../text/types.html#text-functype}{\mathtt{param}})~~t_2^\ast{:\,}\href{../text/conventions.html#text-vec}{\mathtt{vec}}(\href{../text/types.html#text-functype}{\mathtt{result}})~\def\mathdef3892#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3892{)}
&\Rightarrow& [t_1^\ast] \href{../syntax/types.html#syntax-functype}{\rightarrow} [t_2^\ast] \\
\def\mathdef3842#1{{}}\mathdef3842{parameter} & \href{../text/types.html#text-functype}{\mathtt{param}} &::=&
\def\mathdef3893#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3893{(}~\def\mathdef3894#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3894{param}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}}~\def\mathdef3895#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3895{)}
&\Rightarrow& t \\
\def\mathdef3842#1{{}}\mathdef3842{result} & \href{../text/types.html#text-functype}{\mathtt{result}} &::=&
\def\mathdef3896#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3896{(}~\def\mathdef3897#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3897{result}~~t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}}~\def\mathdef3898#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3898{)}
&\Rightarrow& t \\
\end{array}\end{split}\]
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{split}\begin{array}{llclll}
\def\mathdef3842#1{{}}\mathdef3842{parameter} &
\def\mathdef3899#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3899{(}~~\def\mathdef3900#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3900{param}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}^\ast~~\def\mathdef3901#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3901{)} &\equiv&
(\def\mathdef3902#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3902{(}~~\def\mathdef3903#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3903{param}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}~~\def\mathdef3904#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3904{)})^\ast \\
\def\mathdef3842#1{{}}\mathdef3842{result} &
\def\mathdef3905#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3905{(}~~\def\mathdef3906#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3906{result}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}^\ast~~\def\mathdef3907#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3907{)} &\equiv&
(\def\mathdef3908#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3908{(}~~\def\mathdef3909#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3909{result}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}~~\def\mathdef3910#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3910{)})^\ast \\
\end{array}\end{split}\]
Limits¶
\[\begin{split}\begin{array}{llclll}
\def\mathdef3842#1{{}}\mathdef3842{limits} & \href{../text/types.html#text-limits}{\mathtt{limits}} &::=&
n{:}\href{../text/values.html#text-int}{\def\mathdef3867#1{{\mathtt{u}#1}}\mathdef3867{\mathtt{32}}} &\Rightarrow& \{ \href{../syntax/types.html#syntax-limits}{\mathsf{min}}~n, \href{../syntax/types.html#syntax-limits}{\mathsf{max}}~\epsilon \} \\ &&|&
n{:}\href{../text/values.html#text-int}{\def\mathdef3867#1{{\mathtt{u}#1}}\mathdef3867{\mathtt{32}}}~~m{:}\href{../text/values.html#text-int}{\def\mathdef3867#1{{\mathtt{u}#1}}\mathdef3867{\mathtt{32}}} &\Rightarrow& \{ \href{../syntax/types.html#syntax-limits}{\mathsf{min}}~n, \href{../syntax/types.html#syntax-limits}{\mathsf{max}}~m \} \\
\end{array}\end{split}\]
Memory Types¶
\[\begin{split}\begin{array}{llclll@{\qquad\qquad}l}
\def\mathdef3842#1{{}}\mathdef3842{memory type} & \href{../text/types.html#text-memtype}{\mathtt{memtype}} &::=&
\mathit{lim}{:}\href{../text/types.html#text-limits}{\mathtt{limits}} &\Rightarrow& \mathit{lim} \\
\end{array}\end{split}\]
Table Types¶
\[\begin{split}\begin{array}{llclll}
\def\mathdef3842#1{{}}\mathdef3842{table type} & \href{../text/types.html#text-tabletype}{\mathtt{tabletype}} &::=&
\mathit{lim}{:}\href{../text/types.html#text-limits}{\mathtt{limits}}~~\mathit{et}{:}\href{../text/types.html#text-reftype}{\mathtt{reftype}} &\Rightarrow& \mathit{lim}~\mathit{et} \\
\end{array}\end{split}\]
Global Types¶
\[\begin{split}\begin{array}{llclll}
\def\mathdef3842#1{{}}\mathdef3842{global type} & \href{../text/types.html#text-globaltype}{\mathtt{globaltype}} &::=&
t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}} &\Rightarrow& \href{../syntax/types.html#syntax-mut}{\mathsf{const}}~t \\ &&|&
\def\mathdef3911#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3911{(}~\def\mathdef3912#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3912{mut}~~t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}}~\def\mathdef3913#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3913{)} &\Rightarrow& \href{../syntax/types.html#syntax-mut}{\mathsf{var}}~t \\
\end{array}\end{split}\]