WebAssembly Binary Toolkit
Since we use them in the build of the project, we publish a few wabt tools AOT compiled with Chicory. Adding support for more tools is easy and we welcome contributions in this direction. The relevant module can be added to the build with:
<dependency>
<groupId>com.dylibso.chicory</groupId>
<artifactId>wabt</artifactId>
<version>latest-release</version>
</dependency>
wat2wasm
In Chicory, we don't have a Wasm text format parser just yet.
To overcome this limitation you can use wat2wasm
, for example:
import com.dylibso.chicory.wabt.Wat2Wasm;
var wasm = Wat2Wasm.parse(
"(module (func (export \"add\") (param $x i32) (param $y i32) (result i32)"
+ " (i32.add (local.get $x) (local.get $y))))");
var moduleInstance = Instance.builder(Parser.parse(wasm)).build();
var addFunction = moduleInstance.export("add");
var result = addFunction.apply(1, 41)[0];
System.out.println(result);