Struct stark::sail::eval::EvalStack[][src]

pub struct EvalStack {
    stack_start: *mut usize,
    stack_max: *mut usize,
    stack_top: *mut usize,
    frame_start: *mut usize,
    pub null_loc: *mut usize,
}
Expand description

Sail evaluation stack

Fields

stack_start: *mut usize

First (bottom) element of the stack

stack_max: *mut usize

Maximum stack element address

stack_top: *mut usize

Current top of the stack (frame_start is more useful)

frame_start: *mut usize

Start of the stack’s top frame

null_loc: *mut usize

Location to write discarded return values

Implementations

impl EvalStack[src]

pub fn new(size: usize) -> Self[src]

Create and initialize a new Sail stack and associated memory

fn resize(&mut self, size: usize)[src]

Resize the stack, acquiring new memory if necessary

pub fn push(&mut self, word: *mut SlHead)[src]

Pushes a single word to the stack, which will always be a pointer to a Sail object

fn pop(&mut self)[src]

Pops a single word off the stack

pub fn push_frame_head(
    &mut self,
    ret: *mut *mut SlHead,
    opc: Opcode,
    env: *mut SlHead
)
[src]

Push a complete frame head onto the stack

Components:

  • ret: return address for this frame’s result
  • opc: opcode which dictates this frame’s format & behavior
  • env: environment containing bindings for this frame

fn pop_frame(&mut self)[src]

Pop a full frame off of the stack

pub fn start(
    &mut self,
    ret: *mut *mut SlHead,
    env: *mut SlHead,
    expr: *mut SlHead
) -> bool
[src]

Starts evaluating a Sail expression with an external return location

Returns false and does nothing if the stack is already in use

pub fn start_no_ret(&mut self, env: *mut SlHead, expr: *mut SlHead)[src]

Starts evaluating a Sail expression that will not return outside the stack

Works even when other expressions are evaluating on the stack

Warning:

  • Takes over the stack until the expression is finished
  • An error in this expression destroys the entire stack
  • This function is temporary and using it is a bad idea

fn unwind(&mut self, error: *mut SlHead)[src]

pub fn is_empty(&mut self) -> bool[src]

Determines whether the stack is currently empty

fn frame_ret(&mut self) -> *mut *mut SlHead[src]

Gets the return address of the current top frame

fn frame_opc(&mut self) -> Opcode[src]

Gets the opcode of the current top frame

fn frame_top(&mut self) -> (*mut *mut SlHead, *mut SlHead, Opcode)[src]

Returns all frame head components of the current top frame

fn frame_addr(&mut self, offset: usize) -> *mut *mut SlHead[src]

Returns the address of a location offset into the current top frame

fn frame_obj(&mut self, offset: usize) -> *mut SlHead[src]

Returns the pointer stored in a location offset into the current top frame

fn eval_expr(
    &mut self,
    ret: *mut *mut SlHead,
    env: *mut SlHead,
    expr: *mut SlHead
)
[src]

Evaluates any Sail expression in object form, using the given environment and returning to the given location

pub fn iter_once(&mut self, reg: *mut Region, tbl: *mut SlHead)[src]

Consumes one frame off the top of the stack and executes it

This is the core of Sail evaluation logic. In the absence of code with infinite loops, executing this function repeatedly will evaluate any Sail expression. It handles all defined opcodes and adds more frames to the stack as necessary, but never uses recursion.

Auto Trait Implementations

impl RefUnwindSafe for EvalStack

impl !Send for EvalStack

impl !Sync for EvalStack

impl Unpin for EvalStack

impl UnwindSafe for EvalStack

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.