Interface Memory

Interface for memory management functionality

interface Memory {
    collection: Collection<unknown>;
    config: Config<unknown>;
    heap: Heap<Uint8Array>;
    stack: Stack<unknown>;
    allocate(size: number): number;
    compare(address1: number, address2: number): boolean;
    copy(source: number, destination: number): void;
    free(address: number): void;
    move(source: number, destination: number): void;
    peek(): undefined | StackFrame<unknown>;
    pop(): undefined | StackFrame<unknown>;
    push(value: StackFrame<unknown>): void;
    read(address: number): undefined | Uint8Array;
    search(value: Uint8Array): number;
    write(address: number, value: Uint8Array): void;
}

Properties

collection: Collection<unknown>

Collection storage

config: Config<unknown>

Configuration storage

Heap storage

stack: Stack<unknown>

Stack storage

Methods

  • Allocate memory on the heap

    Parameters

    • size: number

      Size in bytes to allocate

    Returns number

  • Compare memory at two addresses

    Parameters

    • address1: number

      First address

    • address2: number

      Second address

    Returns boolean

  • Copy memory between addresses

    Parameters

    • source: number

      Source address

    • destination: number

      Destination address

    Returns void

  • Free memory from the heap

    Parameters

    • address: number

      Address to free

    Returns void

  • Move memory between addresses

    Parameters

    • source: number

      Source address

    • destination: number

      Destination address

    Returns void