[][src]Struct passerine::vm::vm::VM

pub struct VM { /* fields omitted */ }

A VM executes bytecode lambda closures. (That's a mouthful - think bytecode + some context). VM initialization overhead is tiny, and each VM's state is self-contained, so more than one can be spawned if needed.

Implementations

impl VM[src]

pub fn init() -> VM[src]

Initialize a new VM. To run the VM, a lambda must be passed to it through run.

pub fn next(&mut self)[src]

Advances to the next instruction.

pub fn terminate(&mut self) -> Result<(), Trace>[src]

Jumps past the end of the block, causing the current lambda to return.

pub fn done(&mut self) -> Result<(), Trace>[src]

Advances IP, returns Ok. Used in Bytecode implementations.

pub fn peek_byte(&mut self) -> u8[src]

Returns the current instruction as a byte.

pub fn next_byte(&mut self) -> u8[src]

Advances IP and returns the current instruction as a byte.

pub fn next_number(&mut self) -> usize[src]

Builds the next number in the bytecode stream. See utils::number for more.

pub fn step(&mut self) -> Result<(), Trace>[src]

Dissasembles and interprets a single (potentially fallible) bytecode op. The op definitions follow in the next impl block. To see what each op does, check common::opcode::Opcode.

pub fn run(&mut self, closure: Closure) -> Result<(), Trace>[src]

Suspends the current lambda and runs a new one on the VM. Runs until either success, in which it restores the state of the previous lambda, Or failure, in which it returns the runtime error. In the future, fibers will allow for error handling - right now, error in Passerine are practically panics.

pub fn con(&mut self) -> Result<(), Trace>[src]

Load a constant and push it onto the stack.

pub fn capture(&mut self) -> Result<(), Trace>[src]

Moves the top value on the stack to the heap, replacing it with a reference to the heapified value.

NOTE: Behaviour is not stabilized yet.

pub fn save(&mut self) -> Result<(), Trace>[src]

Save the topmost value on the stack into a variable.

pub fn save_cap(&mut self) -> Result<(), Trace>[src]

Save the topmost value on the stack into a captured variable.

pub fn load(&mut self) -> Result<(), Trace>[src]

Push a copy of a variable's value onto the stack.

pub fn load_cap(&mut self) -> Result<(), Trace>[src]

Load a captured variable from the current closure.

pub fn del(&mut self) -> Result<(), Trace>[src]

Delete the top item of the stack.

pub fn print(&mut self) -> Result<(), Trace>[src]

pub fn call(&mut self) -> Result<(), Trace>[src]

Call a function on the top of the stack, passing the next value as an argument.

pub fn return_val(&mut self) -> Result<(), Trace>[src]

Return a value from a function. End the execution of the current lambda. Takes the number of locals on the stack Relpaces the last frame with the value on the top of the stack. Expects the stack to be a [..., Frame, Local 1, ..., Local N, Data]

pub fn closure(&mut self) -> Result<(), Trace>[src]

Trait Implementations

impl Debug for VM[src]

Auto Trait Implementations

impl !RefUnwindSafe for VM

impl !Send for VM

impl !Sync for VM

impl Unpin for VM

impl !UnwindSafe for VM

Blanket Implementations

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

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

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

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

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

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.

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.