GraalvmWasiPreview1Builder

WASI Preview 1 host function installer.

Sets up WebAssembly WASI Preview 1 WebAssembly module in GraalWASM Context.

Usage example:

val source = Source.newBuilder("wasm", ByteSequence.create(wasmFile), "proc").build()
Context.newBuilder().engine(engine).build().use { context ->
context.initialize("wasm")
GraalvmWasiPreview1Builder {
host = embedderHost // setup host
}.build(context)
context.eval(source)

val startFunc = context.getBindings("wasm").getMember("proc").getMember("_start")
startFunc.execute()
try {
startFunction.execute()
} catch (re: PolyglotException) {
if (re.message?.startsWith("Program exited with status code") == false) {
throw re
}
Unit
}
}

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Implementation of a host object that provides access from the WebAssembly to external host resources.

Link copied to clipboard

Memory source used for all operations.

Functions

Link copied to clipboard
fun build(wasmContext: Context, moduleName: String = WASI_SNAPSHOT_PREVIEW1_MODULE_NAME)
Link copied to clipboard

Sets implementation of a host object that provides access from the WebAssembly to external host resources.

Link copied to clipboard

Sets memory source used for all operations.