Types¶
Value Types¶
\[\begin{split}\begin{array}{llcll@{\qquad\qquad}l}
\def\mathdef2370#1{{}}\mathdef2370{value type} & \href{../text/types.html#text-valtype}{\mathtt{valtype}} &::=&
\def\mathdef2407#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2407{i32} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{i32}} \\ &&|&
\def\mathdef2408#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2408{i64} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{i64}} \\ &&|&
\def\mathdef2409#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2409{f32} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{f32}} \\ &&|&
\def\mathdef2410#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2410{f64} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{f64}} \\
\end{array}\end{split}\]
Function Types¶
\[\begin{split}\begin{array}{llclll@{\qquad\qquad}l}
\def\mathdef2370#1{{}}\mathdef2370{function type} & \href{../text/types.html#text-functype}{\mathtt{functype}} &::=&
\def\mathdef2411#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2411{(}~\def\mathdef2412#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2412{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\mathdef2413#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2413{)}
&\Rightarrow& [t_1^\ast] \href{../syntax/types.html#syntax-functype}{\rightarrow} [t_2^\ast] \\
\def\mathdef2370#1{{}}\mathdef2370{parameter} & \href{../text/types.html#text-functype}{\mathtt{param}} &::=&
\def\mathdef2414#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2414{(}~\def\mathdef2415#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2415{param}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}}~\def\mathdef2416#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2416{)}
&\Rightarrow& t \\
\def\mathdef2370#1{{}}\mathdef2370{result} & \href{../text/types.html#text-functype}{\mathtt{result}} &::=&
\def\mathdef2417#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2417{(}~\def\mathdef2418#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2418{result}~~t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}}~\def\mathdef2419#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2419{)}
&\Rightarrow& t \\
\end{array}\end{split}\]
Abbreviations¶
Multiple anonymous parameters or results may be combined into a single declaration:
\[\begin{split}\begin{array}{llclll}
\def\mathdef2370#1{{}}\mathdef2370{parameter} &
\def\mathdef2420#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2420{(}~~\def\mathdef2421#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2421{param}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}^\ast~~\def\mathdef2422#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2422{)} &\equiv&
(\def\mathdef2423#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2423{(}~~\def\mathdef2424#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2424{param}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}~~\def\mathdef2425#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2425{)})^\ast \\
\def\mathdef2370#1{{}}\mathdef2370{result} &
\def\mathdef2426#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2426{(}~~\def\mathdef2427#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2427{result}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}^\ast~~\def\mathdef2428#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2428{)} &\equiv&
(\def\mathdef2429#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2429{(}~~\def\mathdef2430#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2430{result}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}~~\def\mathdef2431#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2431{)})^\ast \\
\end{array}\end{split}\]
Limits¶
\[\begin{split}\begin{array}{llclll}
\def\mathdef2370#1{{}}\mathdef2370{limits} & \href{../text/types.html#text-limits}{\mathtt{limits}} &::=&
n{:}\href{../text/values.html#text-int}{\def\mathdef2395#1{{\mathtt{u}#1}}\mathdef2395{\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\mathdef2395#1{{\mathtt{u}#1}}\mathdef2395{\mathtt{32}}}~~m{:}\href{../text/values.html#text-int}{\def\mathdef2395#1{{\mathtt{u}#1}}\mathdef2395{\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\mathdef2370#1{{}}\mathdef2370{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\mathdef2370#1{{}}\mathdef2370{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-elemtype}{\mathtt{elemtype}} &\Rightarrow& \mathit{lim}~\mathit{et} \\
\def\mathdef2370#1{{}}\mathdef2370{element type} & \href{../text/types.html#text-elemtype}{\mathtt{elemtype}} &::=&
\def\mathdef2432#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2432{funcref} &\Rightarrow& \href{../syntax/types.html#syntax-elemtype}{\mathsf{funcref}} \\
\end{array}\end{split}\]
Note
Additional element types may be introduced in future versions of WebAssembly.
Global Types¶
\[\begin{split}\begin{array}{llclll}
\def\mathdef2370#1{{}}\mathdef2370{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\mathdef2433#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2433{(}~\def\mathdef2434#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2434{mut}~~t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}}~\def\mathdef2435#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef2435{)} &\Rightarrow& \href{../syntax/types.html#syntax-mut}{\mathsf{var}}~t \\
\end{array}\end{split}\]