Skip to main content

MachineBuilder

Struct MachineBuilder 

Source
pub struct MachineBuilder { /* private fields */ }
Expand description

Builder pattern to construct an EndBASIC interpreter.

Unless otherwise specified, the interpreter is connected to a terminal-based console.

Implementations§

Source§

impl MachineBuilder

Source

pub fn actions(&self) -> Rc<RefCell<Vec<MachineAction>>>

Returns a shared reference to the machine’s action queue.

This is used by callables that need to request machine-level side effects (such as CLEAR).

Source

pub fn add_callable(&mut self, callable: Rc<dyn Callable>)

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

Source

pub fn callables_metadata( &self, ) -> Rc<RefCell<HashMap<SymbolKey, Rc<CallableMetadata>>>>

Returns metadata for all callables currently registered in the builder.

Source

pub fn add_clearable(&mut self, clearable: Box<dyn Clearable>)

Registers the given clearable.

In the common case, functions and commands hold a reference to the out-of-machine state they interact with. This state is invisible from here, but we may need to have access to it to reset it as part of the clear operation. In those cases, such state must be registered via this hook.

Source

pub fn with_console(self, console: Rc<RefCell<dyn Console>>) -> Self

Overrides the default terminal-based console with the given one.

Source

pub fn with_globals(self, defs: Vec<GlobalDef>) -> Self

Sets a global variable to an initial value.

Source

pub fn with_gpio_pins(self, pins: Rc<RefCell<dyn Pins>>) -> Self

Overrides the default hardware-based GPIO pins with the given ones.

Source

pub fn with_sleep_fn(self, sleep_fn: SleepFn) -> Self

Overrides the default sleep function with the given one.

Source

pub fn with_yielder(self, yielder: Box<dyn Yielder>) -> Self

Overrides the default yielder with the given one.

Source

pub fn with_signals_chan(self, chan: (Sender<Signal>, Receiver<Signal>)) -> Self

Overrides the default signals channel with the given one.

Source

pub fn get_console(&mut self) -> Rc<RefCell<dyn Console>>

Lazily initializes the console field with a default value and returns it.

Source

pub fn build(self) -> Machine

Builds the interpreter.

Source

pub fn make_interactive(self) -> InteractiveMachineBuilder

Extends the machine with interactive (REPL) features.

Trait Implementations§

Source§

impl Default for MachineBuilder

Source§

fn default() -> MachineBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V