MCPcopy Index your code
hub / github.com/explodingcamera/tinywasm / call_inner

Method call_inner

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

Source from the content-addressed store, hash-verified

12 pub fn call(&self, store: &mut Store, params: &[WasmValue]) -> Result<Vec<WasmValue>> {
13 #[inline]
14 fn call_inner(func: &Function, store: &mut Store, params: &[WasmValue]) -> Result<Vec<WasmValue>> {
15 let func_instance = store.state.get_func(func.addr);
16 let wasm_func = match func_instance {
17 FunctionInstance::Host(host_func) => {
18 return host_func.clone().call(FuncContext { store, module_addr: func.module_addr }, params);
19 }
20 FunctionInstance::Wasm(wasm_func) => wasm_func,
21 };
22
23 // Reset stack, push args, allocate locals, create entry frame.
24 store.call_stack.clear();
25 store.value_stack.clear();
26 store.value_stack.extend_from_wasmvalues(params)?;
27 let locals_base = store.value_stack.enter_locals(&wasm_func.func.params, &wasm_func.func.locals)?;
28 let callframe = CallFrame::new(func.addr, locals_base, wasm_func.func.locals);
29
30 // Execute until completion and then collect result values from the stack.
31 InterpreterRuntime::exec(store, callframe, 0)?;
32 collect_call_results(&mut store.value_stack, &func.ty)
33 }
34
35 self.item.validate_store(store)?;
36 validate_call_params(&self.ty, params)?;

Callers

nothing calls this directly

Calls 6

collect_call_resultsFunction · 0.85
get_funcMethod · 0.80
callMethod · 0.80
enter_localsMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected