Class Instance
Instances represents all the state associated with a module. These are created by calling Module.Instantiate or by calling the Instance constructor.
Namespace: WasmerSharp
Assembly: WasmerSharp.dll
Syntax
public class Instance : WasmerSharp.WasmerNativeHandle
Remarks
At runtime, a module can be instantiated with a set of import values to produce an instance, which is an immutable tuple referencing all the state accessible to the running module. Multiple module instances can access the same shared state which is the basis for dynamic linking in WebAssembly.
Constructors
Instance(Byte[], Import[])
Creates a new Instance from the given wasm bytes and imports.
Declaration
public Instance (byte[] wasm, WasmerSharp.Import[] imports);
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | wasm | Wasm byte code |
Import[] | imports | The list of imports to pass, usually Function, Global and Memory |
Properties
Exports
Returns an array with all the exports - the individual values must be manually disposed.
Declaration
public WasmerSharp.Export[] Exports { get; }
Property Value
Type | Description |
---|---|
Export[] | To be added. |
Methods
Call(String, Object[])
Calls the specified function with the provided arguments
Declaration
public object[] Call (string functionName, object[] args);
Parameters
Type | Name | Description |
---|---|---|
System.String | functionName | Namer of the exported function to call in the instane |
System.Object[] | args | The argument types are limited to int, long, float and double. |
Returns
Type | Description |
---|---|
System.Object[] | An array of values on success, null on error. You can use the LastError error property to get details on the error. |
Call(String, WasmerValue[], WasmerValue[])
Calls the specified function with the provided arguments
Declaration
public bool Call (string functionName, WasmerSharp.WasmerValue[] parameters, WasmerSharp.WasmerValue[] results);
Parameters
Type | Name | Description |
---|---|---|
System.String | functionName | Namer of the exported function to call in the instane |
WasmerValue[] | parameters | The parameters to pass to the function |
WasmerValue[] | results | The array where the return values are returned |
Returns
Type | Description |
---|---|
System.Boolean | True on success, false on failure |
SetData(Object)
Sets a global data field that can be accessed by all imported functions and retrieved by the InstanceContext.Data property.
Declaration
public void SetData (object value);
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The value to pass to all the InstanceContext members |