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
globaltypebe the global type to allocate andvalthe value to initialize the global with. - Let
mut tbe the structure of global typeglobaltype. - Let
abe the first free global address inS. - Let
globalinstbe the global instance{value val, mut mut}. - Append
globalinstto theglobalsofS. - 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
memtypebe the memory type to allocate. - Let
{min n, max m?}be the structure of memory typememtype. - Let
abe the first free memory address inS. - Let
meminstbe the memory instance{data (0x00)^(n⋅64Ki), max m?}that containsnpages of zeroed bytes. - Append
meminstto thememsofS. - 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
tabletypebe the table type to allocate. - Let
({min n, max m?} elemtype)be the structure of table typetabletype. - Let
abe the first free table address inS. - Let
tableinstbe the table instance{elem(ϵ)^n, max m?}withnempty elements. - Append
tableinstto thetablesofS. - 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: