MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime-go / Wat2Wasm

Function Wat2Wasm

wat2wasm.go:14–30  ·  view source on GitHub ↗

Wat2Wasm converts the text format of WebAssembly to the binary format. Takes the text format in-memory as input, and returns either the binary encoding of the text format or an error if parsing fails.

(wat string)

Source from the content-addressed store, hash-verified

12// Takes the text format in-memory as input, and returns either the binary
13// encoding of the text format or an error if parsing fails.
14func Wat2Wasm(wat string) ([]byte, error) {
15 retVec := C.wasm_byte_vec_t{}
16 err := C.wasmtime_wat2wasm(
17 C._GoStringPtr(wat),
18 C._GoStringLen(wat),
19 &retVec,
20 )
21 runtime.KeepAlive(wat)
22
23 if err == nil {
24 ret := C.GoBytes(unsafe.Pointer(retVec.data), C.int(retVec.size))
25 C.wasm_byte_vec_delete(&retVec)
26 return ret, nil
27 }
28
29 return nil, mkError(err)
30}

Callers 15

TestInstanceFunction · 0.85
TestInstanceBadFunction · 0.85
TestInstanceGetFuncFunction · 0.85
NewModuleFromFileFunction · 0.85
newComponentFunction · 0.85
refTypesInstanceFunction · 0.85
TestLinkerFunction · 0.85
TestLinkerTrapFunction · 0.85
TestLinkerModuleFunction · 0.85
TestLinkerFuncsFunction · 0.85

Calls 1

mkErrorFunction · 0.85

Tested by 15

TestInstanceFunction · 0.68
TestInstanceBadFunction · 0.68
TestInstanceGetFuncFunction · 0.68
newComponentFunction · 0.68
refTypesInstanceFunction · 0.68
TestLinkerFunction · 0.68
TestLinkerTrapFunction · 0.68
TestLinkerModuleFunction · 0.68
TestLinkerFuncsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…