Esempio n. 1
0
        public static Instruction Create(Type type)
        {
            // Boxed enums can be unboxed as their underlying types:
            Type underlyingType = type.GetTypeInfo().IsEnum ? Enum.GetUnderlyingType(type) : type.GetNonNullableType();

            switch (underlyingType.GetTypeCode())
            {
            case TypeCode.SByte: return(s_SByte ?? (s_SByte = new OrSByte()));

            case TypeCode.Int16: return(s_Int16 ?? (s_Int16 = new OrInt16()));

            case TypeCode.Int32: return(s_Int32 ?? (s_Int32 = new OrInt32()));

            case TypeCode.Int64: return(s_Int64 ?? (s_Int64 = new OrInt64()));

            case TypeCode.Byte: return(s_Byte ?? (s_Byte = new OrByte()));

            case TypeCode.UInt16: return(s_UInt16 ?? (s_UInt16 = new OrUInt16()));

            case TypeCode.UInt32: return(s_UInt32 ?? (s_UInt32 = new OrUInt32()));

            case TypeCode.UInt64: return(s_UInt64 ?? (s_UInt64 = new OrUInt64()));

            case TypeCode.Boolean: return(s_Boolean ?? (s_Boolean = new OrBoolean()));

            default:
                throw Error.ExpressionNotSupportedForType("Or", type);
            }
        }
Esempio n. 2
0
        public static Instruction Create(Type type)
        {
            switch (type.GetNonNullableType().GetTypeCode())
            {
            case TypeCode.SByte: return(s_SByte ?? (s_SByte = new OrSByte()));

            case TypeCode.Int16: return(s_Int16 ?? (s_Int16 = new OrInt16()));

            case TypeCode.Int32: return(s_Int32 ?? (s_Int32 = new OrInt32()));

            case TypeCode.Int64: return(s_Int64 ?? (s_Int64 = new OrInt64()));

            case TypeCode.Byte: return(s_Byte ?? (s_Byte = new OrByte()));

            case TypeCode.UInt16: return(s_UInt16 ?? (s_UInt16 = new OrUInt16()));

            case TypeCode.UInt32: return(s_UInt32 ?? (s_UInt32 = new OrUInt32()));

            case TypeCode.UInt64: return(s_UInt64 ?? (s_UInt64 = new OrUInt64()));

            case TypeCode.Boolean: return(s_Boolean ?? (s_Boolean = new OrBoolean()));

            default:
                throw ContractUtils.Unreachable;
            }
        }
Esempio n. 3
0
        public static Instruction Create(Type type)
        {
            switch (type.GetNonNullableType().GetTypeCode())
            {
            case TypeCode.SByte: return(s_SByte ?? (s_SByte = new OrSByte()));

            case TypeCode.Int16: return(s_Int16 ?? (s_Int16 = new OrInt16()));

            case TypeCode.Int32: return(s_Int32 ?? (s_Int32 = new OrInt32()));

            case TypeCode.Int64: return(s_Int64 ?? (s_Int64 = new OrInt64()));

            case TypeCode.Byte: return(s_Byte ?? (s_Byte = new OrByte()));

            case TypeCode.UInt16: return(s_UInt16 ?? (s_UInt16 = new OrUInt16()));

            case TypeCode.UInt32: return(s_UInt32 ?? (s_UInt32 = new OrUInt32()));

            case TypeCode.UInt64: return(s_UInt64 ?? (s_UInt64 = new OrUInt64()));

            case TypeCode.Boolean: return(s_Boolean ?? (s_Boolean = new OrBoolean()));

            default:
                throw Error.ExpressionNotSupportedForType("Or", type);
            }
        }
Esempio n. 4
0
        public static Instruction Create(Type type)
        {
            // Boxed enums can be unboxed as their underlying types:
            switch (System.Dynamic.Utils.TypeExtensions.GetTypeCode(type.GetTypeInfo().IsEnum ? Enum.GetUnderlyingType(type) : TypeUtils.GetNonNullableType(type)))
            {
            case TypeCode.SByte: return(s_SByte ?? (s_SByte = new OrSByte()));

            case TypeCode.Byte: return(s_byte ?? (s_byte = new OrByte()));

            case TypeCode.Int16: return(s_int16 ?? (s_int16 = new OrInt16()));

            case TypeCode.Int32: return(s_int32 ?? (s_int32 = new OrInt32()));

            case TypeCode.Int64: return(s_int64 ?? (s_int64 = new OrInt64()));

            case TypeCode.UInt16: return(s_UInt16 ?? (s_UInt16 = new OrUInt16()));

            case TypeCode.UInt32: return(s_UInt32 ?? (s_UInt32 = new OrUInt32()));

            case TypeCode.UInt64: return(s_UInt64 ?? (s_UInt64 = new OrUInt64()));

            case TypeCode.Boolean: return(s_bool ?? (s_bool = new OrBool()));

            default:
                throw Error.ExpressionNotSupportedForType("Or", type);
            }
        }
Esempio n. 5
0
 public static Instruction Create(Type type)
 {
     return(type.GetNonNullableType().GetTypeCode() switch
     {
         TypeCode.SByte => s_SByte ?? (s_SByte = new OrSByte()),
         TypeCode.Int16 => s_Int16 ?? (s_Int16 = new OrInt16()),
         TypeCode.Int32 => s_Int32 ?? (s_Int32 = new OrInt32()),
         TypeCode.Int64 => s_Int64 ?? (s_Int64 = new OrInt64()),
         TypeCode.Byte => s_Byte ?? (s_Byte = new OrByte()),
         TypeCode.UInt16 => s_UInt16 ?? (s_UInt16 = new OrUInt16()),
         TypeCode.UInt32 => s_UInt32 ?? (s_UInt32 = new OrUInt32()),
         TypeCode.UInt64 => s_UInt64 ?? (s_UInt64 = new OrUInt64()),
         TypeCode.Boolean => s_Boolean ?? (s_Boolean = new OrBoolean()),
         _ => throw ContractUtils.Unreachable,
     });
Esempio n. 6
0
        public static Instruction Create(Type type)
        {
            Debug.Assert(!type.IsEnum());
            switch (type.GetTypeCode())
            {
            case TypeCode.Int16: return(_Int16 ?? (_Int16 = new OrInt16()));

            case TypeCode.Int32: return(_Int32 ?? (_Int32 = new OrInt32()));

            case TypeCode.Int64: return(_Int64 ?? (_Int64 = new OrInt64()));

            case TypeCode.UInt16: return(_UInt16 ?? (_UInt16 = new OrUInt16()));

            case TypeCode.UInt32: return(_UInt32 ?? (_UInt32 = new OrUInt32()));

            case TypeCode.UInt64: return(_UInt64 ?? (_UInt64 = new OrUInt64()));

            case TypeCode.Boolean: return(_Boolean ?? (_Boolean = new OrBoolean()));

            default:
                throw Assert.Unreachable;
            }
        }
Esempio n. 7
0
        public static Instruction Create(Type type)
        {
            // Boxed enums can be unboxed as their underlying types:
            switch (System.Dynamic.Utils.TypeExtensions.GetTypeCode(type.GetTypeInfo().IsEnum ? Enum.GetUnderlyingType(type) : TypeUtils.GetNonNullableType(type)))
            {
                case TypeCode.SByte: return s_SByte ?? (s_SByte = new OrSByte());
                case TypeCode.Byte: return s_byte ?? (s_byte = new OrByte());
                case TypeCode.Int16: return s_int16 ?? (s_int16 = new OrInt16());
                case TypeCode.Int32: return s_int32 ?? (s_int32 = new OrInt32());
                case TypeCode.Int64: return s_int64 ?? (s_int64 = new OrInt64());

                case TypeCode.UInt16: return s_UInt16 ?? (s_UInt16 = new OrUInt16());
                case TypeCode.UInt32: return s_UInt32 ?? (s_UInt32 = new OrUInt32());
                case TypeCode.UInt64: return s_UInt64 ?? (s_UInt64 = new OrUInt64());
                case TypeCode.Boolean: return s_bool ?? (s_bool = new OrBool());

                default:
                    throw Error.ExpressionNotSupportedForType("Or", type);
            }
        }
Esempio n. 8
0
        public static Instruction Create(Type type) {
            Debug.Assert(!type.IsEnum());
            switch (type.GetTypeCode()) {
                case TypeCode.Int16: return _Int16 ?? (_Int16 = new OrInt16());
                case TypeCode.Int32: return _Int32 ?? (_Int32 = new OrInt32());
                case TypeCode.Int64: return _Int64 ?? (_Int64 = new OrInt64());
                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new OrUInt16());
                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new OrUInt32());
                case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new OrUInt64());
                case TypeCode.Boolean: return _Boolean ?? (_Boolean = new OrBoolean());

                default:
                    throw Assert.Unreachable;
            }
        }
Esempio n. 9
0
        public static Instruction Create(Type type)
        {
            // Boxed enums can be unboxed as their underlying types:
            Type underlyingType = type.GetTypeInfo().IsEnum ? Enum.GetUnderlyingType(type) : type.GetNonNullableType();

            switch (underlyingType.GetTypeCode())
            {
                case TypeCode.SByte: return s_SByte ?? (s_SByte = new OrSByte());
                case TypeCode.Int16: return s_Int16 ?? (s_Int16 = new OrInt16());
                case TypeCode.Int32: return s_Int32 ?? (s_Int32 = new OrInt32());
                case TypeCode.Int64: return s_Int64 ?? (s_Int64 = new OrInt64());
                case TypeCode.Byte: return s_Byte ?? (s_Byte = new OrByte());
                case TypeCode.UInt16: return s_UInt16 ?? (s_UInt16 = new OrUInt16());
                case TypeCode.UInt32: return s_UInt32 ?? (s_UInt32 = new OrUInt32());
                case TypeCode.UInt64: return s_UInt64 ?? (s_UInt64 = new OrUInt64());
                case TypeCode.Boolean: return s_Boolean ?? (s_Boolean = new OrBoolean());
                default:
                    throw Error.ExpressionNotSupportedForType("Or", type);
            }
        }