Types

Value Types

\[\begin{split}\begin{array}{llcll@{\qquad\qquad}l} \def\mathdef3402#1{{}}\mathdef3402{value type} & \href{../text/types.html#text-valtype}{\mathtt{valtype}} &::=& \def\mathdef3459#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3459{i32} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{i32}} \\ &&|& \def\mathdef3460#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3460{i64} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{i64}} \\ &&|& \def\mathdef3461#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3461{f32} &\Rightarrow& \href{../syntax/types.html#syntax-valtype}{\mathsf{f32}} \\ &&|& \def\mathdef3462#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3462{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\mathdef3402#1{{}}\mathdef3402{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\mathdef3402#1{{}}\mathdef3402{function type} & \href{../text/types.html#text-functype}{\mathtt{functype}} &::=& \def\mathdef3463#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3463{(}~\def\mathdef3464#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3464{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\mathdef3465#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3465{)} &\Rightarrow& [t_1^\ast] \href{../syntax/types.html#syntax-functype}{\rightarrow} [t_2^\ast] \\ \def\mathdef3402#1{{}}\mathdef3402{parameter} & \href{../text/types.html#text-functype}{\mathtt{param}} &::=& \def\mathdef3466#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3466{(}~\def\mathdef3467#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3467{param}~~\href{../text/values.html#text-id}{\mathtt{id}}^?~~t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}}~\def\mathdef3468#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3468{)} &\Rightarrow& t \\ \def\mathdef3402#1{{}}\mathdef3402{result} & \href{../text/types.html#text-functype}{\mathtt{result}} &::=& \def\mathdef3469#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3469{(}~\def\mathdef3470#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3470{result}~~t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}}~\def\mathdef3471#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3471{)} &\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\mathdef3402#1{{}}\mathdef3402{parameter} & \def\mathdef3472#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3472{(}~~\def\mathdef3473#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3473{param}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}^\ast~~\def\mathdef3474#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3474{)} &\equiv& (\def\mathdef3475#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3475{(}~~\def\mathdef3476#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3476{param}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}~~\def\mathdef3477#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3477{)})^\ast \\ \def\mathdef3402#1{{}}\mathdef3402{result} & \def\mathdef3478#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3478{(}~~\def\mathdef3479#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3479{result}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}^\ast~~\def\mathdef3480#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3480{)} &\equiv& (\def\mathdef3481#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3481{(}~~\def\mathdef3482#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3482{result}~~\href{../text/types.html#text-valtype}{\mathtt{valtype}}~~\def\mathdef3483#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3483{)})^\ast \\ \end{array}\end{split}\]

Limits

\[\begin{split}\begin{array}{llclll} \def\mathdef3402#1{{}}\mathdef3402{limits} & \href{../text/types.html#text-limits}{\mathtt{limits}} &::=& n{:}\href{../text/values.html#text-int}{\def\mathdef3447#1{{\mathtt{u}#1}}\mathdef3447{\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\mathdef3447#1{{\mathtt{u}#1}}\mathdef3447{\mathtt{32}}}~~m{:}\href{../text/values.html#text-int}{\def\mathdef3447#1{{\mathtt{u}#1}}\mathdef3447{\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\mathdef3402#1{{}}\mathdef3402{memory type} & \href{../text/types.html#text-memtype}{\mathtt{memtype}} &::=& \mathit{lim}{:}\href{../text/types.html#text-limits}{\mathtt{limits}} &\Rightarrow& \mathit{lim}~\href{../syntax/types.html#syntax-memtype}{\mathsf{unshared}} \\ &&|& \def\mathdef3484#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3484{(}~\def\mathdef3485#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3485{shared}~~\mathit{lim}{:}\href{../text/types.html#text-limits}{\mathtt{limits}}~~\def\mathdef3486#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3486{)} &\Rightarrow& \mathit{lim}~\href{../syntax/types.html#syntax-memtype}{\mathsf{shared}} \\ \end{array}\end{split}\]

Table Types

\[\begin{split}\begin{array}{llclll} \def\mathdef3402#1{{}}\mathdef3402{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\mathdef3402#1{{}}\mathdef3402{element type} & \href{../text/types.html#text-elemtype}{\mathtt{elemtype}} &::=& \def\mathdef3487#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3487{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\mathdef3402#1{{}}\mathdef3402{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\mathdef3488#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3488{(}~\def\mathdef3489#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3489{mut}~~t{:}\href{../text/types.html#text-valtype}{\mathtt{valtype}}~\def\mathdef3490#1{\mbox{‘}\mathtt{#1}\mbox{’}}\mathdef3490{)} &\Rightarrow& \href{../syntax/types.html#syntax-mut}{\mathsf{var}}~t \\ \end{array}\end{split}\]