public class State
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
State.Output
A representation of output from the interpreter
|
Modifier and Type | Field and Description |
---|---|
java.util.List<State.Output> |
output
The full output of the machine.
|
int |
regFP
The frame pointer register (FP)
|
int |
regPC
The program counter register (PC)
|
Word |
regR
The R register
|
int |
regSP
The stack pointer register (SP)
|
int[] |
staticMemory
The static memory
|
int |
tick
The tick counter (not available to programs)
|
Constructor and Description |
---|
State()
Create a "standard" fresh initial XVM state.
|
Modifier and Type | Method and Description |
---|---|
Word |
getStackEntry(int index)
Get an entry from the stack.
|
void |
setOutputHandler(java.util.function.Consumer<java.lang.Integer> outputHandler)
Determine how to handle output.
|
java.lang.String |
toString() |
public Word regR
public int regFP
public int regSP
public int regPC
public int tick
public final int[] staticMemory
public final java.util.List<State.Output> output
Regardless of whether the output is displayed, all output is stored in this list.
setOutputHandler(Consumer)
public State()
By default, this will have 1024 integers worth of static memory.
public Word getStackEntry(int index)
index
- the index of the entry to remove, numbering from bottom (0) to
top. 0 <= index < regSP
public void setOutputHandler(java.util.function.Consumer<java.lang.Integer> outputHandler)
By default all output is only stored and not displayed. To allow it to be displayed to the standard output, for example, you can say:
state.setOutputHandler(System.out::println);
outputHandler
- the output handlerpublic java.lang.String toString()
toString
in class java.lang.Object