32 lines
710 B
Rust
Raw Normal View History

use elements::FunctionType;
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
}
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> {
Err(Error::Trap("invoke index on empty externals".into()))
2017-12-14 15:33:40 +01:00
}
fn check_signature(&self, _index: HostFuncIndex, _signature: &FunctionType) -> bool {
false
2017-12-14 15:33:40 +01:00
}
2017-12-11 16:28:05 +01:00
}