[][src]Struct sbrain::SBrainVM

pub struct SBrainVM<'a> { /* fields omitted */ }

A virtual machine modelling the SBrain Turing machine. This machine implements the specification relatively strictly, providing exactly 2^16 (65536) data and instruction cells. Thus, all pointers are 16 bits and all data is 8 bits. The main deviation from the minimum specification is the jump stack, which is indefinitely expandable.

Methods

impl<'a> SBrainVM<'a>[src]

pub fn new(
    input: Option<&'a mut dyn Read>,
    output: Option<&'a mut dyn Write>,
    program: &[u8]
) -> Result<SBrainVM<'a>, String>
[src]

Return a new SBrainVM, with no data in any tapes. If given a None input, all reads read 0. If given a None output, all writes are discarded.

pub fn load_program(&mut self, program: &[u8]) -> Result<(), String>[src]

Load a program tape: copy data from the given slice into the executable tape, starting at address zero. On error, the Err(s) return will contain a message describing the error.

pub fn run(&mut self, cycles: Option<u32>) -> Result<(u32, Option<u8>)>[src]

Run the machine, until completion (cycles = None) or for n cycles (cycles = Some(n)). Return values are number of cycles run and the return code, or None if the code simply ran out of cycles.

Auto Trait Implementations

impl<'a> !Send for SBrainVM<'a>

impl<'a> !Sync for SBrainVM<'a>

impl<'a> Unpin for SBrainVM<'a>

impl<'a> !UnwindSafe for SBrainVM<'a>

impl<'a> !RefUnwindSafe for SBrainVM<'a>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for 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.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]