public final class Memory
extends java.lang.Object
implements java.io.Closeable
| Constructor and Description |
|---|
Memory()
Construct a new empty memory.
|
Memory(@NotNull Memory memory)
Construct a new copy of the given
memory. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
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 Frame |
dumpFrame()
Dump the stack and the heap of the current frame to frame before it.
|
@NotNull Value |
get(@NotNull java.lang.String address)
Return the value allocated at the given
address in this memory. |
@NotNull java.lang.Appendable |
getConsole()
Return current set console appendable.
|
@NotNull Frame |
getFrame()
Return the current last frame.
|
@NotNull Frame[] |
getFrames()
Return an array containing the current frames in this memory.
|
@NotNull Tree[] |
getStackTrace()
Build the current stack trace of trees.
|
@NotNull Value |
pop()
Return and remove the last pushed value to the stack.
|
Frame |
popFrame()
Pop the current stack frame.
|
void |
print(@NotNull java.lang.CharSequence text)
Print the given
text to the console. |
void |
push(@NotNull Value value)
Push the given
value to the stack part of this memory. |
void |
pushFrame()
Push a new frame.
|
void |
pushFrame(@NotNull Frame frame)
Push the given
frame in 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 |
setConsole(@NotNull java.lang.Appendable console)
Set the console to be the given
console. |
public Memory()
public Memory(@NotNull
@NotNull Memory memory)
memory.memory - the memory to be copied.java.lang.NullPointerException - if the given memory is null.public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOException@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. If no frame has an allocation to the given address
then the result of the computation will be store in the base frame.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(mutates="this") public @NotNull Frame dumpFrame()
@NotNull @Contract(pure=true) public @NotNull Value get(@NotNull @NotNull java.lang.String address)
address in this memory.
address.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.@NotNull @Contract(pure=true) public @NotNull java.lang.Appendable getConsole()
@NotNull @Contract(pure=true) public @NotNull Frame getFrame()
@NotNull
@Contract(value="->new",
pure=true)
public @NotNull Frame[] getFrames()
@NotNull @Contract(pure=true) public @NotNull Tree[] getStackTrace()
@NotNull @Contract(mutates="this") public @NotNull Value pop()
Value.NULL if the stack was
empty.@Contract(mutates="this") public Frame popFrame()
@Contract(mutates="this")
public void print(@NotNull
@NotNull java.lang.CharSequence text)
text to the console.
text - the text to be printed.java.lang.NullPointerException - if the given text is null.java.io.IOError - if an error occurred while writing to the console.@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 pushFrame()
@Contract(mutates="this")
public void pushFrame(@NotNull
@NotNull Frame frame)
frame in this memory.frame - the frame to be pushed.java.lang.NullPointerException - if the given frame 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 setConsole(@NotNull
@NotNull java.lang.Appendable console)
console.console - the new console to be set.java.lang.NullPointerException - if the given console is null.