| Stability | stable |
|---|---|
| Safe Haskell | None |
| Language | Haskell2010 |
VM.VMStack
Description
This module provides the core abstractions to interact with the VM's operand stack.
It abstracts the underlying Vector implementation and handles underflow safety checks.
Synopsis
Documentation
stackPush :: VMValue -> VirtualMachine () Source #
stackPop :: VirtualMachine VMValue Source #
Removes and returns the value at the top of the stack.
@details
Retrieves the last element of the vStack vector and removes it from the state.
Uses 'case' instead of 'if' to avoid DoAndIfThenElse extension.
@throws Error "VM Error: Stack Underflow" if the stack is empty.
@return
The VMValue that was at the top.
stackTop :: VirtualMachine VMValue Source #
Returns the value at the top of the stack without removing it (Peek).
@details Useful for instructions like DUP or conditional jumps that need to inspect the value without consuming it.
@throws Error "VM Error: Stack Underflow (Top)" if the stack is empty.
@return
The VMValue currently at the top.