51 lines
1.4 KiB
Rust
Raw Normal View History

use elements::FunctionType;
2017-12-13 18:19:42 +01:00
use interpreter::global::GlobalInstance;
2017-12-13 14:36:06 +01:00
use interpreter::memory::MemoryInstance;
use interpreter::table::TableInstance;
use interpreter::value::RuntimeValue;
2017-12-11 16:28:05 +01:00
use interpreter::Error;
2017-12-11 19:22:45 +01:00
pub type HostFuncIndex = u32;
2017-12-15 18:23:54 +03:00
pub trait Externals {
fn invoke_index(
2017-12-18 16:37:48 +03:00
&mut self,
index: HostFuncIndex,
args: &[RuntimeValue],
) -> Result<Option<RuntimeValue>, Error>;
2017-12-12 15:18:35 +01:00
fn check_signature(&self, index: HostFuncIndex, signature: &FunctionType) -> bool;
2017-12-11 19:22:45 +01:00
fn memory_by_index(&self, index: usize) -> &MemoryInstance;
fn table_by_index(&self, index: usize) -> &TableInstance;
fn global_by_index(&self, index: usize) -> &GlobalInstance;
2017-12-11 19:22:45 +01:00
}
pub struct EmptyExternals;
2017-12-14 15:33:40 +01:00
impl Externals for EmptyExternals {
fn invoke_index(
&mut self,
_index: HostFuncIndex,
_args: &[RuntimeValue],
) -> Result<Option<RuntimeValue>, Error> {
panic!("called invoke_index on EmptyExternals")
2017-12-14 15:33:40 +01:00
}
fn check_signature(&self, _index: HostFuncIndex, _signature: &FunctionType) -> bool {
panic!("called check_signature on EmptyExternals")
2017-12-14 15:33:40 +01:00
}
fn memory_by_index(&self, _index: usize) -> &MemoryInstance {
panic!("called memory_by_index on EmptyExternals")
2017-12-14 15:33:40 +01:00
}
2017-12-11 19:22:45 +01:00
fn table_by_index(&self, _index: usize) -> &TableInstance {
panic!("called table_by_index on EmptyExternals")
2017-12-11 16:28:05 +01:00
}
2017-12-18 15:18:53 +03:00
fn global_by_index(&self, _index: usize) -> &GlobalInstance {
panic!("called global_by_index on EmptyExternals")
2017-12-11 16:28:05 +01:00
}
}