Skip to main content

submilli_wasm/value/
ref_const.rs

1//! wasmtime-compatible reference-type constants (`RefType::EXTERNREF`, `ValType::FUNCREF`, …).
2//! All denote *nullable* references. Split from [`types`](super::types) to keep that file under
3//! the size cap; these are inherent `const`s on the (already-exported) `RefType`/`ValType`.
4
5use super::types::{HeapType, RefType, ValType};
6
7impl RefType {
8    /// The `funcref` type, aka `(ref null func)`.
9    pub const FUNCREF: Self = RefType::new_nullable(HeapType::Func);
10    /// The `nullfuncref` type, aka `(ref null nofunc)`.
11    pub const NULLFUNCREF: Self = RefType::new_nullable(HeapType::NoFunc);
12    /// The `externref` type, aka `(ref null extern)`.
13    pub const EXTERNREF: Self = RefType::new_nullable(HeapType::Extern);
14    /// The `nullexternref` type, aka `(ref null noextern)`.
15    pub const NULLEXTERNREF: Self = RefType::new_nullable(HeapType::NoExtern);
16    /// The `anyref` type, aka `(ref null any)`.
17    pub const ANYREF: Self = RefType::new_nullable(HeapType::Any);
18    /// The `eqref` type, aka `(ref null eq)`.
19    pub const EQREF: Self = RefType::new_nullable(HeapType::Eq);
20    /// The `i31ref` type, aka `(ref null i31)`.
21    pub const I31REF: Self = RefType::new_nullable(HeapType::I31);
22    /// The `structref` type, aka `(ref null struct)`.
23    pub const STRUCTREF: Self = RefType::new_nullable(HeapType::Struct);
24    /// The `arrayref` type, aka `(ref null array)`.
25    pub const ARRAYREF: Self = RefType::new_nullable(HeapType::Array);
26    /// The `nullref` type, aka `(ref null none)`.
27    pub const NULLREF: Self = RefType::new_nullable(HeapType::None);
28    /// The `exnref` type, aka `(ref null exn)`.
29    pub const EXNREF: Self = RefType::new_nullable(HeapType::Exn);
30    /// The `nullexnref` type, aka `(ref null noexn)`.
31    pub const NULLEXNREF: Self = RefType::new_nullable(HeapType::NoExn);
32}
33
34impl ValType {
35    /// The `funcref` type, aka `(ref null func)`.
36    pub const FUNCREF: Self = ValType::Ref(RefType::FUNCREF);
37    /// The `nullfuncref` type, aka `(ref null nofunc)`.
38    pub const NULLFUNCREF: Self = ValType::Ref(RefType::NULLFUNCREF);
39    /// The `externref` type, aka `(ref null extern)`.
40    pub const EXTERNREF: Self = ValType::Ref(RefType::EXTERNREF);
41    /// The `nullexternref` type, aka `(ref null noextern)`.
42    pub const NULLEXTERNREF: Self = ValType::Ref(RefType::NULLEXTERNREF);
43    /// The `anyref` type, aka `(ref null any)`.
44    pub const ANYREF: Self = ValType::Ref(RefType::ANYREF);
45    /// The `eqref` type, aka `(ref null eq)`.
46    pub const EQREF: Self = ValType::Ref(RefType::EQREF);
47    /// The `i31ref` type, aka `(ref null i31)`.
48    pub const I31REF: Self = ValType::Ref(RefType::I31REF);
49    /// The `structref` type, aka `(ref null struct)`.
50    pub const STRUCTREF: Self = ValType::Ref(RefType::STRUCTREF);
51    /// The `arrayref` type, aka `(ref null array)`.
52    pub const ARRAYREF: Self = ValType::Ref(RefType::ARRAYREF);
53    /// The `nullref` type, aka `(ref null none)`.
54    pub const NULLREF: Self = ValType::Ref(RefType::NULLREF);
55    /// The `exnref` type, aka `(ref null exn)`.
56    pub const EXNREF: Self = ValType::Ref(RefType::EXNREF);
57    /// The `nullexnref` type, aka `(ref null noexn)`.
58    pub const NULLEXNREF: Self = ValType::Ref(RefType::NULLEXNREF);
59}