ValuesΒΆ
Value TypingΒΆ
For the purpose of checking argument values against the parameter types of exported functions, values are classified by value types. The following auxiliary typing rules specify this typing relation relative to a store \(S\) in which possibly referenced addresses live.
Numeric ValuesΒΆ
The number value \(({\mathit{nt}}{.}\href{../syntax/instructions.html#syntax-instr-numeric}{\mathsf{const}}~c)\) is valid with the number type \({\mathit{nt}}\).
Vector ValuesΒΆ
The vector value \(({\mathit{vt}}{.}\href{../syntax/instructions.html#syntax-instr-vec}{\mathsf{const}}~c)\) is valid with the vector type \({\mathit{vt}}\).
Null ReferencesΒΆ
The reference value \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}null}}\) is valid with the reference type \((\href{../syntax/types.html#syntax-reftype}{\mathsf{ref}}~\href{../syntax/types.html#syntax-reftype}{\mathsf{null}}~\href{../valid/conventions.html#syntax-valtype-ext}{\mathsf{bot}})\).
Scalar ReferencesΒΆ
The reference value \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}i\scriptstyle31}}~i)\) is valid with the reference type \((\href{../syntax/types.html#syntax-reftype}{\mathsf{ref}}~\href{../syntax/types.html#syntax-heaptype}{\mathsf{i\scriptstyle31}})\).
Structure ReferencesΒΆ
The reference value \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}struct}}~a)\) is valid with the reference type \((\href{../syntax/types.html#syntax-reftype}{\mathsf{ref}}~{\mathit{dt}})\) if:
The structure instance \(s{.}\href{../exec/runtime.html#syntax-store}{\mathsf{structs}}{}[a]\) exists.
The defined type \(s{.}\href{../exec/runtime.html#syntax-store}{\mathsf{structs}}{}[a]{.}\href{../exec/runtime.html#syntax-structinst}{\mathsf{type}}\) is of the form \({\mathit{dt}}\).
Array ReferencesΒΆ
The reference value \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}array}}~a)\) is valid with the reference type \((\href{../syntax/types.html#syntax-reftype}{\mathsf{ref}}~{\mathit{dt}})\) if:
The array instance \(s{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}{}[a]\) exists.
The defined type \(s{.}\href{../exec/runtime.html#syntax-store}{\mathsf{arrays}}{}[a]{.}\href{../exec/runtime.html#syntax-arrayinst}{\mathsf{type}}\) is of the form \({\mathit{dt}}\).
Exception ReferencesΒΆ
The reference value \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}exn}}~a)\) is valid with the reference type \((\href{../syntax/types.html#syntax-reftype}{\mathsf{ref}}~\href{../syntax/types.html#syntax-heaptype}{\mathsf{exn}})\) if:
The exception instance \(s{.}\href{../exec/runtime.html#syntax-store}{\mathsf{exns}}{}[a]\) exists.
Function ReferencesΒΆ
The reference value \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}func}}~a)\) is valid with the reference type \((\href{../syntax/types.html#syntax-reftype}{\mathsf{ref}}~{\mathit{dt}})\) if:
The function instance \(s{.}\href{../exec/runtime.html#syntax-store}{\mathsf{funcs}}{}[a]\) exists.
The defined type \(s{.}\href{../exec/runtime.html#syntax-store}{\mathsf{funcs}}{}[a]{.}\href{../exec/runtime.html#syntax-funcinst}{\mathsf{type}}\) is of the form \({\mathit{dt}}\).
Host ReferencesΒΆ
The reference value \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}host}}~a)\) is valid with the reference type \((\href{../syntax/types.html#syntax-reftype}{\mathsf{ref}}~\href{../syntax/types.html#syntax-heaptype}{\mathsf{any}})\).
Note
A bare host reference is considered internalized.
External ReferencesΒΆ
The reference value \((\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}extern}}~{\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}})\) is valid with the reference type \((\href{../syntax/types.html#syntax-reftype}{\mathsf{ref}}~\href{../syntax/types.html#syntax-heaptype}{\mathsf{extern}})\) if:
The reference value \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}\) is valid with the reference type \((\href{../syntax/types.html#syntax-reftype}{\mathsf{ref}}~\href{../syntax/types.html#syntax-heaptype}{\mathsf{any}})\).
The reference value \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}\) is not of the form \(\href{../exec/runtime.html#syntax-ref}{\mathsf{ref{.}null}}\).
SubsumptionΒΆ
The reference value \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}\) is valid with the reference type \({\mathit{rt}}\) if:
The reference value \({\href{../exec/runtime.html#syntax-ref}{\mathit{ref}}}\) is valid with the reference type \({\mathit{rt}'}\).
The reference type \({\mathit{rt}'}\) matches the reference type \({\mathit{rt}}\).
External TypingΒΆ
For the purpose of checking external address against imports, such values are classified by external types. The following auxiliary typing rules specify this typing relation relative to a store \(S\) in which the referenced instances live.
FunctionsΒΆ
The external address \((\href{../exec/runtime.html#syntax-externaddr}{\mathsf{func}}~a)\) is valid with the external type \((\href{../syntax/types.html#syntax-externtype}{\mathsf{func}}~{\href{../exec/runtime.html#syntax-funcinst}{\mathit{funcinst}}}{.}\href{../exec/runtime.html#syntax-funcinst}{\mathsf{type}})\) if:
The function instance \(s{.}\href{../exec/runtime.html#syntax-store}{\mathsf{funcs}}{}[a]\) exists.
The function instance \(s{.}\href{../exec/runtime.html#syntax-store}{\mathsf{funcs}}{}[a]\) is of the form \({\href{../exec/runtime.html#syntax-funcinst}{\mathit{funcinst}}}\).
TablesΒΆ
The external address \((\href{../exec/runtime.html#syntax-externaddr}{\mathsf{table}}~a)\) is valid with the external type \((\href{../syntax/types.html#syntax-externtype}{\mathsf{table}}~{\href{../exec/runtime.html#syntax-tableinst}{\mathit{tableinst}}}{.}\href{../exec/runtime.html#syntax-tableinst}{\mathsf{type}})\) if:
The table instance \(s{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[a]\) exists.
The table instance \(s{.}\href{../exec/runtime.html#syntax-store}{\mathsf{tables}}{}[a]\) is of the form \({\href{../exec/runtime.html#syntax-tableinst}{\mathit{tableinst}}}\).
MemoriesΒΆ
The external address \((\href{../exec/runtime.html#syntax-externaddr}{\mathsf{mem}}~a)\) is valid with the external type \((\href{../syntax/types.html#syntax-externtype}{\mathsf{mem}}~{\href{../exec/runtime.html#syntax-meminst}{\mathit{meminst}}}{.}\href{../exec/runtime.html#syntax-meminst}{\mathsf{type}})\) if:
The memory instance \(s{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[a]\) exists.
The memory instance \(s{.}\href{../exec/runtime.html#syntax-store}{\mathsf{mems}}{}[a]\) is of the form \({\href{../exec/runtime.html#syntax-meminst}{\mathit{meminst}}}\).
GlobalsΒΆ
The external address \((\href{../exec/runtime.html#syntax-externaddr}{\mathsf{global}}~a)\) is valid with the external type \((\href{../syntax/types.html#syntax-externtype}{\mathsf{global}}~{\href{../exec/runtime.html#syntax-globalinst}{\mathit{globalinst}}}{.}\href{../exec/runtime.html#syntax-globalinst}{\mathsf{type}})\) if:
The global instance \(s{.}\href{../exec/runtime.html#syntax-store}{\mathsf{globals}}{}[a]\) exists.
The global instance \(s{.}\href{../exec/runtime.html#syntax-store}{\mathsf{globals}}{}[a]\) is of the form \({\href{../exec/runtime.html#syntax-globalinst}{\mathit{globalinst}}}\).
SubsumptionΒΆ
The external address \({\href{../exec/runtime.html#syntax-externaddr}{\mathit{externaddr}}}\) is valid with the external type \({\mathit{xt}}\) if:
The external address \({\href{../exec/runtime.html#syntax-externaddr}{\mathit{externaddr}}}\) is valid with the external type \({\mathit{xt}'}\).
The external type \({\mathit{xt}'}\) matches the external type \({\mathit{xt}}\).