[][src]Trait rdcl_aoc_helpers::machine::instruction::MachineInstruction

pub trait MachineInstruction: Sized + Clone {
    pub fn execute<R: MachineRegister, O: OutputReceiver<R>>(
        &self,
        register: &mut R,
        output_receiver: &mut O
    ) -> i64;
pub fn from_parsed_machine_instruction(
        parsed: &ParsedMachineInstruction
    ) -> Result<Self, ParseError>; pub fn from_str(instruction: &str) -> Result<Self, ParseError> { ... } }

A machine instruction.

Required methods

pub fn execute<R: MachineRegister, O: OutputReceiver<R>>(
    &self,
    register: &mut R,
    output_receiver: &mut O
) -> i64
[src]

Executes this instruction. Returns an offset indicating the next instruction. For example, an offset of 1 means "go to the next instruction", an offset of -1 means "go to the previous instruction", an offset of 3 means "skip two instructions" and an offset of 0 means "repeat the current instruction". If this offset causes the program counter to point to a non-existing instruction (i.e. either the counter becomes negative, or greater than the number of instructions), this will cause the program to halt. If you want to abort the program, you can just return i64::MIN. This will always cause the program counter to become negative, and will thus halt the program.

pub fn from_parsed_machine_instruction(
    parsed: &ParsedMachineInstruction
) -> Result<Self, ParseError>
[src]

Implement this method to be able to use the provided from_str method to parse instructions.

Loading content...

Provided methods

pub fn from_str(instruction: &str) -> Result<Self, ParseError>[src]

Parses an instruction using ParsedMachineInstruction and from_parsed_machine_instruction.

Loading content...

Implementors

Loading content...