Store
data class Store
Fields
Name | Description |
---|---|
val functions: List<FunctionInstance>
|
|
val tables: List<Table>
|
|
val memories: List<Memory>
|
|
val globals: List<Global<*>>
|
Methods
allocateFunction
fun allocateFunction(function: FunctionInstance): Allocation<Function>
Allocates the provided FunctionInstance.
Parameters
Name | Description |
---|---|
function: FunctionInstance
|
ReturnValue
Name | Description |
---|---|
Allocation<Function>
|
allocateTable
fun allocateTable(table: Table): Allocation<Table>
Allocates the provided Table.
Parameters
Name | Description |
---|---|
table: Table
|
ReturnValue
Name | Description |
---|---|
Allocation<Table>
|
allocateMemory
fun allocateMemory(memory: Memory): Allocation<Memory>
Allocates the provided Memory.
Parameters
Name | Description |
---|---|
memory: Memory
|
ReturnValue
Name | Description |
---|---|
Allocation<Memory>
|
allocateGlobal
fun allocateGlobal(global: Global<*>): Allocation<Global>
Allocates the provided Global.
Parameters
Name | Description |
---|---|
global: Global<*>
|
ReturnValue
Name | Description |
---|---|
Allocation<Global>
|
Extensions
allocate
fun <T : Number> Store.allocate(globalType: GlobalType, value: T): Allocation<Global>
From the docs:
- Let
globaltype
be the global type to allocate andval
the value to initialize the global with. - Let
mut t
be the structure of global typeglobaltype
. - Let
a
be the first free global address inS
. - Let
globalinst
be the global instance{value val, mut mut}
. - Append
globalinst
to theglobals
ofS
. - Return
a
.
Receiver
Name | Description |
---|---|
Store
|
Parameters
Name | Description |
---|---|
globalType: GlobalType
|
|
value: T
|
ReturnValue
Name | Description |
---|---|
Allocation<Global>
|
allocate
fun Store.allocate(memoryProvider: MemoryProvider, memoryType: MemoryType): Allocation<Memory>
From the docs:
- Let
memtype
be the memory type to allocate. - Let
{min n, max m?}
be the structure of memory typememtype
. - Let
a
be the first free memory address inS
. - Let
meminst
be the memory instance{data (0x00)^(n⋅64Ki), max m?}
that containsn
pages of zeroed bytes. - Append
meminst
to themems
ofS
. - Return
a
.
Receiver
Name | Description |
---|---|
Store
|
Parameters
Name | Description |
---|---|
memoryProvider: MemoryProvider
|
|
memoryType: MemoryType
|
ReturnValue
Name | Description |
---|---|
Allocation<Memory>
|
allocate
fun Store.allocate(tableType: TableType): Allocation<Table>
From the docs:
- Let
tabletype
be the table type to allocate. - Let
({min n, max m?} elemtype)
be the structure of table typetabletype
. - Let
a
be the first free table address inS
. - Let
tableinst
be the table instance{elem(ϵ)^n, max m?}
withn
empty elements. - Append
tableinst
to thetables
ofS
. - Return
a
.
Receiver
Name | Description |
---|---|
Store
|
Parameters
Name | Description |
---|---|
tableType: TableType
|
ReturnValue
Name | Description |
---|---|
Allocation<Table>
|
From the docs:
The store represents all global state that can be manipulated by WebAssembly programs. It consists of the runtime representation of all instances of functions, tables, memories, and globals that have been allocated during the life time of the abstract machine.
Syntactically, the store is defined as a record listing the existing instances of each category: