public class TypeCheckBuilder extends Object
TypeSnippets
for specific implementation details).
For the class dependency hierarchy, assigning each type a unique id that can be used within a range check can be accomplished by assigning ids via a preorder traversal of the hierarchy graph. However, because classes/interfaces may implement multiple interfaces, there might not be a single graph traversal which accurately encapsulates all needed range checks. Therefore, instead of a type having a single id, each type has an array of ids, where each index represents the type's id in the specific subset of range checks the index covers.
In our implementation, we separately handle type checks for class and interface types: class checks are assigned via a preorder graph traversal, while interface checks are assigned by finding maximal subsets of the required range checks which satisfy the consecutive ones property (C1P).
Given a matrix of boolean values, the consecutive ones property holds if the columns of the matrix can be reordered so that, within each row, all of the set columns are contiguous. When mapping type checks to a boolean matrix, the columns/rows are the types against which the check will be performed. An row-column entry is true if row.isAssignableFrom(column) should be true. If an ordering can be found which ensures all set columns are contiguous, then it is possible to assign ids in a order which satisfies all encapsulated range checks.
For determining whether a given subset of the range checks satisfies C1P, we use the algorithm described in "A Simple Test for the Consecutive Ones Property" by Wen-Lain Hsu. In this work, the author is able to simplify the process of determining whether C1P is satisfied by determining which rows strictly overlap. Two rows strictly overlap iff:
Identifying strictly overlapping relations allows the C1P problem to be decomposed and solved in an incremental manner.
Constructor and Description |
---|
TypeCheckBuilder(Collection<HostedType> types,
HostedType objectType,
HostedType cloneableType,
HostedType serializableType) |
Modifier and Type | Method and Description |
---|---|
void |
buildTypeInformation(HostedUniverse hUniverse)
This method set's the universe's orderedType collection, and for each HostedType, sets the
following fields:
typeID
subTypes
strengthenStampType
uniqueConcreteImplementation
The stamps are calculated by performing a dataflow analysis of the
TypeCheckBuilder.subtypeMap . |
boolean |
calculateIDs()
Calculates all of the needed type check id information and stores it in the HostedTypes.
|
int |
getNumTypeCheckSlots() |
public TypeCheckBuilder(Collection<HostedType> types, HostedType objectType, HostedType cloneableType, HostedType serializableType)
public int getNumTypeCheckSlots()
public void buildTypeInformation(HostedUniverse hUniverse)
TypeCheckBuilder.subtypeMap
.public boolean calculateIDs()