UNPKG

@ethereumjs/evm

Version:
55 lines 2 kB
/** * Implementation of the stack used in evm. */ export declare class Stack { private _store; private _maxHeight; private _len; constructor(maxHeight?: number); get length(): number; /** * Pushes a new bigint onto the stack. * @param value - Value to push (must fit within the configured max height) */ push(value: bigint): void; /** * Pops the top value from the stack. * @returns The value removed from the stack */ pop(): bigint; /** * Pops multiple items from the stack with the top-most item returned first. * @param num - Number of items to pop (defaults to 1) * @returns Array containing the popped values */ popN(num?: number): bigint[]; /** * Returns items from the stack without removing them. * @param num - Number of items to return (defaults to 1) * @returns Array of items, with index 0 representing the top of the stack * @throws {@link EVMError} with code STACK_UNDERFLOW if there are not enough items on the stack */ peek(num?: number): bigint[]; /** * Swaps the top of the stack with another item. * @param position - Zero-based index from the top of the stack (0 swaps with the top itself) */ swap(position: number): void; /** * Pushes a copy of an item deeper in the stack. * @param position - One-based index of the item to duplicate */ dup(position: number): void; /** * Swaps two arbitrary entries relative to the top of the stack. * @param swap1 - Distance from the top (0 = top element) for the first entry * @param swap2 - Distance from the top for the second entry */ exchange(swap1: number, swap2: number): void; /** * Returns a copy of the current stack. This represents the actual state of the stack * (not the internal state of the stack, which might have unreachable elements in it) */ getStack(): bigint[]; } //# sourceMappingURL=stack.d.ts.map