pub struct Interpreter { /* private fields */ }Expand description
A Brainfuck interpreter that supports breakpoints.
Implementations§
Source§impl Interpreter
impl Interpreter
Sourcepub fn new(code: Vec<BrainfuckInstruction>) -> Self
pub fn new(code: Vec<BrainfuckInstruction>) -> Self
Creates a new Interpreter form some input program.
§Arguments
code- A sequence of BrainfuckInstructions to be interpreted.
Sourcepub fn set_breakpoint(&mut self, address: usize) -> Result<bool, String>
pub fn set_breakpoint(&mut self, address: usize) -> Result<bool, String>
Sets a breakpoint at the specified code address.
§Arguments
address- The code address to set a breakpoint at.
Sourcepub fn delete_breakpoint(&mut self, address: usize) -> bool
pub fn delete_breakpoint(&mut self, address: usize) -> bool
Removes a breakpoint at the specified code address.
§Arguments
address- The code address to delete a breakpoint from.
Sourcepub fn run(&mut self) -> StopReason
pub fn run(&mut self) -> StopReason
Runs the Interpreter until either a breakpoint is hit or until the program has run to completion.
Sourcepub fn get(&self, address: usize) -> Result<u8, String>
pub fn get(&self, address: usize) -> Result<u8, String>
Reads a value from the tape at the specified address.
§Arguments
address- The tape address to read.
Sourcepub fn set(&mut self, address: usize, value: u8) -> Result<u8, String>
pub fn set(&mut self, address: usize, value: u8) -> Result<u8, String>
Writes a value to the tape at the specified address.
§Arguments
address- The tape address to write to.value- The value to write.
Auto Trait Implementations§
impl Freeze for Interpreter
impl RefUnwindSafe for Interpreter
impl Send for Interpreter
impl Sync for Interpreter
impl Unpin for Interpreter
impl UnwindSafe for Interpreter
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