use crate::MemoryError;
use crate::{Memory, Table};
use crate::{MemoryStyle, TableStyle};
use crate::{VMMemoryDefinition, VMTableDefinition};
use unc_vm_types::{MemoryType, TableType};
use std::ptr::NonNull;
use std::sync::Arc;
pub trait Tunables: Sync {
fn memory_style(&self, memory: &MemoryType) -> MemoryStyle;
fn table_style(&self, table: &TableType) -> TableStyle;
fn create_host_memory(
&self,
ty: &MemoryType,
style: &MemoryStyle,
) -> Result<Arc<dyn Memory>, MemoryError>;
unsafe fn create_vm_memory(
&self,
ty: &MemoryType,
style: &MemoryStyle,
vm_definition_location: NonNull<VMMemoryDefinition>,
) -> Result<Arc<dyn Memory>, MemoryError>;
fn create_host_table(
&self,
ty: &TableType,
style: &TableStyle,
) -> Result<Arc<dyn Table>, String>;
unsafe fn create_vm_table(
&self,
ty: &TableType,
style: &TableStyle,
vm_definition_location: NonNull<VMTableDefinition>,
) -> Result<Arc<dyn Table>, String>;
fn stack_limiter_cfg(&self) -> Box<dyn finite_wasm::max_stack::SizeConfig>;
fn gas_cfg(&self) -> Box<dyn finite_wasm::wasmparser::VisitOperator<Output = u64>>;
fn stack_init_gas_cost(&self, frame_size: u64) -> u64;
}
#[doc(hidden)]
pub struct TestTunables;
impl Tunables for TestTunables {
fn memory_style(&self, _memory: &MemoryType) -> MemoryStyle {
unimplemented!()
}
fn table_style(&self, _table: &TableType) -> TableStyle {
unimplemented!()
}
fn create_host_memory(
&self,
_ty: &MemoryType,
_style: &MemoryStyle,
) -> Result<Arc<dyn Memory>, MemoryError> {
unimplemented!()
}
unsafe fn create_vm_memory(
&self,
_ty: &MemoryType,
_style: &MemoryStyle,
_vm_definition_location: NonNull<VMMemoryDefinition>,
) -> Result<Arc<dyn Memory>, MemoryError> {
unimplemented!()
}
fn create_host_table(
&self,
_ty: &TableType,
_style: &TableStyle,
) -> Result<Arc<dyn Table>, String> {
unimplemented!()
}
unsafe fn create_vm_table(
&self,
_ty: &TableType,
_style: &TableStyle,
_vm_definition_location: NonNull<VMTableDefinition>,
) -> Result<Arc<dyn Table>, String> {
unimplemented!()
}
fn stack_limiter_cfg(&self) -> Box<dyn finite_wasm::max_stack::SizeConfig> {
unimplemented!()
}
fn gas_cfg(&self) -> Box<dyn finite_wasm::wasmparser::VisitOperator<Output = u64>> {
unimplemented!()
}
fn stack_init_gas_cost(&self, _frame_size: u64) -> u64 {
unimplemented!()
}
}