Unity.IL2CPP.StackTypeConverter.StackTypeFor C# (CSharp) Method

StackTypeFor() public static method

public static StackTypeFor ( TypeReference type ) : TypeReference
type Mono.Cecil.TypeReference
return Mono.Cecil.TypeReference
        public static TypeReference StackTypeFor(TypeReference type)
        {
            PinnedType type2 = type as PinnedType;
            if (type2 != null)
            {
                type = type2.ElementType;
            }
            ByReferenceType type3 = type as ByReferenceType;
            if (type3 != null)
            {
                return type3;
            }
            RequiredModifierType type4 = type as RequiredModifierType;
            if (type4 != null)
            {
                return StackTypeFor(type4.ElementType);
            }
            if ((Extensions.IsSameType(type, TypeProvider.NativeIntTypeReference) || Extensions.IsSameType(type, TypeProvider.NativeUIntTypeReference)) || type.IsPointer)
            {
                return TypeProvider.NativeIntTypeReference;
            }
            if (!Extensions.IsValueType(type))
            {
                return TypeProvider.ObjectTypeReference;
            }
            MetadataType metadataType = type.MetadataType;
            if (Extensions.IsValueType(type) && Extensions.IsEnum(type))
            {
                metadataType = Extensions.GetUnderlyingEnumType(type).MetadataType;
            }
            switch (metadataType)
            {
                case MetadataType.Boolean:
                case MetadataType.Char:
                case MetadataType.SByte:
                case MetadataType.Byte:
                case MetadataType.Int16:
                case MetadataType.UInt16:
                case MetadataType.Int32:
                case MetadataType.UInt32:
                    return TypeProvider.Int32TypeReference;

                case MetadataType.Int64:
                case MetadataType.UInt64:
                    return TypeProvider.Int64TypeReference;

                case MetadataType.Single:
                    return TypeProvider.SingleTypeReference;

                case MetadataType.Double:
                    return TypeProvider.DoubleTypeReference;

                case MetadataType.IntPtr:
                case MetadataType.UIntPtr:
                    return TypeProvider.NativeIntTypeReference;
            }
            throw new ArgumentException(string.Format("Cannot get stack type for {0}", type.Name));
        }