Drops support for the WebAssembly text format (#614)
This drops the text format (%.wat) and renames InstantiateModuleFromCode to InstantiateModuleFromBinary as it is no longer ambiguous. We decided to stop supporting the text format as it isn't typically used in production, yet costs a lot of work to develop. Given the resources available and the increased work added with WebAssembly 2.0 and soon WASI 2, we can't afford to spend the time on it. The old parser is used only internally and will eventually be moved to its own repository named watzero, possibly towards archival. See #59 Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
@@ -12,6 +12,11 @@ import (
|
||||
"github.com/tetratelabs/wazero/api"
|
||||
)
|
||||
|
||||
// addWasm was generated by the following:
|
||||
// cd testdata; wat2wasm --debug-names add.wat
|
||||
//go:embed testdata/add.wasm
|
||||
var addWasm []byte
|
||||
|
||||
// main implements a basic function in both Go and WebAssembly.
|
||||
func main() {
|
||||
// Choose the context to use for function calls.
|
||||
@@ -22,14 +27,7 @@ func main() {
|
||||
defer r.Close(ctx) // This closes everything this Runtime created.
|
||||
|
||||
// Add a module to the runtime named "wasm/math" which exports one function "add", implemented in WebAssembly.
|
||||
wasm, err := r.InstantiateModuleFromCode(ctx, []byte(`(module $wasm/math
|
||||
(func $add (param i32 i32) (result i32)
|
||||
local.get 0
|
||||
local.get 1
|
||||
i32.add
|
||||
)
|
||||
(export "add" (func $add))
|
||||
)`))
|
||||
wasm, err := r.InstantiateModuleFromBinary(ctx, addWasm)
|
||||
if err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user