wasmer-go
wasmer-go copied to clipboard
Error executing?
Describe the bug
The wat file:
(module
(func (result i64)
v128.const i64x2 -1 1
global.get 0
f64x2.replace_lane 0
i64x2.extract_lane 1
)
(global f64 (f64.const 1))
(export "func1" (func 0)))
The go file:
package main
import (
"fmt"
"github.com/wasmerio/wasmer-go/wasmer"
"io/ioutil"
)
func main() {
wasmBytes, _ := ioutil.ReadFile("./tmp.wasm")
engine := wasmer.NewEngine()
store := wasmer.NewStore(engine)
// Compiles the module
module, err := wasmer.NewModule(store, wasmBytes)
if err != nil {
fmt.Println("Failed to compile module:", err)
}
// Instantiates the module
importObject := wasmer.NewImportObject()
instance, err := wasmer.NewInstance(module, importObject)
if err != nil {
panic(fmt.Sprintln("Failed to instantiate the module:", err))
}
func1, err := instance.Exports.GetFunction("func1")
if err != nil {
panic(fmt.Sprintln("Failed to get the `func1` function:", err))
}
result, err := func1()
if err != nil {
panic(fmt.Sprintln("Failed to call the `func1` function:", err))
}
fmt.Println(result)
}
Steps to reproduce
wat2wasm tmp.wat
go run tmp.go
Expected behavior
Print:1
Actual behavior
Print:0 Environment: macOS or ubuntu 20.04