Types

Value Types

\[\begin{split}\begin{array}{llcll@{\qquad\qquad}l} \def\mathdef2997#1{{}}\mathdef2997{value type} & \href{../text/types.html#text-valtype}{\mathtt{valtype}} &::=& \def\mathdef3054#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3054{i32} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{i32}} \\ &&|& \def\mathdef3055#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3055{i64} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{i64}} \\ &&|& \def\mathdef3056#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3056{f32} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{f32}} \\ &&|& \def\mathdef3057#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3057{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\mathdef2997#1{{}}\mathdef2997{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\mathdef2997#1{{}}\mathdef2997{function type} & \href{../text/types.html#text-functype}{\mathtt{functype}} &::=& \def\mathdef3058#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3058{(}~\def\mathdef3059#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3059{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\mathdef3060#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3060{)} &\Rightarrow& [t_1^\ast] \href{../syntax/types.html#syntax-functype}{\rightarrow} [t_2^\ast] \\ \def\mathdef2997#1{{}}\mathdef2997{parameter} & \href{../text/types.html#text-functype}{\mathtt{param}} &::=& \def\mathdef3061#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3061{(}~\def\mathdef3062#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3062{param}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}}~\def\mathdef3063#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3063{)} &\Rightarrow& t \\ \def\mathdef2997#1{{}}\mathdef2997{result} & \href{../text/types.html#text-functype}{\mathtt{result}} &::=& \def\mathdef3064#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3064{(}~\def\mathdef3065#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3065{result}~~t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}}~\def\mathdef3066#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3066{)} &\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\mathdef2997#1{{}}\mathdef2997{parameter} & \def\mathdef3067#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3067{(}~~\def\mathdef3068#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3068{param}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}^\ast~~\def\mathdef3069#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3069{)} &\equiv& (\def\mathdef3070#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3070{(}~~\def\mathdef3071#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3071{param}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}~~\def\mathdef3072#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3072{)})^\ast \\ \def\mathdef2997#1{{}}\mathdef2997{result} & \def\mathdef3073#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3073{(}~~\def\mathdef3074#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3074{result}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}^\ast~~\def\mathdef3075#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3075{)} &\equiv& (\def\mathdef3076#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3076{(}~~\def\mathdef3077#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3077{result}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}~~\def\mathdef3078#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3078{)})^\ast \\ \end{array}\end{split}\]

Limits

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