Struct brain::Instructions
[−]
[src]
pub struct Instructions(_);
Methods
impl Instructions
[src]
fn from_program(program: Program) -> Result<Self, Error>
Generate instructions from the given program syntax tree
fn optimize(&mut self, level: OptimizationLevel)
Optimize the instructions based on the given optimization level
fn len(&self) -> usize
The number of instructions in this instructions set
fn move_relative(&mut self, from: usize, to: usize)
Add instructions that move from a given offset to the other offset using the fewest instructions possible
fn move_right(&mut self)
Add an instruction to move one cell to the right
fn move_right_by(&mut self, n: usize)
Add instructions that move n cells to the right
fn move_left(&mut self)
Add an instruction to move one cell to the left
fn move_left_by(&mut self, n: usize)
Add instructions that move n cells to the left
fn increment_relative(&mut self, from: u8, to: u8)
Adds instructions that increment/decrement the current cell from the given value to the other given value
fn increment(&mut self)
Add an instruction to increment the current cell once
fn increment_by(&mut self, n: u8)
Add instructions that increment the current cell n times
fn decrement(&mut self)
Add an instruction to decrement the current cell once
fn decrement_by(&mut self, n: u8)
Add instructions that decrement the current cell n times
fn zero(&mut self)
Adds instructions which set the cell at the current position to zero regardless of its current value
fn zero_cells(&mut self, n: usize)
Adds instructions which set the next n cells (including the current one) to zero Example: zero_cells(3) will set the current cell and the next two to zero
fn store_bytes(&mut self, bytes: &[u8])
Stores the given bytes in each location starting at the current cell The pointer ends up at the cell immediately after the last character written IMPORTANT: Assumes that the current cell and all consecutive cells to be written into are zero to begin with
fn write(&mut self)
Add an instruction that will write the current cell
fn write_consecutive(&mut self, n: usize)
Add instructions that will write the next n consecutive cells starting at the current cell
fn read(&mut self)
Add an instruction that will read a single byte into the current cell
fn read_consecutive(&mut self, n: usize)
Add instructions that will read input into the next n consecutive cells starting at the current cell
fn jump_forward_if_zero(&mut self)
Add an instruction which will only jump forward to the matching jump backward instruction if the current cell is zero
fn jump_backward_unless_zero(&mut self)
Add an instruction which will only jump backward to the previous matching jump forward instruction if the current cell is not zero
fn remove(&mut self, index: usize) -> Instruction
Trait Implementations
impl Debug for Instructions
[src]
impl PartialEq for Instructions
[src]
fn eq(&self, __arg_0: &Instructions) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Instructions) -> bool
This method tests for !=
.
impl Clone for Instructions
[src]
fn clone(&self) -> Instructions
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Into<String> for Instructions
[src]
impl IntoIterator for Instructions
[src]
type Item = Instruction
The type of the elements being iterated over.
type IntoIter = IntoIter<Self::Item>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl Index<usize> for Instructions
[src]
type Output = Instruction
The returned type after indexing
fn index(&self, index: usize) -> &Self::Output
The method for the indexing (container[index]
) operation