Assigns this type's depth if the depths of its supertype and implemented
interfaces are known. Returns false if the depth couldn't be computed
yet.
int max;
if (classDef.getSupertypeIndex() == ClassDef.NO_INDEX) {
max = 0; // this is Object.class or an interface
} else {
SortableType sortableSupertype = types[classDef.getSupertypeIndex()];
if (sortableSupertype == null) {
max = 1; // unknown, so assume it's a root.
} else if (sortableSupertype.depth == -1) {
return false;
} else {
max = sortableSupertype.depth;
}
}
for (short interfaceIndex : classDef.getInterfaces()) {
SortableType implemented = types[interfaceIndex];
if (implemented == null) {
max = Math.max(max, 1); // unknown, so assume it's a root.
} else if (implemented.depth == -1) {
return false;
} else {
max = Math.max(max, implemented.depth);
}
}
depth = max + 1;
return true;