CodeBox

Struct CodeBox 

Source
pub struct CodeBox { /* private fields */ }
Expand description

CodeBox is an object. It contains a *><> program complete with a stack, and is typically run in steps via CodeBox.Swim.

Implementations§

Source§

impl CodeBox

Source

pub fn new(script: &str, stack: Stack, compatibility_mode: bool) -> CodeBox

new returns a new CodeBox. “script” should be a complete *><> script, “stack” should be the initial stack, and compatibility_mode should be set if old fishinterpreter.com behaviour is needed.

Source

pub fn shift(&mut self)

shift changes the fish’s x/y coordinates based on CodeBox.f_dir.

Source

pub fn exe(&mut self, r: u8) -> (Option<String>, bool, f64)

exe executes the instruction the ><> is currently on top of. It returns the string it intends to output (None if none) and true when it executes “;”. It also returns the time it should sleep for.

Source

pub fn swim(&mut self) -> (Option<String>, bool, f64)

swim causes the ><> to execute an instruction, then move. It returns a string of non-zero length when it has output and true when it encounters “;”.

Source

pub fn push(&mut self, r: f64)

push appends r to the end of the current stack.

Source

pub fn pop(&mut self) -> f64

pop removes the value on the end of the current stack and returns it.

Source

pub fn stack_length(&mut self)

stack_length implements “l” on the current stack.

Source

pub fn register(&mut self)

register implements “&” on the current stack.

Source

pub fn reverse_stack(&mut self)

reverse_stack implements “r” on the current stack.

Source

pub fn extend_stack(&mut self)

extend_stack implements “:” on the current stack.

Source

pub fn stack_swap_two(&mut self)

stack_swap_two implements “$” on the current stack.

Source

pub fn stack_swap_three(&mut self)

stack_swap_three implements “@” on the current stack.

Source

pub fn stack_shift_right(&mut self)

stack_shift_right implements “}” on the current stack.

Source

pub fn stack_shift_left(&mut self)

stack_shift_left implements “{” on the current stack.

Source

pub fn close_stack(&mut self)

close_stack implements “]”.

Source

pub fn new_stack(&mut self, n: usize)

new_stack implements “[”.

Source

pub fn call(&mut self)

call implements “C”.

Source

pub fn ret(&mut self)

ret implements “R”.

Source

pub fn print(&self, clear: bool)

print outputs the codebox to stdout.

Source

pub fn string_stack(&self) -> String

string_stack returns a copy of the current stack as a string.

Source

pub fn size(&self) -> (usize, usize)

size returns the width and height of the codebox.

Source

pub fn code_box(&self) -> Vec<Vec<u8>>

code_box outputs a copy of the current state of the codebox.

Source

pub fn deep_sea(&self) -> bool

deep_sea returns if the ><> is in deepsea mode or not.

Source

pub fn position(&self) -> (usize, usize)

position returns the x/y coordinates of the ><>.

Auto Trait Implementations§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V