Types

Value Types

\[\begin{split}\begin{array}{llcll@{\qquad\qquad}l} \def\mathdef3070#1{{}}\mathdef3070{value type} & \href{../text/types.html#text-valtype}{\mathtt{valtype}} &::=& \def\mathdef3127#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3127{i32} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{i32}} \\ &&|& \def\mathdef3128#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3128{i64} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{i64}} \\ &&|& \def\mathdef3129#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3129{f32} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{f32}} \\ &&|& \def\mathdef3130#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3130{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\mathdef3070#1{{}}\mathdef3070{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\mathdef3070#1{{}}\mathdef3070{function type} & \href{../text/types.html#text-functype}{\mathtt{functype}} &::=& \def\mathdef3131#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3131{(}~\def\mathdef3132#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3132{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\mathdef3133#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3133{)} &\Rightarrow& [t_1^\ast] \href{../syntax/types.html#syntax-functype}{\rightarrow} [t_2^\ast] \\ \def\mathdef3070#1{{}}\mathdef3070{parameter} & \href{../text/types.html#text-functype}{\mathtt{param}} &::=& \def\mathdef3134#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3134{(}~\def\mathdef3135#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3135{param}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}}~\def\mathdef3136#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3136{)} &\Rightarrow& t \\ \def\mathdef3070#1{{}}\mathdef3070{result} & \href{../text/types.html#text-functype}{\mathtt{result}} &::=& \def\mathdef3137#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3137{(}~\def\mathdef3138#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3138{result}~~t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}}~\def\mathdef3139#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3139{)} &\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\mathdef3070#1{{}}\mathdef3070{parameter} & \def\mathdef3140#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3140{(}~~\def\mathdef3141#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3141{param}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}^\ast~~\def\mathdef3142#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3142{)} &\equiv& (\def\mathdef3143#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3143{(}~~\def\mathdef3144#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3144{param}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}~~\def\mathdef3145#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3145{)})^\ast \\ \def\mathdef3070#1{{}}\mathdef3070{result} & \def\mathdef3146#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3146{(}~~\def\mathdef3147#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3147{result}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}^\ast~~\def\mathdef3148#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3148{)} &\equiv& (\def\mathdef3149#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3149{(}~~\def\mathdef3150#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3150{result}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}~~\def\mathdef3151#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3151{)})^\ast \\ \end{array}\end{split}\]

Limits

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