Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error executing? #385

Open
orangeC23 opened this issue Apr 11, 2023 · 0 comments
Open

Error executing? #385

orangeC23 opened this issue Apr 11, 2023 · 0 comments
Labels
🐞 bug Something isn't working

Comments

@orangeC23
Copy link

orangeC23 commented Apr 11, 2023

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

@orangeC23 orangeC23 added the 🐞 bug Something isn't working label Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant