[][src]Struct dark_vm::vm::VM

pub struct VM {
    pub operand_stack: Stack<Rc<Value>>,
    // some fields omitted
}

Fields

operand_stack: Stack<Rc<Value>>

Implementations

impl VM[src]

pub fn new(tokens: VecDeque<Token>) -> Result<VM, Error>[src]

Constructs a new VM with the specified tokens. The tokens are usually generated through the lexer. Internally, the tokens are converted to different values by the code object.

Arguments

tokens - The tokens produced by the lexer.

pub fn repl() -> Result<VM, Error>[src]

Creates a VM in REPL mode.

pub fn load_tokens(&mut self, tokens: VecDeque<Token>) -> Result<(), Error>[src]

Loads the given tokens into the VM. This function does not change the operand stack or the call stack. This function can be used with the REPL mode to help facilitate a proper REPL experience.

Arguments

tokens - The tokens to load.

pub fn run(&mut self) -> Result<Option<Rc<Value>>, Error>[src]

Runs the VM until the end of the code. This function may return an optionally value, representing the value of the last expression. It may also prematurely return an error. This may be updated to return a vector of errors.

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.