public class LocalsArraySet extends LocalsArray
Note: For the most part, the documentation for this class
ignores the distinction between Type and TypeBearer.
| Constructor and Description |
|---|
LocalsArraySet(int maxLocals)
Constructs an instance.
|
LocalsArraySet(OneLocalsArray primary,
java.util.ArrayList<LocalsArray> secondaries)
Constructs an instance with the specified primary and secondaries set.
|
| Modifier and Type | Method and Description |
|---|---|
void |
annotate(ExceptionWithContext ex)
Annotates (adds context to) the given exception with information
about this instance.
|
LocalsArray |
copy()
Makes and returns a mutable copy of this instance.
|
TypeBearer |
get(int idx)
Gets the type stored at the given local index, only succeeding if
the given local contains a valid type (though it is allowed to
be an uninitialized instance).
|
TypeBearer |
getCategory1(int idx)
Gets the type stored at the given local index, which is expected
to be an initialized category-1 value.
|
TypeBearer |
getCategory2(int idx)
Gets the type stored at the given local index, which is expected
to be a category-2 value.
|
int |
getMaxLocals()
Gets the maximum number of locals this instance can refer to.
|
TypeBearer |
getOrNull(int idx)
Gets the type stored at the given local index, or
null
if the given local is uninitialized / invalid. |
protected OneLocalsArray |
getPrimary()
Gets the locals set appropriate for the current execution context.
|
void |
invalidate(int idx)
Invalidates the local at the given index.
|
void |
makeInitialized(Type type)
Replaces all the occurrences of the given uninitialized type in
this array with its initialized equivalent.
|
LocalsArraySet |
merge(LocalsArray other)
Merges this instance with
other. |
LocalsArraySet |
mergeWithSubroutineCaller(LocalsArray other,
int predLabel)
Merges this instance with a
LocalsSet from a subroutine
caller. |
void |
set(int idx,
TypeBearer type)
Sets the type stored at the given local index.
|
void |
set(RegisterSpec spec)
Sets the type for the local indicated by the given register spec
to that register spec (which includes type and optional name
information).
|
void |
setImmutable()
Makes this instance immutable.
|
LocalsArray |
subArrayForLabel(int subLabel)
Returns a LocalsArray instance representing the locals state that should
be used when returning to a subroutine caller.
|
java.lang.String |
toHuman()
Return the "human" string form of this instance.
|
isImmutable, isMutable, throwIfImmutable, throwIfMutablepublic LocalsArraySet(int maxLocals)
nulls).maxLocals - >= 0; the maximum number of locals this instance
can refer topublic LocalsArraySet(OneLocalsArray primary, java.util.ArrayList<LocalsArray> secondaries)
primary - non-null; primary locals to usesecondaries - non-null; secondaries set, indexed by subroutine
caller label.public void setImmutable()
setImmutable in class MutabilityControlpublic LocalsArray copy()
copy in class LocalsArraynon-null; the copypublic void annotate(ExceptionWithContext ex)
annotate in class LocalsArrayex - non-null; the exception to annotatepublic java.lang.String toHuman()
toString().non-null; the human string formpublic void makeInitialized(Type type)
makeInitialized in class LocalsArraytype - non-null; type to replacepublic int getMaxLocals()
getMaxLocals in class LocalsArraypublic void set(int idx,
TypeBearer type)
LocalsArray.getMaxLocals() and (b) the next index gets invalidated
by the operation. In case of either category, if the previous
local contains a category-2 value, then it too is invalidated by
this operation.set in class LocalsArrayidx - >= 0, < getMaxLocals(); which localtype - non-null; new type for the local at idxpublic void set(RegisterSpec spec)
set(spec.getReg(), spec).set in class LocalsArrayspec - non-null; register spec to use as the basis for the updatepublic void invalidate(int idx)
invalidate in class LocalsArrayidx - >= 0, < getMaxLocals(); which localpublic TypeBearer getOrNull(int idx)
null
if the given local is uninitialized / invalid.getOrNull in class LocalsArrayidx - >= 0, < getMaxLocals(); which localnull-ok; the type of value stored in that localpublic TypeBearer get(int idx)
get in class LocalsArrayidx - >= 0, < getMaxLocals(); which localnon-null; the type of value stored in that localpublic TypeBearer getCategory1(int idx)
getCategory1 in class LocalsArrayidx - >= 0, < getMaxLocals(); which localnon-null; the type of value stored in that localpublic TypeBearer getCategory2(int idx)
getCategory2 in class LocalsArrayidx - >= 0, < getMaxLocals(); which localnon-null; the type of value stored in that localpublic LocalsArraySet merge(LocalsArray other)
other. If the merged result is
the same as this instance, then this is returned (not a copy).merge in class LocalsArrayother - non-null; another LocalsArraynon-null; the merge result, a new instance or thispublic LocalsArraySet mergeWithSubroutineCaller(LocalsArray other, int predLabel)
LocalsSet from a subroutine
caller. To be used when merging in the first block of a subroutine.mergeWithSubroutineCaller in class LocalsArrayother - other non-null; another LocalsArray. The final locals
state of a subroutine caller.predLabel - the label of the subroutine caller block.non-null; the merge result, a new instance or thispublic LocalsArray subArrayForLabel(int subLabel)
subLabel - >= 0; A calling label of a subroutinenull-ok; an instance for this subroutine, or null if subroutine
is not in this set.protected OneLocalsArray getPrimary()
OneLocalsArray instance, then return
this, otherwise return LocalsArraySet's
primary.getPrimary in class LocalsArrayCopyright © 2020. All Rights Reserved.