Trait SubRoutineStack

pub trait SubRoutineStack {
    // Required methods
    fn len(&self) -> usize;
    fn routine_idx(&self) -> usize;
    fn set_routine_idx(&mut self, idx: usize);
    fn push(&mut self, old_program_counter: usize, new_idx: usize) -> bool;
    fn pop(&mut self) -> Option<usize>;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

Handles EOF introduced sub routine calls.

Required Methods§

fn len(&self) -> usize

Returns sub routine stack length.

fn routine_idx(&self) -> usize

Returns current sub routine index.

fn set_routine_idx(&mut self, idx: usize)

Sets new code section without touching subroutine stack.

This is used for bytecode::opcode::JUMPF opcode. Where tail call is performed.

fn push(&mut self, old_program_counter: usize, new_idx: usize) -> bool

Pushes a new frame to the stack and new code index.

fn pop(&mut self) -> Option<usize>

Pops previous subroutine, sets previous code index and returns program counter.

Provided Methods§

fn is_empty(&self) -> bool

Returns true if sub routine stack is empty.

Implementors§