Esempio n. 1
0
        public static bool Is64BitIntegral(this Cci.PrimitiveTypeCode kind)
        {
            switch (kind)
            {
            case Cci.PrimitiveTypeCode.Int64:
            case Cci.PrimitiveTypeCode.UInt64:
                return(true);

            default:
                return(false);
            }
        }
Esempio n. 2
0
        public static bool IsFloatingPoint(this Cci.PrimitiveTypeCode kind)
        {
            switch (kind)
            {
            case Cci.PrimitiveTypeCode.Float32:
            case Cci.PrimitiveTypeCode.Float64:
                return(true);

            default:
                return(false);
            }
        }
        public static bool IsUnsigned(this Cci.PrimitiveTypeCode kind)
        {
            switch (kind)
            {
            case Cci.PrimitiveTypeCode.UInt8:
            case Cci.PrimitiveTypeCode.UInt16:
            case Cci.PrimitiveTypeCode.UInt32:
            case Cci.PrimitiveTypeCode.UInt64:
            case Cci.PrimitiveTypeCode.UIntPtr:
            case Cci.PrimitiveTypeCode.Char:
            case Cci.PrimitiveTypeCode.Pointer:
                return(true);

            default:
                return(false);
            }
        }
        public static bool IsSigned(this Cci.PrimitiveTypeCode kind)
        {
            switch (kind)
            {
            case Cci.PrimitiveTypeCode.Int8:
            case Cci.PrimitiveTypeCode.Int16:
            case Cci.PrimitiveTypeCode.Int32:
            case Cci.PrimitiveTypeCode.Int64:
            case Cci.PrimitiveTypeCode.IntPtr:
            case Cci.PrimitiveTypeCode.Float32:
            case Cci.PrimitiveTypeCode.Float64:
                return(true);

            default:
                return(false);
            }
        }
Esempio n. 5
0
        public void IntegrityTest()
        {
            for (int i = 1; i <= (int)SpecialType.Count; i++)
            {
                string name = SpecialTypes.GetMetadataName((SpecialType)i);
                Assert.Equal((SpecialType)i, SpecialTypes.GetTypeFromMetadataName(name));
            }

            for (int i = 0; i <= (int)SpecialType.Count; i++)
            {
                Cci.PrimitiveTypeCode code = SpecialTypes.GetTypeCode((SpecialType)i);

                if (code != Cci.PrimitiveTypeCode.NotPrimitive)
                {
                    Assert.Equal((SpecialType)i, SpecialTypes.GetTypeFromMetadataName(code));
                }
            }

            for (int i = 0; i <= (int)Cci.PrimitiveTypeCode.Invalid; i++)
            {
                SpecialType id = SpecialTypes.GetTypeFromMetadataName((Cci.PrimitiveTypeCode)i);

                if (id != SpecialType.None)
                {
                    Assert.Equal((Cci.PrimitiveTypeCode)i, SpecialTypes.GetTypeCode(id));
                }
            }

            Assert.Equal(SpecialType.System_Boolean, SpecialTypes.GetTypeFromMetadataName(Cci.PrimitiveTypeCode.Boolean));
            Assert.Equal(SpecialType.System_Char, SpecialTypes.GetTypeFromMetadataName(Cci.PrimitiveTypeCode.Char));
            Assert.Equal(SpecialType.System_Void, SpecialTypes.GetTypeFromMetadataName(Cci.PrimitiveTypeCode.Void));
            Assert.Equal(SpecialType.System_String, SpecialTypes.GetTypeFromMetadataName(Cci.PrimitiveTypeCode.String));
            Assert.Equal(SpecialType.System_Int64, SpecialTypes.GetTypeFromMetadataName(Cci.PrimitiveTypeCode.Int64));
            Assert.Equal(SpecialType.System_Int32, SpecialTypes.GetTypeFromMetadataName(Cci.PrimitiveTypeCode.Int32));
            Assert.Equal(SpecialType.System_Int16, SpecialTypes.GetTypeFromMetadataName(Cci.PrimitiveTypeCode.Int16));
            Assert.Equal(SpecialType.System_SByte, SpecialTypes.GetTypeFromMetadataName(Cci.PrimitiveTypeCode.Int8));
            Assert.Equal(SpecialType.System_UInt64, SpecialTypes.GetTypeFromMetadataName(Cci.PrimitiveTypeCode.UInt64));
            Assert.Equal(SpecialType.System_UInt32, SpecialTypes.GetTypeFromMetadataName(Cci.PrimitiveTypeCode.UInt32));
            Assert.Equal(SpecialType.System_UInt16, SpecialTypes.GetTypeFromMetadataName(Cci.PrimitiveTypeCode.UInt16));
            Assert.Equal(SpecialType.System_Byte, SpecialTypes.GetTypeFromMetadataName(Cci.PrimitiveTypeCode.UInt8));
            Assert.Equal(SpecialType.System_Single, SpecialTypes.GetTypeFromMetadataName(Cci.PrimitiveTypeCode.Float32));
            Assert.Equal(SpecialType.System_Double, SpecialTypes.GetTypeFromMetadataName(Cci.PrimitiveTypeCode.Float64));
            Assert.Equal(SpecialType.System_IntPtr, SpecialTypes.GetTypeFromMetadataName(Cci.PrimitiveTypeCode.IntPtr));
            Assert.Equal(SpecialType.System_UIntPtr, SpecialTypes.GetTypeFromMetadataName(Cci.PrimitiveTypeCode.UIntPtr));
        }
        public static ConstantValueTypeDiscriminator GetConstantValueTypeDiscriminator(this Cci.PrimitiveTypeCode type)
        {
            switch (type)
            {
            case Cci.PrimitiveTypeCode.Int8: return(ConstantValueTypeDiscriminator.SByte);

            case Cci.PrimitiveTypeCode.UInt8: return(ConstantValueTypeDiscriminator.Byte);

            case Cci.PrimitiveTypeCode.Int16: return(ConstantValueTypeDiscriminator.Int16);

            case Cci.PrimitiveTypeCode.UInt16: return(ConstantValueTypeDiscriminator.UInt16);

            case Cci.PrimitiveTypeCode.Int32: return(ConstantValueTypeDiscriminator.Int32);

            case Cci.PrimitiveTypeCode.UInt32: return(ConstantValueTypeDiscriminator.UInt32);

            case Cci.PrimitiveTypeCode.Int64: return(ConstantValueTypeDiscriminator.Int64);

            case Cci.PrimitiveTypeCode.UInt64: return(ConstantValueTypeDiscriminator.UInt64);

            case Cci.PrimitiveTypeCode.Char: return(ConstantValueTypeDiscriminator.Char);

            case Cci.PrimitiveTypeCode.Boolean: return(ConstantValueTypeDiscriminator.Boolean);

            case Cci.PrimitiveTypeCode.Float32: return(ConstantValueTypeDiscriminator.Single);

            case Cci.PrimitiveTypeCode.Float64: return(ConstantValueTypeDiscriminator.Double);

            case Cci.PrimitiveTypeCode.String: return(ConstantValueTypeDiscriminator.String);

            default:
                throw ExceptionUtilities.UnexpectedValue(type);
            }
        }