Types¶
Number Types¶
\[\begin{split}\begin{array}{llcll@{\qquad\qquad}l}
\def\mathdef3705#1{{}}\mathdef3705{number type} & \href{../text/types.html#text-numtype}{\mathtt{numtype}}_I &::=&
\def\mathdef3744#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3744{i32} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{i32}} \\ &&|&
\def\mathdef3745#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3745{i64} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{i64}} \\ &&|&
\def\mathdef3746#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3746{f32} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{f32}} \\ &&|&
\def\mathdef3747#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3747{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\mathdef3705#1{{}}\mathdef3705{vector type} & \href{../text/types.html#text-vectype}{\mathtt{vectype}}_I &::=&
\def\mathdef3748#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3748{v128} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{v128}} \\
\end{array}\end{split}\]
Heap Types¶
\[\begin{split}\begin{array}{llcll@{\qquad\qquad}l}
\def\mathdef3705#1{{}}\mathdef3705{heap type} & \href{../text/types.html#text-heaptype}{\mathtt{heaptype}}_I &::=&
\def\mathdef3749#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3749{func} &\Rightarrow& \href{../syntax/types.html#syntax-heaptype}{\mathsf{func}} \\ &&|&
\def\mathdef3750#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3750{extern} &\Rightarrow& \href{../syntax/types.html#syntax-heaptype}{\mathsf{extern}} \\ &&|&
x{:}\href{../text/modules.html#text-typeidx}{\mathtt{typeidx}}_I &\Rightarrow& x \\
\end{array}\end{split}\]
Reference Types¶
\[\begin{split}\begin{array}{llcll@{\qquad\qquad}l}
\def\mathdef3705#1{{}}\mathdef3705{reference type} & \href{../text/types.html#text-reftype}{\mathtt{reftype}}_I &::=&
\def\mathdef3751#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3751{(}~\def\mathdef3752#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3752{ref}~~\mathit{ht}{:}\href{../text/types.html#text-heaptype}{\mathtt{heaptype}}~\def\mathdef3753#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3753{)}
&\Rightarrow& \href{../syntax/types.html#syntax-reftype}{\mathsf{ref}}~\mathit{ht} \\ &&|&
\def\mathdef3754#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3754{(}~\def\mathdef3755#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3755{ref}~~\def\mathdef3756#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3756{null}~~\mathit{ht}{:}\href{../text/types.html#text-heaptype}{\mathtt{heaptype}}~\def\mathdef3757#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3757{)}
&\Rightarrow& \href{../syntax/types.html#syntax-reftype}{\mathsf{ref}}~\href{../syntax/types.html#syntax-reftype}{\mathsf{null}}~\mathit{ht} \\
\end{array}\end{split}\]
Abbreviations¶
There are shorthands for references to abstract heap types.
\[\begin{split}\begin{array}{llclll}
\def\mathdef3705#1{{}}\mathdef3705{reference type} &
\def\mathdef3758#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3758{funcref} &\equiv& \def\mathdef3759#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3759{(}~\def\mathdef3760#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3760{ref}~~\def\mathdef3761#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3761{null}~~\def\mathdef3762#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3762{func}~\def\mathdef3763#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3763{)} \\
\def\mathdef3764#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3764{externref} &\equiv& \def\mathdef3765#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3765{(}~\def\mathdef3766#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3766{ref}~~\def\mathdef3767#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3767{null}~~\def\mathdef3768#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3768{extern}~\def\mathdef3769#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3769{)} \\
\end{array}\end{split}\]
Value Types¶
\[\begin{split}\begin{array}{llcll@{\qquad\qquad}l}
\def\mathdef3705#1{{}}\mathdef3705{value type} & \href{../text/types.html#text-valtype}{\mathtt{valtype}}_I &::=&
t{:}\href{../text/types.html#text-numtype}{\mathtt{numtype}}_I &\Rightarrow& t \\ &&|&
t{:}\href{../text/types.html#text-vectype}{\mathtt{vectype}}_I &\Rightarrow& t \\ &&|&
t{:}\href{../text/types.html#text-reftype}{\mathtt{reftype}}_I &\Rightarrow& t \\
\end{array}\end{split}\]
Function Types¶
\[\begin{split}\begin{array}{llclll@{\qquad\qquad}l}
\def\mathdef3705#1{{}}\mathdef3705{function type} & \href{../text/types.html#text-functype}{\mathtt{functype}}_I &::=&
\def\mathdef3770#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3770{(}~\def\mathdef3771#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3771{func}~~t_1^\ast{:\,}\href{../text/conventions.html#text-vec}{\mathtt{vec}}(\href{../text/types.html#text-functype}{\mathtt{param}}_I)~~t_2^\ast{:\,}\href{../text/conventions.html#text-vec}{\mathtt{vec}}(\href{../text/types.html#text-functype}{\mathtt{result}}_I)~\def\mathdef3772#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3772{)}
&\Rightarrow& [t_1^\ast] \href{../syntax/types.html#syntax-functype}{\rightarrow} [t_2^\ast] \\
\def\mathdef3705#1{{}}\mathdef3705{parameter} & \href{../text/types.html#text-functype}{\mathtt{param}}_I &::=&
\def\mathdef3773#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3773{(}~\def\mathdef3774#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3774{param}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}}_I~\def\mathdef3775#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3775{)}
&\Rightarrow& t \\
\def\mathdef3705#1{{}}\mathdef3705{result} & \href{../text/types.html#text-functype}{\mathtt{result}}_I &::=&
\def\mathdef3776#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3776{(}~\def\mathdef3777#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3777{result}~~t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}}_I~\def\mathdef3778#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3778{)}
&\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\mathdef3705#1{{}}\mathdef3705{parameter} &
\def\mathdef3779#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3779{(}~~\def\mathdef3780#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3780{param}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}^\ast~~\def\mathdef3781#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3781{)} &\equiv&
(\def\mathdef3782#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3782{(}~~\def\mathdef3783#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3783{param}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}~~\def\mathdef3784#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3784{)})^\ast \\
\def\mathdef3705#1{{}}\mathdef3705{result} &
\def\mathdef3785#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3785{(}~~\def\mathdef3786#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3786{result}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}^\ast~~\def\mathdef3787#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3787{)} &\equiv&
(\def\mathdef3788#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3788{(}~~\def\mathdef3789#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3789{result}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}~~\def\mathdef3790#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3790{)})^\ast \\
\end{array}\end{split}\]
Limits¶
\[\begin{split}\begin{array}{llclll}
\def\mathdef3705#1{{}}\mathdef3705{limits} & \href{../text/types.html#text-limits}{\mathtt{limits}} &::=&
n{:}\href{../text/values.html#text-int}{\def\mathdef3730#1{{\mathtt{u}#1}}\mathdef3730{\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\mathdef3730#1{{\mathtt{u}#1}}\mathdef3730{\mathtt{32}}}~~m{:}\href{../text/values.html#text-int}{\def\mathdef3730#1{{\mathtt{u}#1}}\mathdef3730{\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\mathdef3705#1{{}}\mathdef3705{memory type} & \href{../text/types.html#text-memtype}{\mathtt{memtype}}_I &::=&
\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\mathdef3705#1{{}}\mathdef3705{table type} & \href{../text/types.html#text-tabletype}{\mathtt{tabletype}}_I &::=&
\mathit{lim}{:}\href{../text/types.html#text-limits}{\mathtt{limits}}~~\mathit{et}{:}\href{../text/types.html#text-reftype}{\mathtt{reftype}}_I &\Rightarrow& \mathit{lim}~\mathit{et} \\
\end{array}\end{split}\]
Global Types¶
\[\begin{split}\begin{array}{llclll}
\def\mathdef3705#1{{}}\mathdef3705{global type} & \href{../text/types.html#text-globaltype}{\mathtt{globaltype}}_I &::=&
t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}} &\Rightarrow& \href{../syntax/types.html#syntax-mut}{\mathsf{const}}~t \\ &&|&
\def\mathdef3791#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3791{(}~\def\mathdef3792#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3792{mut}~~t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}}_I~\def\mathdef3793#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3793{)} &\Rightarrow& \href{../syntax/types.html#syntax-mut}{\mathsf{var}}~t \\
\end{array}\end{split}\]