* @throws IOException
*/
static final TypeExpr load (RecordInputStream s, ModuleTypeInfo mti, Map<Short, TypeExpr> visitedTypeExpr, Map<Short, RecordVar> visitedRecordVar, CompilerMessageLogger msgLogger) throws IOException {
// Determine which specific class this serialized instance is.
RecordHeaderInfo rhi = s.findRecord(TYPE_EXPR_RECORD_TAGS);
if (rhi == null) {
throw new IOException ("Unable to find TypeExpr record header.");
}
// Based on the record tag load the actual instance.
switch (rhi.getRecordTag()) {
case ModuleSerializationTags.STATIC_CONSTANT_TYPE_EXPR:
{
if (rhi.getSchema() > staticConstantTypeExprSerializationSchema) {
throw new IOException("Stored schema " + rhi.getSchema() + " is greater than current schema " + staticConstantTypeExprSerializationSchema + " when loading a static constant TypeExpr.");
}
String constName = s.readUTF();
s.skipRestOfRecord();
if (constName.equals ("EMPTY_RECORD")) {
return EMPTY_RECORD;
} else {
}
}
case ModuleSerializationTags.ALREADY_VISITED_TYPE_EXPR:
{
// This is a reference to an existing instance. The instance should be
// in the visitedTypeExpr map.
if (rhi.getSchema() > alreadyVisitedTypeExprSerializationSchema) {
throw new IOException("Stored schema " + rhi.getSchema() + " is greater than current schema " + alreadyVisitedTypeExprSerializationSchema + " loading an already visited TypeExpr.");
}
// Read the key and do the lookup.
short id = s.readShortCompressed();
TypeExpr te = visitedTypeExpr.get(new Short(id));
if (te == null) {
throw new IOException ("Unable to resolve previously encountered TypeExpr instance in TypeExpr.");
}
s.skipRestOfRecord();
return te;
}
case ModuleSerializationTags.TYPE_CONSTRUCTOR:
{
return TypeConsApp.load(s, rhi.getSchema(), mti, visitedTypeExpr, visitedRecordVar, msgLogger);
}
case ModuleSerializationTags.TYPE_APP:
{
return TypeApp.load(s, rhi.getSchema(), mti, visitedTypeExpr, visitedRecordVar, msgLogger);
}
case ModuleSerializationTags.TYPE_VAR:
case ModuleSerializationTags.TYPE_VAR_WITH_INSTANCE:
{
return TypeVar.load(s, rhi.getRecordTag(), rhi.getSchema(), mti, visitedTypeExpr, visitedRecordVar, msgLogger);
}
case ModuleSerializationTags.RECORD_TYPE:
{
return RecordType.load(s, rhi.getSchema(), mti, visitedTypeExpr, visitedRecordVar, msgLogger);
}
default:
{
throw new IOException("Unexpected record tag " + rhi.getRecordTag() + " found when looking for TypeExpr.");
}
}
}