use super::super::RunWasmGcHost;
pub(super) fn dispatch(
name: &str,
caller: &mut wasmtime::Caller<'_, RunWasmGcHost>,
params: &[wasmtime::Val],
_results: &mut [wasmtime::Val],
) -> Result<bool, wasmtime::Error> {
use wasmtime::Val;
match name {
"record_enter_group" => {
if let Some(rec) = caller.data_mut().recorder.as_mut() {
rec.enter_group();
}
Ok(true)
}
"record_set_branch" => {
let branch = match params.first() {
Some(Val::I64(n)) => *n as u32,
_ => 0,
};
if let Some(rec) = caller.data_mut().recorder.as_mut() {
rec.set_branch(branch);
}
Ok(true)
}
"record_exit_group" => {
if let Some(rec) = caller.data_mut().recorder.as_mut() {
rec.exit_group();
}
Ok(true)
}
_ => Ok(false),
}
}