Exemplo 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 RightShiftSByte()));

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

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

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

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

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

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

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

            default:
                throw Error.ExpressionNotSupportedForType("RightShift", type);
            }
        }
Exemplo n.º 2
0
 public static Instruction Create(Type type)
 {
     return(type.GetNonNullableType().GetTypeCode() switch
     {
         TypeCode.SByte => s_SByte ?? (s_SByte = new RightShiftSByte()),
         TypeCode.Int16 => s_Int16 ?? (s_Int16 = new RightShiftInt16()),
         TypeCode.Int32 => s_Int32 ?? (s_Int32 = new RightShiftInt32()),
         TypeCode.Int64 => s_Int64 ?? (s_Int64 = new RightShiftInt64()),
         TypeCode.Byte => s_Byte ?? (s_Byte = new RightShiftByte()),
         TypeCode.UInt16 => s_UInt16 ?? (s_UInt16 = new RightShiftUInt16()),
         TypeCode.UInt32 => s_UInt32 ?? (s_UInt32 = new RightShiftUInt32()),
         TypeCode.UInt64 => s_UInt64 ?? (s_UInt64 = new RightShiftUInt64()),
         _ => throw ContractUtils.Unreachable,
     });
Exemplo n.º 3
0
        public static Instruction Create(Type type)
        {
            switch (type.GetNonNullableType().GetTypeCode())
            {
            case TypeCode.SByte: return(s_SByte ?? (s_SByte = new RightShiftSByte()));

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

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

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

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

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

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

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

            default:
                throw Error.ExpressionNotSupportedForType("RightShift", type);
            }
        }
Exemplo n.º 4
0
        public static Instruction Create(Type type)
        {
            switch (type.GetNonNullable().GetTypeCode())
            {
            case TypeCode.SByte: return(_sByte ?? (_sByte = new RightShiftSByte()));

            case TypeCode.Int16: return(_int16 ?? (_int16 = new RightShiftInt16()));

            case TypeCode.Int32: return(_int32 ?? (_int32 = new RightShiftInt32()));

            case TypeCode.Int64: return(_int64 ?? (_int64 = new RightShiftInt64()));

            case TypeCode.Byte: return(_byte ?? (_byte = new RightShiftByte()));

            case TypeCode.UInt16: return(_uInt16 ?? (_uInt16 = new RightShiftUInt16()));

            case TypeCode.UInt32: return(_uInt32 ?? (_uInt32 = new RightShiftUInt32()));

            case TypeCode.UInt64: return(_uInt64 ?? (_uInt64 = new RightShiftUInt64()));

            default:
                throw ContractUtils.Unreachable;
            }
        }
Exemplo n.º 5
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 RightShiftSByte());
                case TypeCode.Byte: return s_byte ?? (s_byte = new RightShiftByte());
                case TypeCode.Int16: return s_int16 ?? (s_int16 = new RightShiftInt16());
                case TypeCode.Int32: return s_int32 ?? (s_int32 = new RightShiftInt32());
                case TypeCode.Int64: return s_int64 ?? (s_int64 = new RightShiftInt64());

                case TypeCode.UInt16: return s_UInt16 ?? (s_UInt16 = new RightShiftUInt16());
                case TypeCode.UInt32: return s_UInt32 ?? (s_UInt32 = new RightShiftUInt32());
                case TypeCode.UInt64: return s_UInt64 ?? (s_UInt64 = new RightShiftUInt64());

                default:
                    throw Error.ExpressionNotSupportedForType("RightShift", type);
            }
        }