Struct endbasic_core::exec::Machine[][src]

pub struct Machine { /* fields omitted */ }

Executes an EndBASIC program and tracks its state.

Implementations

impl Machine[src]

pub fn add_command(&mut self, command: Rc<dyn Command>)[src]

Registers the given builtin command, which must not yet be registered.

pub fn add_function(&mut self, function: Rc<dyn Function>)[src]

Registers the given builtin function, which must not yet be registered.

pub fn clear(&mut self)[src]

Resets the state of the machine by clearing all variable.

pub fn exit(&mut self, code: u8)[src]

Tells the machine to stop execution at the next statement boundary.

The exec() call that's stopped by this invocation will return the code given to this call.

pub fn get_symbols(&self) -> &Symbols[src]

Obtains immutable access to the state of the symbols.

pub fn get_mut_symbols(&mut self) -> &mut Symbols[src]

Obtains mutable access to the state of the symbols.

pub fn get_var_as_bool(&self, name: &str) -> Result<bool>[src]

Retrieves the variable name as a boolean. Fails if it is some other type or if it's not defined.

pub fn get_var_as_int(&self, name: &str) -> Result<i32>[src]

Retrieves the variable name as an integer. Fails if it is some other type or if it's not defined.

pub fn get_var_as_string(&self, name: &str) -> Result<&str>[src]

Retrieves the variable name as a string. Fails if it is some other type or if it's not defined.

pub fn dim_array(
    &mut self,
    name: &str,
    subtype: &VarType,
    dimensions: &[Expr]
) -> Result<()>
[src]

Defines a new array name of type subtype with dimensions. The array must not yet exist, and the name may not overlap function or variable names.

pub async fn exec(&mut self, input: &mut dyn Read) -> Result<StopReason>[src]

Executes a program extracted from the input readable.

Note that this does not consume self. As a result, it is possible to execute multiple different programs on the same machine, all sharing state.

Trait Implementations

impl Default for Machine[src]

Auto Trait Implementations

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.