Class Stack<E>

Represents the EVM stack of expressions E. The stack is a list of expressions E elements used to store smart contract instruction inputs and outputs. E represents the type of the symbolic elements in the stack.

There is one stack created per call context, and it is destroyed when the call context ends. When a new value is put on the stack, it is put on top, and only the top values are used by the instructions. The stack currently has a maximum limit of 1024 values. All instructions interact with the stack, but it can be directly manipulated with instructions like PUSH1, POP, DUP1, or SWAP1.^1

Type Parameters

  • in out E

Hierarchy

  • Stack

Constructors

Properties

Accessors

Methods

Constructors

  • Type Parameters

    • in out E

    Returns Stack<E>

Properties

values: E[] = []

Accessors

  • get top(): undefined | E
  • Returns the element at the top of the stack without removing it.

    Returns undefined | E

Methods

  • Creates a shallow copy of this Stack.

    Returns Stack<E>

    a new Stack with the same elements as this one.

  • Removes the top element from the stack and returns it.

    Returns E

    the top element of the stack.

    Throws

    Error when the stack is empty.

  • Inserts the element elem at the top of the stack.

    Parameters

    • elem: E

      the element to be inserted.

    Returns void

    Throws

    Error when the stack reaches its maximum capacity of 1024 elements.

  • Swaps the element at position with the top element of the stack.

    Parameters

    • secondPosition: number

      the position of the element to be swapped.

    Returns void

    Throws

    Error when secondPosition is not in the range [1, 16) or the element at secondPosition does not exist in this Stack.

Generated using TypeDoc v0.25.2