嘿@all,我正在使用WebAssembly Studio并创建了一个空的 Rust 项目。
在我的 Rust 代码中,我返回“Hello World”字符串的指针和长度。编译工作正常,但我期望生成的 WASM 有一个返回两个 i32 的函数。但我发现一个函数接受一个 i32 并且没有返回任何内容。
为什么该函数没有签名 fn () -> (i32,i32) ?
我该如何从 WASM 模块中提取这两个值?(使用 Rust- wasmtime)
您可以在下面找到我正在讨论的代码片段。提前致谢!
#[no_mangle]
pub extern "C" fn say() -> (*const u8,i32) {
let pointcut = "Hello World";
(pointcut.as_ptr(),11)
}
Run Code Online (Sandbox Code Playgroud)
(module
(type $t0 (func (param i32)))
(func $say (export "say") (type $t0) (param $p0 i32)
get_local $p0
i32.const 11
i32.store offset=4
get_local $p0
i32.const 1024
i32.store)
(table $T0 1 1 anyfunc)
(memory $memory (export …Run Code Online (Sandbox Code Playgroud)