예제 #1
0
        public TypeDesc ConvertToCanonFormIfNecessary(TypeDesc type, CanonicalFormKind policy)
        {
            if (!type.IsCanonicalSubtype(CanonicalFormKind.Any))
            {
                return(type);
            }

            if (type.IsPointer || type.IsByRef)
            {
                ParameterizedType parameterizedType  = (ParameterizedType)type;
                TypeDesc          paramTypeConverted = ConvertToCanonFormIfNecessary(parameterizedType.ParameterType, policy);
                if (paramTypeConverted == parameterizedType.ParameterType)
                {
                    return(type);
                }

                if (type.IsPointer)
                {
                    return(TypeSystemContext.GetPointerType(paramTypeConverted));
                }

                if (type.IsByRef)
                {
                    return(TypeSystemContext.GetByRefType(paramTypeConverted));
                }
            }

            return(type.ConvertToCanonForm(policy));
        }
        private TypeDesc GetModifierType(ref NativeParser parser, TypeModifierKind modifier)
        {
            TypeDesc typeParameter = GetType(ref parser);

            switch (modifier)
            {
            case TypeModifierKind.Array:
                return(_typeSystemContext.GetArrayType(typeParameter));

            case TypeModifierKind.ByRef:
                return(_typeSystemContext.GetByRefType(typeParameter));

            case TypeModifierKind.Pointer:
                return(_typeSystemContext.GetPointerType(typeParameter));

            default:
                parser.ThrowBadImageFormatException();
                return(null);
            }
        }