public final class Frame
extends java.lang.Object
Constructor and Description |
---|
Frame()
Construct a new frame.
|
Frame(@NotNull Frame frame)
Construct a copy of the given
frame . |
Frame(@NotNull Instruction instruction)
Construct a new frame with the given
instruction . |
Modifier and Type | Method and Description |
---|---|
Value |
compute(@NotNull java.lang.String address,
@NotNull java.util.function.UnaryOperator<Value> operator)
Replace the value at the given
address with the result of invoking the
given operator with the current value. |
@NotNull Value |
get(@NotNull java.lang.String address)
Return the value allocated at the given
address in this memory. |
@Nullable Instruction |
getInstruction()
Return the instruction of this frame.
|
@NotNull Value |
pop()
Return and remove the last pushed value to the stack.
|
void |
push(@NotNull Value value)
Push the given
value to the stack part of this memory. |
void |
set(@NotNull java.lang.String address,
@NotNull Value value)
Set the value at the given
address to be the given value . |
void |
setInstruction(@NotNull Instruction instruction)
Set the instruction of this frame to be the given
instruction . |
public Frame()
public Frame(@NotNull @NotNull Frame frame)
frame
.frame
- the frame to copy.java.lang.NullPointerException
- if the given frame
is null.public Frame(@NotNull @NotNull Instruction instruction)
instruction
.instruction
- the instruction the constructed frame is for.java.lang.NullPointerException
- if the given instruction
is null.@Contract(mutates="this") public Value compute(@NotNull @NotNull java.lang.String address, @NotNull @NotNull java.util.function.UnaryOperator<Value> operator)
address
with the result of invoking the
given operator
with the current value.
operator
thrown any exception when invoked by this method. The
thrown exception will fall throw this method with nothing changed.address
- the address to replace the value at.operator
- the function to be invoked to acquire the replacement value.java.lang.NullPointerException
- if the given address
or operator
is
null.@NotNull @Contract(pure=true) public @NotNull Value get(@NotNull @NotNull java.lang.String address)
address
in this memory.address
- the address to be read.address
. Or Value.NULL
if no value
was allocated there.java.lang.NullPointerException
- if the given address
is null.@Nullable @Contract(pure=true) public @Nullable Instruction getInstruction()
@NotNull @Contract(mutates="this") public @NotNull Value pop()
Value.NULL
if the stack was
empty.@Contract(mutates="this") public void push(@NotNull @NotNull Value value)
value
to the stack part of this memory.value
- the value to be pushed.java.lang.NullPointerException
- if the given value
is null.@Contract(mutates="this") public void set(@NotNull @NotNull java.lang.String address, @NotNull @NotNull Value value)
address
to be the given value
.address
- the address to set the value to.value
- the value to be set at the given address
.java.lang.NullPointerException
- if the given address
or value
is
null.@Contract(mutates="this") public void setInstruction(@NotNull @NotNull Instruction instruction)
instruction
.instruction
- the instruction of this frame.