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:
Crypt Keeper
2022-06-01 19:01:43 +08:00
committed by GitHub
parent 7e5142f1a6
commit 92ba4929e5
77 changed files with 650 additions and 466 deletions

View File

@@ -7,9 +7,14 @@ import (
"log"
)
// addWasm was generated by the following:
// cd examples/basic/testdata/testdata; wat2wasm --debug-names add.wat
//go:embed examples/basic/testdata/add.wasm
var addWasm []byte
// This is an example of how to use WebAssembly via adding two numbers.
//
// See https://github.com/tetratelabs/wazero/tree/main/examples for more examples.
// See https://github.com/tetratelabs/wazero/tree/main/examples for more.
func Example() {
// Choose the context to use for function calls.
ctx := context.Background()
@@ -17,15 +22,9 @@ func Example() {
// Create a new WebAssembly Runtime.
r := NewRuntime()
// Add a module to the runtime named "wasm/math" which exports one function "add", implemented in WebAssembly.
mod, 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))
)`))
// Add a module to the runtime named "wasm/math" which exports one function
// "add", implemented in WebAssembly.
mod, err := r.InstantiateModuleFromBinary(ctx, addWasm)
if err != nil {
log.Panicln(err)
}