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
impl CodeBox
Sourcepub fn new(script: &str, stack: Stack, compatibility_mode: bool) -> CodeBox
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.
Sourcepub fn exe(&mut self, r: u8) -> (Option<String>, bool, f64)
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.
Sourcepub fn swim(&mut self) -> (Option<String>, bool, f64)
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 “;”.
Sourcepub fn pop(&mut self) -> f64
pub fn pop(&mut self) -> f64
pop removes the value on the end of the current stack and returns it.
Sourcepub fn stack_length(&mut self)
pub fn stack_length(&mut self)
stack_length implements “l” on the current stack.
Sourcepub fn reverse_stack(&mut self)
pub fn reverse_stack(&mut self)
reverse_stack implements “r” on the current stack.
Sourcepub fn extend_stack(&mut self)
pub fn extend_stack(&mut self)
extend_stack implements “:” on the current stack.
Sourcepub fn stack_swap_two(&mut self)
pub fn stack_swap_two(&mut self)
stack_swap_two implements “$” on the current stack.
Sourcepub fn stack_swap_three(&mut self)
pub fn stack_swap_three(&mut self)
stack_swap_three implements “@” on the current stack.
Sourcepub fn stack_shift_right(&mut self)
pub fn stack_shift_right(&mut self)
stack_shift_right implements “}” on the current stack.
Sourcepub fn stack_shift_left(&mut self)
pub fn stack_shift_left(&mut self)
stack_shift_left implements “{” on the current stack.
Sourcepub fn close_stack(&mut self)
pub fn close_stack(&mut self)
close_stack implements “]”.
Sourcepub fn string_stack(&self) -> String
pub fn string_stack(&self) -> String
string_stack returns a copy of the current stack as a string.