MXVM 1.8.1
Virtual Machine, Compiler, and Pascal Frontend
Loading...
Searching...
No Matches
mxvm::Stack Class Reference

Runtime operand stack for the MXVM interpreter. More...

#include <icode.hpp>

Public Member Functions

 Stack ()=default
void push (const StackValue &value)
 Push a value onto the stack.
StackValue pop ()
 Pop and return the top value.
bool empty () const
 Check whether the stack is empty.
size_t size () const
 Return the number of elements on the stack.
StackValueoperator[] (size_t index)
 Random access into the stack.

Private Attributes

std::vector< StackValuedata

Detailed Description

Runtime operand stack for the MXVM interpreter.

Definition at line 23 of file icode.hpp.

Constructor & Destructor Documentation

◆ Stack()

mxvm::Stack::Stack ( )
default

Member Function Documentation

◆ empty()

bool mxvm::Stack::empty ( ) const
inlinenodiscard

Check whether the stack is empty.

Definition at line 47 of file icode.hpp.

References data.

◆ operator[]()

StackValue & mxvm::Stack::operator[] ( size_t index)
inline

Random access into the stack.

Parameters
indexZero-based index from the bottom
Returns
Reference to the stack element
Exceptions
mx::Exceptionif index is out of bounds

Definition at line 57 of file icode.hpp.

References data.

◆ pop()

StackValue mxvm::Stack::pop ( )
inlinenodiscard

Pop and return the top value.

Returns
The top stack value
Exceptions
mx::Exceptionon stack underflow

Definition at line 38 of file icode.hpp.

References data.

◆ push()

void mxvm::Stack::push ( const StackValue & value)
inline

Push a value onto the stack.

Parameters
valueInteger or pointer value to push

Definition at line 30 of file icode.hpp.

References data.

◆ size()

size_t mxvm::Stack::size ( ) const
inlinenodiscard

Return the number of elements on the stack.

Definition at line 50 of file icode.hpp.

References data.

Member Data Documentation

◆ data

std::vector<StackValue> mxvm::Stack::data
private

Definition at line 64 of file icode.hpp.

Referenced by empty(), operator[](), pop(), push(), and size().


The documentation for this class was generated from the following file: