KWasmProgram

KWasmProgram

class KWasmProgram

A WebAssembly program.

Consisting of one or more WasmModules loaded either via Strings or from Files/InputStreams, a KWasmProgram may expose to the caller any memory, functions, globals exported by the loaded modules. Additionally, the caller may provide HostFunctions to those modules to allow them to communicate with the external environment (e.g. i/o).

Fields

Name Description
val memory: Memory

Gets the KWasmProgram's shared/exported Memory.

Methods

getGlobalInt

fun getGlobalInt(moduleName: String, globalName: String): Int

Gets the current value of the i32-typed global called globalName exported from the module with name moduleName.

Parameters

Name Description
moduleName: String
globalName: String

ReturnValue

Name Description
Int

setGlobalInt

fun setGlobalInt(moduleName: String, globalName: String, newValue: Int)

Sets the current value of the i32-typed global called globalName exported from the module with name moduleName to the provided newValue.

Parameters

Name Description
moduleName: String
globalName: String
newValue: Int

ReturnValue

Name Description
Unit

getGlobalLong

fun getGlobalLong(moduleName: String, globalName: String): Long

Gets the current value of the i64-typed global called globalName exported from the module with name moduleName.

Parameters

Name Description
moduleName: String
globalName: String

ReturnValue

Name Description
Long

setGlobalLong

fun setGlobalLong(moduleName: String, globalName: String, newValue: Long)

Sets the current value of the i64-typed global called globalName exported from the module with name moduleName to the provided newValue.

Parameters

Name Description
moduleName: String
globalName: String
newValue: Long

ReturnValue

Name Description
Unit

getGlobalFloat

fun getGlobalFloat(moduleName: String, globalName: String): Float

Gets the current value of the f32-typed global called globalName exported from the module with name moduleName.

Parameters

Name Description
moduleName: String
globalName: String

ReturnValue

Name Description
Float

setGlobalFloat

fun setGlobalFloat(moduleName: String, globalName: String, newValue: Float)

Sets the current value of the f32-typed global called globalName exported from the module with name moduleName to the provided newValue.

Parameters

Name Description
moduleName: String
globalName: String
newValue: Float

ReturnValue

Name Description
Unit

getGlobalDouble

fun getGlobalDouble(moduleName: String, globalName: String): Double

Gets the current value of the f64-typed global called globalName exported from the module with name moduleName.

Parameters

Name Description
moduleName: String
globalName: String

ReturnValue

Name Description
Double

setGlobalDouble

fun setGlobalDouble(moduleName: String, globalName: String, newValue: Double)

Sets the current value of the f64-typed global called globalName exported from the module with name moduleName to the provided newValue.

Parameters

Name Description
moduleName: String
globalName: String
newValue: Double

ReturnValue

Name Description
Unit

getFunction

fun getFunction(moduleName: String, functionName: String): ExportedFunction

Gets an ExportedFunction by the given functionName in the moduleName-named module.

Parameters

Name Description
moduleName: String
functionName: String

ReturnValue

Name Description
ExportedFunction

CompanionObject

KWasmProgram

class KWasmProgram

A WebAssembly program.

Consisting of one or more WasmModules loaded either via Strings or from Files/InputStreams, a KWasmProgram may expose to the caller any memory, functions, globals exported by the loaded modules. Additionally, the caller may provide HostFunctions to those modules to allow them to communicate with the external environment (e.g. i/o).

Methods

builder

fun builder(memoryProvider: MemoryProvider): Builder

Parameters

Name Description
memoryProvider: MemoryProvider

ReturnValue

Name Description
Builder