use enum_iterator::IntoEnumIterator;
use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize};
#[cfg(feature = "enable-serde")]
use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(
Copy,
Clone,
Debug,
PartialEq,
Eq,
Hash,
IntoEnumIterator,
RkyvSerialize,
RkyvDeserialize,
Archive,
rkyv::CheckBytes,
)]
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "artifact-size", derive(loupe::MemoryUsage))]
#[archive(as = "Self")]
#[repr(u16)]
pub enum LibCall {
CeilF32,
CeilF64,
FloorF32,
FloorF64,
NearestF32,
NearestF64,
TruncF32,
TruncF64,
Memory32Size,
ImportedMemory32Size,
TableCopy,
TableInit,
TableFill,
TableSize,
ImportedTableSize,
TableGet,
ImportedTableGet,
TableSet,
ImportedTableSet,
TableGrow,
ImportedTableGrow,
FuncRef,
ElemDrop,
Memory32Copy,
ImportedMemory32Copy,
Memory32Fill,
ImportedMemory32Fill,
Memory32Init,
DataDrop,
RaiseTrap,
Probestack,
Memory32AtomicWait32,
ImportedMemory32AtomicWait32,
Memory32AtomicWait64,
ImportedMemory32AtomicWait64,
Memory32AtomicNotify,
ImportedMemory32AtomicNotify,
}
impl LibCall {
pub fn to_function_name(&self) -> &str {
match self {
Self::CeilF32 => "wasmer_vm_f32_ceil",
Self::CeilF64 => "wasmer_vm_f64_ceil",
Self::FloorF32 => "wasmer_vm_f32_floor",
Self::FloorF64 => "wasmer_vm_f64_floor",
Self::NearestF32 => "wasmer_vm_f32_nearest",
Self::NearestF64 => "wasmer_vm_f64_nearest",
Self::TruncF32 => "wasmer_vm_f32_trunc",
Self::TruncF64 => "wasmer_vm_f64_trunc",
Self::Memory32Size => "wasmer_vm_memory32_size",
Self::ImportedMemory32Size => "wasmer_vm_imported_memory32_size",
Self::TableCopy => "wasmer_vm_table_copy",
Self::TableInit => "wasmer_vm_table_init",
Self::TableFill => "wasmer_vm_table_fill",
Self::TableSize => "wasmer_vm_table_size",
Self::ImportedTableSize => "wasmer_vm_imported_table_size",
Self::TableGet => "wasmer_vm_table_get",
Self::ImportedTableGet => "wasmer_vm_imported_table_get",
Self::TableSet => "wasmer_vm_table_set",
Self::ImportedTableSet => "wasmer_vm_imported_table_set",
Self::TableGrow => "wasmer_vm_table_grow",
Self::ImportedTableGrow => "wasmer_vm_imported_table_grow",
Self::FuncRef => "wasmer_vm_func_ref",
Self::ElemDrop => "wasmer_vm_elem_drop",
Self::Memory32Copy => "wasmer_vm_memory32_copy",
Self::ImportedMemory32Copy => "wasmer_vm_imported_memory32_copy",
Self::Memory32Fill => "wasmer_vm_memory32_fill",
Self::ImportedMemory32Fill => "wasmer_vm_imported_memory32_fill",
Self::Memory32Init => "wasmer_vm_memory32_init",
Self::DataDrop => "wasmer_vm_data_drop",
Self::RaiseTrap => "wasmer_vm_raise_trap",
#[cfg(target_vendor = "apple")]
Self::Probestack => "_wasmer_vm_probestack",
#[cfg(not(target_vendor = "apple"))]
Self::Probestack => "wasmer_vm_probestack",
Self::Memory32AtomicWait32 => "wasmer_vm_memory32_atomic_wait32",
Self::ImportedMemory32AtomicWait32 => "wasmer_vm_imported_memory32_atomic_wait32",
Self::Memory32AtomicWait64 => "wasmer_vm_memory32_atomic_wait64",
Self::ImportedMemory32AtomicWait64 => "wasmer_vm_imported_memory32_atomic_wait64",
Self::Memory32AtomicNotify => "wasmer_vm_memory32_atomic_notify",
Self::ImportedMemory32AtomicNotify => "wasmer_vm_imported_memory32_atomic_notify",
}
}
}
impl fmt::Display for LibCall {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(self, f)
}
}