wasmtime_internal_debugger/host/
bindings.rs1use wasmtime::{Result, ValType};
4
5wasmtime::component::bindgen!({
6 path: "wit",
7 world: "bytecodealliance:wasmtime/debug-main",
8 imports: {
9 default: async | trappable
14 },
15 exports: {
16 default: async,
17 },
18 with: {
19 "bytecodealliance:wasmtime/debuggee.debuggee": super::api::Debuggee,
20 "bytecodealliance:wasmtime/debuggee.event-future": super::api::EventFuture,
21 "bytecodealliance:wasmtime/debuggee.frame": super::api::Frame,
22 "bytecodealliance:wasmtime/debuggee.instance": wasmtime::Instance,
23 "bytecodealliance:wasmtime/debuggee.module": wasmtime::Module,
24 "bytecodealliance:wasmtime/debuggee.table": wasmtime::Table,
25 "bytecodealliance:wasmtime/debuggee.global": wasmtime::Global,
26 "bytecodealliance:wasmtime/debuggee.memory": wasmtime::Memory,
27 "bytecodealliance:wasmtime/debuggee.wasm-tag": wasmtime::Tag,
28 "bytecodealliance:wasmtime/debuggee.wasm-func": wasmtime::Func,
29 "bytecodealliance:wasmtime/debuggee.wasm-exception": super::api::WasmException,
30 "bytecodealliance:wasmtime/debuggee.wasm-value": super::api::WasmValue,
31
32 "wasi": wasmtime_wasi::p2::bindings,
33 },
34 trappable_error_type: {
35 "bytecodealliance:wasmtime/debuggee.error" => wasmtime::Error,
36 },
37 require_store_data_send: true,
38});
39
40use bytecodealliance::wasmtime::debuggee as wit;
41
42pub(crate) fn val_type_to_wasm_type(vt: &ValType) -> Result<wit::WasmType> {
43 match vt {
44 ValType::I32 => Ok(wit::WasmType::WasmI32),
45 ValType::I64 => Ok(wit::WasmType::WasmI64),
46 ValType::F32 => Ok(wit::WasmType::WasmF32),
47 ValType::F64 => Ok(wit::WasmType::WasmF64),
48 ValType::V128 => Ok(wit::WasmType::WasmV128),
49 ValType::Ref(rt) if rt.heap_type().is_exn() => Ok(wit::WasmType::WasmExnref),
50 ValType::Ref(rt) if rt.heap_type().is_func() => Ok(wit::WasmType::WasmFuncref),
51 ValType::Ref(_) => Err(wit::Error::UnsupportedType.into()),
52 }
53}
54
55pub(crate) fn wasm_type_to_val_type(wt: wit::WasmType) -> ValType {
56 match wt {
57 wit::WasmType::WasmI32 => ValType::I32,
58 wit::WasmType::WasmI64 => ValType::I64,
59 wit::WasmType::WasmF32 => ValType::F32,
60 wit::WasmType::WasmF64 => ValType::F64,
61 wit::WasmType::WasmV128 => ValType::V128,
62 wit::WasmType::WasmFuncref => ValType::FUNCREF,
63 wit::WasmType::WasmExnref => ValType::EXNREF,
64 }
65}