Struct Program

Source
pub struct Program<'env> { /* private fields */ }
Expand description

An instance of a Befunge-98 program.

This manages all data associated to the running program, like the addressable space, all currently active instruction pointers and program configuration.

Implementations§

Source§

impl<'env> Program<'env>

Source

pub fn new() -> Self

Creates a new empty Program.

Source

pub fn read(code: &str) -> Self

Initializes a Program with the given source code.

Source

pub fn config(self, config: Config<'env>) -> Self

Sets the Program’s Config.

Source

pub fn step_single(&mut self)

Executes the current instruction of a single instruction pointer.

The IP will execute a single ‘tick’ as defined by the Funge-98 specification and then advance its position up to the next command, skipping any intermediate spaces and areas delimited by semicolons and wrapping around to the other side of the program if it steps out of the program area.

Source

pub fn step_all(&mut self)

Executes the current instruction of every active instruction pointer.

Similarly to step_single, each IP will be advanced to its next command.

Source

pub fn run(&mut self) -> i32

Runs the program to completion.

Instructions will continuously be executed until the program encounters an error, all instruction pointers stop by encountering an @ instruction or the program is stopped with a q instruction.

Auto Trait Implementations§

§

impl<'env> Freeze for Program<'env>

§

impl<'env> !RefUnwindSafe for Program<'env>

§

impl<'env> !Send for Program<'env>

§

impl<'env> !Sync for Program<'env>

§

impl<'env> Unpin for Program<'env>

§

impl<'env> !UnwindSafe for Program<'env>

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.