Class Memory
Represents a WebAssembly memory.
Inheritance
Inherited Members
Namespace: Wasmtime
Assembly: Wasmtime.Dotnet.dll
Syntax
public class Memory
Constructors
| Improve this Doc View SourceMemory(UInt32, UInt32)
Creates a new memory with the given minimum and maximum page counts.
Declaration
public Memory(uint minimum = 1U, uint maximum = 4294967295U)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | minimum | |
System.UInt32 | maximum |
Fields
| Improve this Doc View SourcePageSize
The size, in bytes, of a WebAssembly memory page.
Declaration
public const int PageSize = 65536
Field Value
Type | Description |
---|---|
System.Int32 |
Properties
| Improve this Doc View SourceMaximum
The minimum memory size (in WebAssembly page units).
Declaration
public uint Maximum { get; }
Property Value
Type | Description |
---|---|
System.UInt32 |
Minimum
The minimum memory size (in WebAssembly page units).
Declaration
public uint Minimum { get; }
Property Value
Type | Description |
---|---|
System.UInt32 |
Span
The span of the memory.
Declaration
public Span<byte> Span { get; }
Property Value
Type | Description |
---|---|
System.Span<System.Byte> |
Remarks
The span may become invalid if the memory grows.
This may happen if the memory is explicitly requested to grow or grows as a result of WebAssembly execution.
Therefore, the returned Span should not be stored.
Methods
| Improve this Doc View SourceReadByte(Int32)
Reads a byte from memory.
Declaration
public byte ReadByte(int address)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | address | The zero-based address to read from. |
Returns
Type | Description |
---|---|
System.Byte | Returns the byte read from memory. |
ReadDouble(Int32)
Reads a double from memory.
Declaration
public double ReadDouble(int address)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | address | The zero-based address to read from. |
Returns
Type | Description |
---|---|
System.Double | Returns the double read from memory. |
ReadInt16(Int32)
Reads a short from memory.
Declaration
public short ReadInt16(int address)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | address | The zero-based address to read from. |
Returns
Type | Description |
---|---|
System.Int16 | Returns the short read from memory. |
ReadInt32(Int32)
Reads an int from memory.
Declaration
public int ReadInt32(int address)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | address | The zero-based address to read from. |
Returns
Type | Description |
---|---|
System.Int32 | Returns the int read from memory. |
ReadInt64(Int32)
Reads a long from memory.
Declaration
public long ReadInt64(int address)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | address | The zero-based address to read from. |
Returns
Type | Description |
---|---|
System.Int64 | Returns the long read from memory. |
ReadIntPtr(Int32)
Reads an IntPtr from memory.
Declaration
public IntPtr ReadIntPtr(int address)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | address | The zero-based address to read from. |
Returns
Type | Description |
---|---|
System.IntPtr | Returns the IntPtr read from memory. |
ReadSingle(Int32)
Reads a long from memory.
Declaration
public float ReadSingle(int address)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | address | The zero-based address to read from. |
Returns
Type | Description |
---|---|
System.Single | Returns the long read from memory. |
ReadString(Int32, Int32)
Reads a UTF-8 string from memory.
Declaration
public string ReadString(int address, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | address | The zero-based address to read from. |
System.Int32 | length | The length of bytes to read. |
Returns
Type | Description |
---|---|
System.String | Returns the string read from memory. |
WriteByte(Int32, Byte)
Writes a byte to memory.
Declaration
public void WriteByte(int address, byte value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | address | The zero-based address to write to. |
System.Byte | value | The byte to write. |
WriteDouble(Int32, Double)
Writes a double to memory.
Declaration
public void WriteDouble(int address, double value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | address | The zero-based address to write to. |
System.Double | value | The double to write. |
WriteInt16(Int32, Int16)
Writes a short to memory.
Declaration
public void WriteInt16(int address, short value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | address | The zero-based address to write to. |
System.Int16 | value | The short to write. |
WriteInt32(Int32, Int32)
Writes an int to memory.
Declaration
public void WriteInt32(int address, int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | address | The zero-based address to write to. |
System.Int32 | value | The int to write. |
WriteInt64(Int32, Int64)
Writes a long to memory.
Declaration
public void WriteInt64(int address, long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | address | The zero-based address to write to. |
System.Int64 | value | The long to write. |
WriteIntPtr(Int32, IntPtr)
Writes an IntPtr to memory.
Declaration
public void WriteIntPtr(int address, IntPtr value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | address | The zero-based address to write to. |
System.IntPtr | value | The IntPtr to write. |
WriteSingle(Int32, Single)
Writes a single to memory.
Declaration
public void WriteSingle(int address, float value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | address | The zero-based address to write to. |
System.Single | value | The single to write. |
WriteString(Int32, String)
Writes a UTF-8 string at the given address.
Declaration
public int WriteString(int address, string value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | address | The zero-based address to write to. |
System.String | value | The string to write. |
Returns
Type | Description |
---|---|
System.Int32 |