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
impl MachineBuilder
Sourcepub fn actions(&self) -> Rc<RefCell<Vec<MachineAction>>>
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).
Sourcepub fn add_callable(&mut self, callable: Rc<dyn Callable>)
pub fn add_callable(&mut self, callable: Rc<dyn Callable>)
Registers the given builtin callable, which must not yet be registered.
Sourcepub fn callables_metadata(
&self,
) -> Rc<RefCell<HashMap<SymbolKey, Rc<CallableMetadata>>>>
pub fn callables_metadata( &self, ) -> Rc<RefCell<HashMap<SymbolKey, Rc<CallableMetadata>>>>
Returns metadata for all callables currently registered in the builder.
Sourcepub fn add_clearable(&mut self, clearable: Box<dyn Clearable>)
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.
Sourcepub fn with_console(self, console: Rc<RefCell<dyn Console>>) -> Self
pub fn with_console(self, console: Rc<RefCell<dyn Console>>) -> Self
Overrides the default terminal-based console with the given one.
Sourcepub fn with_globals(self, defs: Vec<GlobalDef>) -> Self
pub fn with_globals(self, defs: Vec<GlobalDef>) -> Self
Sets a global variable to an initial value.
Sourcepub fn with_gpio_pins(self, pins: Rc<RefCell<dyn Pins>>) -> Self
pub fn with_gpio_pins(self, pins: Rc<RefCell<dyn Pins>>) -> Self
Overrides the default hardware-based GPIO pins with the given ones.
Sourcepub fn with_sleep_fn(self, sleep_fn: SleepFn) -> Self
pub fn with_sleep_fn(self, sleep_fn: SleepFn) -> Self
Overrides the default sleep function with the given one.
Sourcepub fn with_yielder(self, yielder: Box<dyn Yielder>) -> Self
pub fn with_yielder(self, yielder: Box<dyn Yielder>) -> Self
Overrides the default yielder with the given one.
Sourcepub fn with_signals_chan(self, chan: (Sender<Signal>, Receiver<Signal>)) -> Self
pub fn with_signals_chan(self, chan: (Sender<Signal>, Receiver<Signal>)) -> Self
Overrides the default signals channel with the given one.
Sourcepub fn get_console(&mut self) -> Rc<RefCell<dyn Console>>
pub fn get_console(&mut self) -> Rc<RefCell<dyn Console>>
Lazily initializes the console field with a default value and returns it.
Sourcepub fn make_interactive(self) -> InteractiveMachineBuilder
pub fn make_interactive(self) -> InteractiveMachineBuilder
Extends the machine with interactive (REPL) features.