public final class ExecutionStack extends MutabilityControl
Note: For the most part, the documentation for this class
ignores the distinction between Type and TypeBearer.
| Constructor and Description |
|---|
ExecutionStack(int maxStack)
Constructs an instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
annotate(ExceptionWithContext ex)
Annotates (adds context to) the given exception with information
about this instance.
|
void |
change(int n,
TypeBearer type)
Changes an element already on a stack.
|
void |
clear()
Clears the stack.
|
ExecutionStack |
copy()
Makes and returns a mutable copy of this instance.
|
int |
getMaxStack()
Gets the maximum stack size for this instance.
|
void |
makeInitialized(Type type)
Replaces all the occurrences of the given uninitialized type in
this stack with its initialized equivalent.
|
ExecutionStack |
merge(ExecutionStack other)
Merges this stack with another stack.
|
TypeBearer |
peek(int n)
Peeks at the
nth element down from the top of the stack. |
boolean |
peekLocal(int n)
Peeks at the
nth element down from the top of the
stack, returning whether or not it has local info. |
Type |
peekType(int n)
Peeks at the
nth element down from the top of the
stack, returning the type per se, as opposed to the
type-bearer. |
TypeBearer |
pop()
Pops the top element off of the stack.
|
void |
push(TypeBearer type)
Pushes a value of the given type onto the stack.
|
void |
setLocal()
Flags the next value pushed onto the stack as having local info.
|
int |
size()
Gets the current stack size.
|
isImmutable, isMutable, setImmutable, throwIfImmutable, throwIfMutablepublic ExecutionStack(int maxStack)
maxStack - >= 0; the maximum size of the stack for this
instancepublic ExecutionStack copy()
non-null; the copypublic void annotate(ExceptionWithContext ex)
ex - non-null; the exception to annotatepublic void makeInitialized(Type type)
type - non-null; type to replacepublic int getMaxStack()
>= 0; the max stack sizepublic int size()
>= 0, < getMaxStack(); the current stack sizepublic void clear()
public void push(TypeBearer type)
type - non-null; type of the valueSimException - thrown if there is insufficient room on the
stack for the valuepublic void setLocal()
public TypeBearer peek(int n)
nth element down from the top of the stack.
n == 0 means to peek at the top of the stack. Note that
this will return null if the indicated element is the
deeper half of a category-2 value.n - >= 0; which element to peek atnull-ok; the type of value stored at that elementSimException - thrown if n >= size()public boolean peekLocal(int n)
nth element down from the top of the
stack, returning whether or not it has local info.n - >= 0; which element to peek attrue if the value has local info, false otherwiseSimException - thrown if n >= size()public Type peekType(int n)
nth element down from the top of the
stack, returning the type per se, as opposed to the
type-bearer. This method is just a convenient shorthand
for peek(n).getType().peek(int)public TypeBearer pop()
non-null; the type formerly on the top of the stackSimException - thrown if the stack is emptypublic void change(int n,
TypeBearer type)
n - >= 0; which element to change, where 0 is
the top element of the stacktype - non-null; type of the new valueSimException - thrown if n >= size() or
the action is otherwise prohibitedpublic ExecutionStack merge(ExecutionStack other)
Merger.mergeStack()other - non-null; a stack to merge withnon-null; the result of the mergeCopyright © 2020. All Rights Reserved.