pub struct Interpreter<State> {
pub state: State,
/* private fields */
}Expand description
The core interpreter object. Takes in a custom defined state that can be modified by built-ins.
Fields§
§state: StateCustom state for each application. Allows users to register built-ins that modify this state.
Implementations§
Source§impl<State> Interpreter<State>
impl<State> Interpreter<State>
Sourcepub fn reset_program(&mut self)
pub fn reset_program(&mut self)
Resets the program counter and clears the program and program debug locations but preserves RAM and stack.
Source§impl<State> Interpreter<State>
impl<State> Interpreter<State>
Source§impl<State> Interpreter<State>
impl<State> Interpreter<State>
Sourcepub fn new(state: State) -> Self
pub fn new(state: State) -> Self
Create a new interpreter. Pass in the initial custom state for the interpreter.
Sourcepub fn evaluate(&mut self, code: &str, path: Option<PathBuf>) -> Result<(), Err>
pub fn evaluate(&mut self, code: &str, path: Option<PathBuf>) -> Result<(), Err>
Evaluate a program.
Sourcepub fn pop_number(&mut self) -> Result<f32, Err>
pub fn pop_number(&mut self) -> Result<f32, Err>
Pop a number from the stack.
Sourcepub fn push_number(&mut self, number: f32)
pub fn push_number(&mut self, number: f32)
Push a number onto the stack.
Sourcepub fn push_address(&mut self, address: Address)
pub fn push_address(&mut self, address: Address)
Push an address onto the stack.
Sourcepub fn pop_address(&mut self) -> Result<Address, Err>
pub fn pop_address(&mut self) -> Result<Address, Err>
Pop an address from the stack.
Sourcepub fn push_string(&mut self, string: String)
pub fn push_string(&mut self, string: String)
Push a string onto the stack.
Sourcepub fn pop_string(&mut self) -> Result<String, Err>
pub fn pop_string(&mut self) -> Result<String, Err>
Pop a string from the stack.
Sourcepub fn start_repl(&mut self) -> Result<(), Err>
pub fn start_repl(&mut self) -> Result<(), Err>
Start a REPL.
Sourcepub fn register_builtin(
&mut self,
name: &str,
stack_modification: &str,
documentation: &str,
example: &str,
func: BuiltIn<State>,
)
pub fn register_builtin( &mut self, name: &str, stack_modification: &str, documentation: &str, example: &str, func: BuiltIn<State>, )
Register a built-in function to be used in the interpreter.
Sourcepub fn print_documentation(&self)
pub fn print_documentation(&self)
Print the documentation for all words.
Auto Trait Implementations§
impl<State> Freeze for Interpreter<State>where
State: Freeze,
impl<State> RefUnwindSafe for Interpreter<State>where
State: RefUnwindSafe,
impl<State> Send for Interpreter<State>where
State: Send,
impl<State> Sync for Interpreter<State>where
State: Sync,
impl<State> Unpin for Interpreter<State>where
State: Unpin,
impl<State> UnwindSafe for Interpreter<State>where
State: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more