Types

Value Types

\[\begin{split}\begin{array}{llcll@{\qquad\qquad}l} \def\mathdef3086#1{{}}\mathdef3086{value type} & \href{../text/types.html#text-valtype}{\mathtt{valtype}} &::=& \def\mathdef3143#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3143{i32} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{i32}} \\ &&|& \def\mathdef3144#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3144{i64} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{i64}} \\ &&|& \def\mathdef3145#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3145{f32} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{f32}} \\ &&|& \def\mathdef3146#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3146{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\mathdef3086#1{{}}\mathdef3086{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\mathdef3086#1{{}}\mathdef3086{function type} & \href{../text/types.html#text-functype}{\mathtt{functype}} &::=& \def\mathdef3147#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3147{(}~\def\mathdef3148#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3148{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\mathdef3149#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3149{)} &\Rightarrow& [t_1^\ast] \href{../syntax/types.html#syntax-functype}{\rightarrow} [t_2^\ast] \\ \def\mathdef3086#1{{}}\mathdef3086{parameter} & \href{../text/types.html#text-functype}{\mathtt{param}} &::=& \def\mathdef3150#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3150{(}~\def\mathdef3151#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3151{param}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}}~\def\mathdef3152#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3152{)} &\Rightarrow& t \\ \def\mathdef3086#1{{}}\mathdef3086{result} & \href{../text/types.html#text-functype}{\mathtt{result}} &::=& \def\mathdef3153#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3153{(}~\def\mathdef3154#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3154{result}~~t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}}~\def\mathdef3155#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3155{)} &\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\mathdef3086#1{{}}\mathdef3086{parameter} & \def\mathdef3156#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3156{(}~~\def\mathdef3157#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3157{param}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}^\ast~~\def\mathdef3158#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3158{)} &\equiv& (\def\mathdef3159#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3159{(}~~\def\mathdef3160#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3160{param}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}~~\def\mathdef3161#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3161{)})^\ast \\ \def\mathdef3086#1{{}}\mathdef3086{result} & \def\mathdef3162#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3162{(}~~\def\mathdef3163#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3163{result}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}^\ast~~\def\mathdef3164#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3164{)} &\equiv& (\def\mathdef3165#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3165{(}~~\def\mathdef3166#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3166{result}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}~~\def\mathdef3167#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3167{)})^\ast \\ \end{array}\end{split}\]

Limits

\[\begin{split}\begin{array}{llclll} \def\mathdef3086#1{{}}\mathdef3086{limits} & \href{../text/types.html#text-limits}{\mathtt{limits}} &::=& n{:}\href{../text/values.html#text-int}{\def\mathdef3131#1{{\mathtt{u}#1}}\mathdef3131{\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\mathdef3131#1{{\mathtt{u}#1}}\mathdef3131{\mathtt{32}}}~~m{:}\href{../text/values.html#text-int}{\def\mathdef3131#1{{\mathtt{u}#1}}\mathdef3131{\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\mathdef3086#1{{}}\mathdef3086{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\mathdef3086#1{{}}\mathdef3086{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\mathdef3086#1{{}}\mathdef3086{element type} & \href{../text/types.html#text-elemtype}{\mathtt{elemtype}} &::=& \def\mathdef3168#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3168{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\mathdef3086#1{{}}\mathdef3086{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\mathdef3169#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3169{(}~\def\mathdef3170#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3170{mut}~~t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}}~\def\mathdef3171#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3171{)} &\Rightarrow& \href{../syntax/types.html#syntax-mut}{\mathsf{var}}~t \\ \end{array}\end{split}\]