Struct mlem::Machine [] [src]

pub struct Machine<'mach> { /* fields omitted */ }

Represents the state of a machine, including its registers, its memory, its I/O Read and Write, and its program.

The associated lifetime 'mach represents the life of the machine; its I/O connections must live at least that long.


impl<'mach> Machine<'mach>

Create a new Machine connected to the given I/O ports.

Load a program into the machine This resets the instruction pointer.

Borrow out the machine's internal memory for examination. When it's borrowed out, the machine can't run.

Replace the machine's memory with the given vector.

Advance to the next instruction (i.e., increment IP). This can cause a Fault, if IP ends up off the end.

Write the given word value to the given address. If it's a Literal, this will emit a Fault; otherwise it's a Continue.

Read a word from the given address.

Execute instructions until a Halt or Fault occurs. BEWARE: This may run forever!

Execute at most the given number of instructions, also stopping on a Halt or Fault condition. Returns the Outcome of the last instruction and the number of instructions executed.