Closed RoyalIcing closed 3 months ago
Add Wasmex.Instance.get_global_value/3 and Wasmex.Instance.set_global_value/4 to read and write globals.
Wasmex.Instance.get_global_value/3
Wasmex.Instance.set_global_value/4
I don’t believe languages like Rust or C allow exporting globals, but in raw WebAssembly this is very much possible:
(module (global (export "meaning_of_life") i32 (i32.const 42)) (global (export "count") (mut i64) (i64.const 0)) )
I’ve followed what appears to be the convention of returning string errors. If you like I can make them atoms like {:error, :not_found} or {:error, :immutable}.
{:error, :not_found}
{:error, :immutable}
Add
Wasmex.Instance.get_global_value/3
andWasmex.Instance.set_global_value/4
to read and write globals.I don’t believe languages like Rust or C allow exporting globals, but in raw WebAssembly this is very much possible:
I’ve followed what appears to be the convention of returning string errors. If you like I can make them atoms like
{:error, :not_found}
or{:error, :immutable}
.