FunctionInstance
        sealed class FunctionInstance
      
Fields
| Name | Description | 
|---|---|
| open type: FunctionType | 
CompanionObject
FunctionInstance
        sealed class FunctionInstance
      
Represents either a WasmFunction from a ModuleInstance, or a HostFunction exposed to the ModuleInstance via imports.
From the docs:
A function instance is the runtime representation of a function. It effectively is a closure of the original function over the runtime module instance of its originating module. The module instance is used to resolve references to other definitions during execution of the function.
funcinst   ::= {type functype, module moduleinst, code func}
{type functype, hostcode hostfunc}
hostfunc ::= ...
A host function is a function expressed outside WebAssembly but passed to a module as an import.
Methods
allocate
        fun Store.allocate(moduleInstance: ModuleInstance, wasmFunction: WasmFunction): Allocation<Function>
      
From the docs:
- Let funcbe the function to allocate andmoduleinstits module instance.
- Let abe the first free function address inS.
- Let functypebe the function typemoduleinst.types[func.type].
- Let funcinstbe the function instance{type functype, module moduleinst, code func}.
- Append funcinstto thefuncsofS.
- Return a.
Receiver
| Name | Description | 
|---|---|
| Store | 
Parameters
| Name | Description | 
|---|---|
| moduleInstance: ModuleInstance | |
| wasmFunction: WasmFunction | 
ReturnValue
| Name | Description | 
|---|---|
| Allocation<Function> | 
allocate
        fun Store.allocate(hostFunction: HostFunction<*>): Allocation<Function>
      
From the * docs:
- Let hostfuncbe the host function to allocate andfunctypeits function type.
- Let abe the first free function address inS.
- Let funcinstbe the function instance{type functype, hostcode hostfunc}.
- Append funcinstto thefuncsofS.
- Return a.
Receiver
| Name | Description | 
|---|---|
| Store | 
Parameters
| Name | Description | 
|---|---|
| hostFunction: HostFunction<*> | 
ReturnValue
| Name | Description | 
|---|---|
| Allocation<Function> | 
Represents either a WasmFunction from a ModuleInstance, or a HostFunction exposed to the ModuleInstance via imports.
From the docs:
A function instance is the runtime representation of a function. It effectively is a closure of the original function over the runtime module instance of its originating module. The module instance is used to resolve references to other definitions during execution of the function.
A host function is a function expressed outside WebAssembly but passed to a module as an import.