wasmer/backend/sys/
vm.rs

1//! The `vm` module re-exports wasmer-vm types.
2use crate::entities::{Function, Global, Memory, Table, Tag};
3use crate::store::AsStoreMut;
4pub use wasmer_vm::*;
5
6/// The type of extern tables in the `sys` VM.
7pub type VMExternTable = InternalStoreHandle<VMTable>;
8///
9/// The type of extern memories in the `sys` VM.
10pub type VMExternMemory = InternalStoreHandle<VMMemory>;
11
12/// The type of extern globals in the `sys` VM.
13pub type VMExternGlobal = InternalStoreHandle<VMGlobal>;
14
15/// The type of extern functions in the `sys` VM.
16pub type VMExternFunction = InternalStoreHandle<VMFunction>;
17
18/// The type of extern tags in the `sys` VM.
19pub(crate) type VMExternTag = InternalStoreHandle<VMTag>;
20
21/// The type of function callbacks in the `sys` VM.
22pub type VMFunctionCallback = *const VMFunctionBody;
23
24impl crate::VMExternToExtern for VMExtern {
25    fn to_extern(self, store: &mut impl AsStoreMut) -> crate::Extern {
26        match self {
27            Self::Function(f) => crate::Extern::Function(Function::from_vm_extern(
28                store,
29                crate::vm::VMExternFunction::Sys(f),
30            )),
31            Self::Memory(m) => crate::Extern::Memory(Memory::from_vm_extern(
32                store,
33                crate::vm::VMExternMemory::Sys(m),
34            )),
35            Self::Global(g) => crate::Extern::Global(Global::from_vm_extern(
36                store,
37                crate::vm::VMExternGlobal::Sys(g),
38            )),
39            Self::Table(t) => crate::Extern::Table(Table::from_vm_extern(
40                store,
41                crate::vm::VMExternTable::Sys(t),
42            )),
43            Self::Tag(t) => {
44                crate::Extern::Tag(Tag::from_vm_extern(store, crate::vm::VMExternTag::Sys(t)))
45            }
46        }
47    }
48}