Skip to main content

Tools

Endive publishes a few WebAssembly tools as Maven artifacts, compiled to Wasm and run with Endive itself.

WebAssembly Binary Toolkit​

A few wabt tools, the ones Endive's own build uses:

<dependency>
<groupId>run.endive</groupId>
<artifactId>wabt</artifactId>
<version>${endive.version}</version>
</dependency>

Wasm Tools​

A few wasm-tools binaries, which track the latest Wasm proposals:

<dependency>
<groupId>run.endive</groupId>
<artifactId>wasm-tools</artifactId>
<version>${endive.version}</version>
</dependency>

wat2wasm​

Endive does not parse the Wasm text format. Use wat2wasm to convert text to binary:

import run.endive.wabt.Wat2Wasm;
// or
import run.endive.tools.wasm.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);