Types¶
Value Types¶
\[\begin{split}\begin{array}{llcll@{\qquad\qquad}l}
\def\mathdef3055#1{{}}\mathdef3055{value type} & \href{../text/types.html#text-valtype}{\mathtt{valtype}} &::=&
\def\mathdef3112#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3112{i32} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{i32}} \\ &&|&
\def\mathdef3113#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3113{i64} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{i64}} \\ &&|&
\def\mathdef3114#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3114{f32} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{f32}} \\ &&|&
\def\mathdef3115#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3115{f64} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{f64}} \\
\end{array}\end{split}\]
Result Types¶
\[\begin{split}\begin{array}{llclll@{\qquad\qquad}l}
\def\mathdef3055#1{{}}\mathdef3055{result type} & \href{../text/types.html#text-resulttype}{\mathtt{resulttype}} &::=&
(t{:}\href{../text/types.html#text-functype}{\mathtt{result}})^? &\Rightarrow& [t^?] \\
\end{array}\end{split}\]
Note
In future versions of WebAssembly, this scheme may be extended to support multiple results or more general result types.
Function Types¶
\[\begin{split}\begin{array}{llclll@{\qquad\qquad}l}
\def\mathdef3055#1{{}}\mathdef3055{function type} & \href{../text/types.html#text-functype}{\mathtt{functype}} &::=&
\def\mathdef3116#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3116{(}~\def\mathdef3117#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3117{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\mathdef3118#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3118{)}
&\Rightarrow& [t_1^\ast] \href{../syntax/types.html#syntax-functype}{\rightarrow} [t_2^\ast] \\
\def\mathdef3055#1{{}}\mathdef3055{parameter} & \href{../text/types.html#text-functype}{\mathtt{param}} &::=&
\def\mathdef3119#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3119{(}~\def\mathdef3120#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3120{param}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}}~\def\mathdef3121#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3121{)}
&\Rightarrow& t \\
\def\mathdef3055#1{{}}\mathdef3055{result} & \href{../text/types.html#text-functype}{\mathtt{result}} &::=&
\def\mathdef3122#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3122{(}~\def\mathdef3123#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3123{result}~~t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}}~\def\mathdef3124#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3124{)}
&\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\mathdef3055#1{{}}\mathdef3055{parameter} &
\def\mathdef3125#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3125{(}~~\def\mathdef3126#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3126{param}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}^\ast~~\def\mathdef3127#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3127{)} &\equiv&
(\def\mathdef3128#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3128{(}~~\def\mathdef3129#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3129{param}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}~~\def\mathdef3130#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3130{)})^\ast \\
\def\mathdef3055#1{{}}\mathdef3055{result} &
\def\mathdef3131#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3131{(}~~\def\mathdef3132#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3132{result}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}^\ast~~\def\mathdef3133#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3133{)} &\equiv&
(\def\mathdef3134#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3134{(}~~\def\mathdef3135#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3135{result}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}~~\def\mathdef3136#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3136{)})^\ast \\
\end{array}\end{split}\]
Limits¶
\[\begin{split}\begin{array}{llclll}
\def\mathdef3055#1{{}}\mathdef3055{limits} & \href{../text/types.html#text-limits}{\mathtt{limits}} &::=&
n{:}\href{../text/values.html#text-int}{\def\mathdef3100#1{{\mathtt{u}#1}}\mathdef3100{\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\mathdef3100#1{{\mathtt{u}#1}}\mathdef3100{\mathtt{32}}}~~m{:}\href{../text/values.html#text-int}{\def\mathdef3100#1{{\mathtt{u}#1}}\mathdef3100{\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\mathdef3055#1{{}}\mathdef3055{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\mathdef3055#1{{}}\mathdef3055{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\mathdef3055#1{{}}\mathdef3055{element type} & \href{../text/types.html#text-elemtype}{\mathtt{elemtype}} &::=&
\def\mathdef3137#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3137{anyfunc} &\Rightarrow& \href{../syntax/types.html#syntax-elemtype}{\mathsf{anyfunc}} \\
\end{array}\end{split}\]
Note
Additional element types may be introduced in future versions of WebAssembly.
Global Types¶
\[\begin{split}\begin{array}{llclll}
\def\mathdef3055#1{{}}\mathdef3055{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\mathdef3138#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3138{(}~\def\mathdef3139#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3139{mut}~~t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}}~\def\mathdef3140#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3140{)} &\Rightarrow& \href{../syntax/types.html#syntax-mut}{\mathsf{var}}~t \\
\end{array}\end{split}\]