# `EEVM.Interpreter.Stack`
[🔗](https://github.com/mw2000/eevm/blob/v0.1.0/lib/eevm/interpreter/stack.ex#L1)

The EVM stack — a LIFO data structure with a max depth of 1024.

# `t`

```elixir
@type t() :: %EEVM.Interpreter.Stack{
  elements: [non_neg_integer()],
  size: non_neg_integer()
}
```

# `depth`

```elixir
@spec depth(t()) :: non_neg_integer()
```

Returns the current stack depth.

# `max_depth`

```elixir
@spec max_depth() :: pos_integer()
```

Returns the maximum stack depth (1024).

# `new`

```elixir
@spec new() :: t()
```

Creates a new empty stack.

# `pop`

```elixir
@spec pop(t()) :: {:ok, non_neg_integer(), t()} | {:error, :stack_underflow}
```

Pops the top value from the stack.

Returns `{:ok, value, new_stack}` or `{:error, :stack_underflow}`.

# `push`

```elixir
@spec push(t(), non_neg_integer()) :: {:ok, t()} | {:error, :stack_overflow}
```

Pushes a value onto the stack.

Returns `{:ok, stack}` or `{:error, :stack_overflow}` if the stack is full.

EVM values are 256-bit unsigned integers. We enforce this with a bitmask.

# `to_list`

```elixir
@spec to_list(t()) :: [non_neg_integer()]
```

Converts the stack to a list (top element first) for inspection.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
