MCPcopy Create free account
hub / github.com/explodingcamera/tinywasm / call_resumable_inner

Method call_resumable_inner

crates/tinywasm/src/func.rs:56–80  ·  view source on GitHub ↗
(
            func: &Function,
            store: &mut Store,
            params: &[WasmValue],
        )

Source from the content-addressed store, hash-verified

54 ) -> Result<FuncExecution<'store>> {
55 #[inline]
56 fn call_resumable_inner(
57 func: &Function,
58 store: &mut Store,
59 params: &[WasmValue],
60 ) -> Result<FuncExecutionState> {
61 let func_instance = store.state.get_func(func.addr);
62 match func_instance {
63 FunctionInstance::Host(host_func) => host_func
64 .clone()
65 .call(FuncContext { store, module_addr: func.module_addr }, params)
66 .map(|result| FuncExecutionState::Completed { result: Some(result) }),
67 FunctionInstance::Wasm(wasm_func) => {
68 store.call_stack.clear();
69 store.value_stack.clear();
70 store.value_stack.extend_from_wasmvalues(params)?;
71 let locals_base = store.value_stack.enter_locals(&wasm_func.func.params, &wasm_func.func.locals)?;
72 let callframe = CallFrame::new(func.addr, locals_base, wasm_func.func.locals);
73
74 Ok(FuncExecutionState::Running {
75 exec_state: ExecutionState { callframe },
76 root_func_addr: func.addr,
77 })
78 }
79 }
80 }
81
82 self.item.validate_store(store)?;
83 validate_call_params(&self.ty, params)?;

Callers

nothing calls this directly

Calls 6

get_funcMethod · 0.80
mapMethod · 0.80
callMethod · 0.80
enter_localsMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected