提交 3151bc33 编写于 作者: chai2010's avatar chai2010

wat2wasm 增加锁保护; 例子增加全局变量

上级 1923e748
......@@ -11,8 +11,10 @@ import (
func ExampleRunCode() {
const code = `
var gBase: i32 = 1000
fn main() {
println(add(40, 2))
println(add(40, 2) + gBase)
}
fn add(a: i32, b: i32) => i32 {
......@@ -28,5 +30,5 @@ func ExampleRunCode() {
fmt.Print(string(output))
// Output:
// 42
// 1042
}
......@@ -11,6 +11,7 @@ import (
"path/filepath"
"runtime"
"strings"
"sync"
"github.com/tetratelabs/wazero"
"github.com/tetratelabs/wazero/api"
......@@ -97,7 +98,12 @@ func InstallWat2wasm(path string) error {
return nil
}
var muRunWat2Wasm sync.Mutex
func RunWat2Wasm(args ...string) (stdoutStderr []byte, err error) {
muRunWat2Wasm.Lock()
defer muRunWat2Wasm.Unlock()
if wat2wasmPath == "" {
logger.Tracef(&config.EnableTrace_app, "wat2wasm not found")
return nil, errors.New("wat2wasm not found")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册