pub(crate) mod inner;
pub(crate) use inner::*;
use wasmer_types::{TagType, Type};
use crate::{
AsStoreMut, AsStoreRef, ExportError, Exportable, Extern,
vm::{VMExtern, VMExternTag},
};
#[derive(Debug, Clone, PartialEq, Eq, derive_more::From)]
#[cfg_attr(feature = "artifact-size", derive(loupe::MemoryUsage))]
pub struct Tag(pub(crate) BackendTag);
impl Tag {
pub fn new<P: Into<Box<[Type]>>>(store: &mut impl AsStoreMut, params: P) -> Self {
Self(BackendTag::new(store, params))
}
pub fn ty(&self, store: &impl AsStoreRef) -> TagType {
self.0.ty(store)
}
pub(crate) fn from_vm_extern(store: &mut impl AsStoreMut, vm_extern: VMExternTag) -> Self {
Self(BackendTag::from_vm_extern(store, vm_extern))
}
pub fn is_from_store(&self, store: &impl AsStoreRef) -> bool {
self.0.is_from_store(store)
}
pub(crate) fn to_vm_extern(&self) -> VMExtern {
self.0.to_vm_extern()
}
}
impl<'a> Exportable<'a> for Tag {
fn get_self_from_extern(_extern: &'a Extern) -> Result<&'a Self, ExportError> {
match _extern {
Extern::Tag(tag) => Ok(tag),
_ => Err(ExportError::IncompatibleType),
}
}
}