throw e;
}
}
public Type decodeType0() {
Type type = null;
int desc = readByte();
switch (desc) {
case ELEMENT_TYPE_BOOLEAN:type = Type.GetType("System.Boolean"); break;
case ELEMENT_TYPE_CHAR: type = Type.GetType("System.Char"); break;
case ELEMENT_TYPE_I1: type = Type.GetType("System.SByte"); break;
case ELEMENT_TYPE_U1: type = Type.GetType("System.Byte"); break;
case ELEMENT_TYPE_I2: type = Type.GetType("System.Int16"); break;
case ELEMENT_TYPE_U2: type = Type.GetType("System.UInt16"); break;
case ELEMENT_TYPE_I4: type = Type.GetType("System.Int32"); break;
case ELEMENT_TYPE_U4: type = Type.GetType("System.UInt32"); break;
case ELEMENT_TYPE_I8: type = Type.GetType("System.Int64"); break;
case ELEMENT_TYPE_U8: type = Type.GetType("System.UInt64"); break;
case ELEMENT_TYPE_R4: type = Type.GetType("System.Single"); break;
case ELEMENT_TYPE_R8: type = Type.GetType("System.Double"); break;
case ELEMENT_TYPE_OBJECT: type = Type.GetType("System.Object"); break;
case ELEMENT_TYPE_STRING: type = Type.GetType("System.String"); break;
case ELEMENT_TYPE_I: type = Type.GetType("System.IntPtr"); break;
case ELEMENT_TYPE_U: type = Type.GetType("System.UIntPtr"); break;
case ELEMENT_TYPE_PTR: // Followed by <type> token.
if (getByte() == ELEMENT_TYPE_VOID) {
readByte();
type = Type.mkPtr(Type.GetType("System.Void"));
} else type = Type.mkPtr(decodeType());
break;
case ELEMENT_TYPE_BYREF: /* although BYREF is not listed in 23.2.12. as possible alternative, this method is also called when parsing the signatures of a method param and a method return, which do allow for BYREF */
type = Type.mkByRef(decodeType());
break;
case ELEMENT_TYPE_VALUETYPE: // Followed by TypeDefOrRefEncoded
assert true;
case ELEMENT_TYPE_CLASS:
// Followed by <type> token
type = pemodule.getTypeDefOrRef(decodeInt());
if (type == null) throw new RuntimeException();
break;
case ELEMENT_TYPE_SZARRAY: // Single-dim array with 0 lower bound.
skipCustomMods();
type = Type.mkArray(decodeType(), 1);
break;
case ELEMENT_TYPE_ARRAY:
// <type> <rank> <boundsCount> <bound1> ... <loCount> <lo1> ...
// ArrayShape defined in 23.2.13 ArrayShape
Type elem = decodeType();
int rank = decodeInt();
int numSizes = decodeInt();
for (int i = 0; i < numSizes; i++)
decodeInt(); // TODO don't ignore
int numLoBounds = decodeInt();
for (int i = 0; i < numLoBounds; i++)
decodeInt(); // TODO don't ignore
type = Type.mkArray(elem, rank);
break;
// a grammar production from 23.2.12 Type
// GENERICINST (CLASS | VALUETYPE) TypeDefOrRefEncoded GenArgCount Type*
case ELEMENT_TYPE_GENERICINST:
int b = readByte();
/*- TODO don't ignore b as done above. Should .NET valuetypes be represented as Scala case classes? */
Type instantiatedType = pemodule.getTypeDefOrRef(decodeInt());
int numberOfTypeArgs = decodeInt();
Type[] typeArgs = new Type[numberOfTypeArgs];
for (int iarg = 0; iarg < numberOfTypeArgs; iarg++) {
typeArgs[iarg] = decodeType();
}