use alloc::string::String;
use alloc::vec::Vec;
use crate::execution::{hooks::HookSet, value::InteropValueList, RuntimeInstance};
use crate::{RuntimeError, ValType, Value};
pub struct FunctionRef {
pub(crate) module_name: String,
pub(crate) function_name: String,
pub(crate) module_index: usize,
pub(crate) function_index: usize,
pub(crate) exported: bool,
}
impl FunctionRef {
pub fn invoke<H: HookSet, Param: InteropValueList, Returns: InteropValueList>(
&self,
runtime: &mut RuntimeInstance<H>,
params: Param,
) -> Result<Returns, RuntimeError> {
runtime.invoke(self, params)
}
pub fn invoke_dynamic<H: HookSet>(
&self,
runtime: &mut RuntimeInstance<H>,
params: Vec<Value>,
ret_types: &[ValType],
) -> Result<Vec<Value>, RuntimeError> {
runtime.invoke_dynamic(self, params, ret_types)
}
}