Example #1
0
        /// <summary>
        /// Parse a descriptor containing a single field type
        /// </summary>
        private static TypeReference ParseFieldType(string descriptor, ref int index)
        {
            var code = descriptor[index++];

            if (code == '[')
            {
                // Array
                return(new ArrayTypeReference(ParseFieldType(descriptor, ref index)));
            }

            if (code == 'L')
            {
                // Object class
                var end = descriptor.IndexOf(';', index);
                if (end < 0)
                {
                    throw new InvalidDescriptorException(descriptor);
                }
                var name = descriptor.Substring(index, end - index);
                index = end + 1;
                return(new ObjectTypeReference(name, null));
            }

            // Should be base type
            BaseTypeReference type;

            if (BaseTypeReference.TryGetByCode(code, out type))
            {
                return(type);
            }

            throw new InvalidDescriptorException(descriptor);
        }
Example #2
0
        /// <summary>
        /// Parse a signature containing a single TypeSignature.
        /// </summary>
        private static TypeReference ParseTypeSignature(string signature, ref int index)
        {
            var code = signature[index];

            // Try base type
            BaseTypeReference type;

            if (BaseTypeReference.TryGetByCode(code, out type))
            {
                index++;
                return(type);
            }

            return(ParseFieldTypeSignature(signature, ref index));
        }
Example #3
0
 /// <summary>
 /// Try to lookup a base type reference by it's CLR equivalent.
 /// </summary>
 internal static bool TryGetByClrType(Type clrType, out BaseTypeReference type)
 {
     type = baseTypes.FirstOrDefault(x => x.clrType == clrType);
     return(type != null);
 }
Example #4
0
 /// <summary>
 /// Try to lookup a base type reference by it's descriptor code.
 /// </summary>
 internal static bool TryGetByCode(char code, out BaseTypeReference type)
 {
     type = baseTypes.FirstOrDefault(x => x.code == code);
     return(type != null);
 }
Example #5
0
 /// <summary>
 /// Try to lookup a base type reference by it's descriptor code.
 /// </summary>
 internal static bool TryGetByCode(char code, out BaseTypeReference type)
 {
     type = baseTypes.FirstOrDefault(x => x.code == code);
     return (type != null);
 }
Example #6
0
 /// <summary>
 /// Try to lookup a base type reference by it's CLR equivalent.
 /// </summary>
 internal static bool TryGetByClrType(Type clrType, out BaseTypeReference type)
 {
     type = baseTypes.FirstOrDefault(x => x.clrType == clrType);
     return (type != null);
 }