예제 #1
0
        public static Instruction Create(Type type)
        {
            Debug.Assert(!type.GetTypeInfo().IsEnum);
            switch (type.GetTypeCode())
            {
            case TypeCode.SByte: return(s_SByte ?? (s_SByte = new LessThanSByte()));

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

            case TypeCode.Char: return(s_char ?? (s_char = new LessThanChar()));

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

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

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

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

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

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

            case TypeCode.Single: return(s_single ?? (s_single = new LessThanSingle()));

            case TypeCode.Double: return(s_double ?? (s_double = new LessThanDouble()));

            default:
                throw Assert.Unreachable;
            }
        }
예제 #2
0
        public static Instruction Create(Type type)
        {
            Debug.Assert(!type.IsEnum());
            switch (type.GetTypeCode()) {
                case TypeCode.SByte: return _SByte ?? (_SByte = new LessThanSByte());
                case TypeCode.Byte: return _Byte ?? (_Byte = new LessThanByte());
                case TypeCode.Char: return _Char ?? (_Char = new LessThanChar());
                case TypeCode.Int16: return _Int16 ?? (_Int16 = new LessThanInt16());
                case TypeCode.Int32: return _Int32 ?? (_Int32 = new LessThanInt32());
                case TypeCode.Int64: return _Int64 ?? (_Int64 = new LessThanInt64());
                case TypeCode.UInt16: return _UInt16 ?? (_UInt16 = new LessThanUInt16());
                case TypeCode.UInt32: return _UInt32 ?? (_UInt32 = new LessThanUInt32());
                case TypeCode.UInt64: return _UInt64 ?? (_UInt64 = new LessThanUInt64());
                case TypeCode.Single: return _Single ?? (_Single = new LessThanSingle());
                case TypeCode.Double: return _Double ?? (_Double = new LessThanDouble());

                default:
                    throw Assert.Unreachable;
            }
        }
예제 #3
0
 public static Instruction Create(Type type, bool liftedToNull = false)
 {
     Debug.Assert(!type.IsEnum);
     if (liftedToNull)
     {
         return(type.GetNonNullableType().GetTypeCode() switch
         {
             TypeCode.SByte => s_liftedToNullSByte ?? (s_liftedToNullSByte = new LessThanSByte(null)),
             TypeCode.Int16 => s_liftedToNullInt16 ?? (s_liftedToNullInt16 = new LessThanInt16(null)),
             TypeCode.Char => s_liftedToNullChar ?? (s_liftedToNullChar = new LessThanChar(null)),
             TypeCode.Int32 => s_liftedToNullInt32 ?? (s_liftedToNullInt32 = new LessThanInt32(null)),
             TypeCode.Int64 => s_liftedToNullInt64 ?? (s_liftedToNullInt64 = new LessThanInt64(null)),
             TypeCode.Byte => s_liftedToNullByte ?? (s_liftedToNullByte = new LessThanByte(null)),
             TypeCode.UInt16 => s_liftedToNullUInt16 ?? (s_liftedToNullUInt16 = new LessThanUInt16(null)),
             TypeCode.UInt32 => s_liftedToNullUInt32 ?? (s_liftedToNullUInt32 = new LessThanUInt32(null)),
             TypeCode.UInt64 => s_liftedToNullUInt64 ?? (s_liftedToNullUInt64 = new LessThanUInt64(null)),
             TypeCode.Single => s_liftedToNullSingle ?? (s_liftedToNullSingle = new LessThanSingle(null)),
             TypeCode.Double => s_liftedToNullDouble ?? (s_liftedToNullDouble = new LessThanDouble(null)),
             _ => throw ContractUtils.Unreachable,
         });
예제 #4
0
        public static Instruction CreateLifted(Type type) {
            Debug.Assert(!type.IsEnum());
            switch (type.GetTypeCode()) {
                case TypeCode.SByte: return _SByteLifted ?? (_SByteLifted = new LessThanSByte() { LiftedToNull = true });
                case TypeCode.Byte: return _ByteLifted ?? (_ByteLifted = new LessThanByte() { LiftedToNull = true });
                case TypeCode.Char: return _CharLifted ?? (_CharLifted = new LessThanChar() { LiftedToNull = true });
                case TypeCode.Int16: return _Int16Lifted ?? (_Int16Lifted = new LessThanInt16() { LiftedToNull = true });
                case TypeCode.Int32: return _Int32Lifted ?? (_Int32Lifted = new LessThanInt32() { LiftedToNull = true });
                case TypeCode.Int64: return _Int64Lifted ?? (_Int64Lifted = new LessThanInt64() { LiftedToNull = true });
                case TypeCode.UInt16: return _UInt16Lifted ?? (_UInt16Lifted = new LessThanUInt16() { LiftedToNull = true });
                case TypeCode.UInt32: return _UInt32Lifted ?? (_UInt32Lifted = new LessThanUInt32() { LiftedToNull = true });
                case TypeCode.UInt64: return _UInt64Lifted ?? (_UInt64Lifted = new LessThanUInt64() { LiftedToNull = true });
                case TypeCode.Single: return _SingleLifted ?? (_SingleLifted = new LessThanSingle() { LiftedToNull = true });
                case TypeCode.Double: return _DoubleLifted ?? (_DoubleLifted = new LessThanDouble() { LiftedToNull = true });

                default:
                    throw Assert.Unreachable;
            }
        }
        public static Instruction Create(Type type, bool liftedToNull)
        {
            Debug.Assert(!type.IsEnum);
            if (liftedToNull)
            {
                switch (type.GetNonNullableType().GetTypeCode())
                {
                case TypeCode.SByte:
                    return(_liftedToNullSByte ?? (_liftedToNullSByte = new LessThanSByte(null)));

                case TypeCode.Byte:
                    return(_liftedToNullByte ?? (_liftedToNullByte = new LessThanByte(null)));

                case TypeCode.Char:
                    return(_liftedToNullChar ?? (_liftedToNullChar = new LessThanChar(null)));

                case TypeCode.Int16:
                    return(_liftedToNullInt16 ?? (_liftedToNullInt16 = new LessThanInt16(null)));

                case TypeCode.Int32:
                    return(_liftedToNullInt32 ?? (_liftedToNullInt32 = new LessThanInt32(null)));

                case TypeCode.Int64:
                    return(_liftedToNullInt64 ?? (_liftedToNullInt64 = new LessThanInt64(null)));

                case TypeCode.UInt16:
                    return(_liftedToNullUInt16 ?? (_liftedToNullUInt16 = new LessThanUInt16(null)));

                case TypeCode.UInt32:
                    return(_liftedToNullUInt32 ?? (_liftedToNullUInt32 = new LessThanUInt32(null)));

                case TypeCode.UInt64:
                    return(_liftedToNullUInt64 ?? (_liftedToNullUInt64 = new LessThanUInt64(null)));

                case TypeCode.Single:
                    return(_liftedToNullSingle ?? (_liftedToNullSingle = new LessThanSingle(null)));

                case TypeCode.Double:
                    return(_liftedToNullDouble ?? (_liftedToNullDouble = new LessThanDouble(null)));

                default:
                    throw Error.ExpressionNotSupportedForType("LessThan", type);
                }
            }
            else
            {
                switch (type.GetNonNullableType().GetTypeCode())
                {
                case TypeCode.SByte:
                    return(_sbyte ?? (_sbyte = new LessThanSByte(ScriptingRuntimeHelpers.False)));

                case TypeCode.Byte:
                    return(_byte ?? (_byte = new LessThanByte(ScriptingRuntimeHelpers.False)));

                case TypeCode.Char:
                    return(_char ?? (_char = new LessThanChar(ScriptingRuntimeHelpers.False)));

                case TypeCode.Int16:
                    return(_int16 ?? (_int16 = new LessThanInt16(ScriptingRuntimeHelpers.False)));

                case TypeCode.Int32:
                    return(_int32 ?? (_int32 = new LessThanInt32(ScriptingRuntimeHelpers.False)));

                case TypeCode.Int64:
                    return(_int64 ?? (_int64 = new LessThanInt64(ScriptingRuntimeHelpers.False)));

                case TypeCode.UInt16:
                    return(_uint16 ?? (_uint16 = new LessThanUInt16(ScriptingRuntimeHelpers.False)));

                case TypeCode.UInt32:
                    return(_uint32 ?? (_uint32 = new LessThanUInt32(ScriptingRuntimeHelpers.False)));

                case TypeCode.UInt64:
                    return(_uint64 ?? (_uint64 = new LessThanUInt64(ScriptingRuntimeHelpers.False)));

                case TypeCode.Single:
                    return(_single ?? (_single = new LessThanSingle(ScriptingRuntimeHelpers.False)));

                case TypeCode.Double:
                    return(_double ?? (_double = new LessThanDouble(ScriptingRuntimeHelpers.False)));

                default:
                    throw Error.ExpressionNotSupportedForType("LessThan", type);
                }
            }
        }
예제 #6
0
        public static Instruction Create(Type type, bool liftedToNull = false)
        {
            Debug.Assert(!type.GetTypeInfo().IsEnum);
            if (liftedToNull)
            {
                switch (type.GetNonNullableType().GetTypeCode())
                {
                case TypeCode.SByte: return(s_liftedToNullSByte ?? (s_liftedToNullSByte = new LessThanSByte(null)));

                case TypeCode.Byte: return(s_liftedToNullByte ?? (s_liftedToNullByte = new LessThanByte(null)));

                case TypeCode.Char: return(s_liftedToNullChar ?? (s_liftedToNullChar = new LessThanChar(null)));

                case TypeCode.Int16: return(s_liftedToNullInt16 ?? (s_liftedToNullInt16 = new LessThanInt16(null)));

                case TypeCode.Int32: return(s_liftedToNullInt32 ?? (s_liftedToNullInt32 = new LessThanInt32(null)));

                case TypeCode.Int64: return(s_liftedToNullInt64 ?? (s_liftedToNullInt64 = new LessThanInt64(null)));

                case TypeCode.UInt16: return(s_liftedToNullUInt16 ?? (s_liftedToNullUInt16 = new LessThanUInt16(null)));

                case TypeCode.UInt32: return(s_liftedToNullUInt32 ?? (s_liftedToNullUInt32 = new LessThanUInt32(null)));

                case TypeCode.UInt64: return(s_liftedToNullUInt64 ?? (s_liftedToNullUInt64 = new LessThanUInt64(null)));

                case TypeCode.Single: return(s_liftedToNullSingle ?? (s_liftedToNullSingle = new LessThanSingle(null)));

                case TypeCode.Double: return(s_liftedToNullDouble ?? (s_liftedToNullDouble = new LessThanDouble(null)));

                default:
                    throw Error.ExpressionNotSupportedForType("LessThan", type);
                }
            }
            else
            {
                switch (type.GetNonNullableType().GetTypeCode())
                {
                case TypeCode.SByte: return(s_SByte ?? (s_SByte = new LessThanSByte(Utils.BoxedFalse)));

                case TypeCode.Byte: return(s_byte ?? (s_byte = new LessThanByte(Utils.BoxedFalse)));

                case TypeCode.Char: return(s_char ?? (s_char = new LessThanChar(Utils.BoxedFalse)));

                case TypeCode.Int16: return(s_int16 ?? (s_int16 = new LessThanInt16(Utils.BoxedFalse)));

                case TypeCode.Int32: return(s_int32 ?? (s_int32 = new LessThanInt32(Utils.BoxedFalse)));

                case TypeCode.Int64: return(s_int64 ?? (s_int64 = new LessThanInt64(Utils.BoxedFalse)));

                case TypeCode.UInt16: return(s_UInt16 ?? (s_UInt16 = new LessThanUInt16(Utils.BoxedFalse)));

                case TypeCode.UInt32: return(s_UInt32 ?? (s_UInt32 = new LessThanUInt32(Utils.BoxedFalse)));

                case TypeCode.UInt64: return(s_UInt64 ?? (s_UInt64 = new LessThanUInt64(Utils.BoxedFalse)));

                case TypeCode.Single: return(s_single ?? (s_single = new LessThanSingle(Utils.BoxedFalse)));

                case TypeCode.Double: return(s_double ?? (s_double = new LessThanDouble(Utils.BoxedFalse)));

                default:
                    throw Error.ExpressionNotSupportedForType("LessThan", type);
                }
            }
        }
예제 #7
0
        public static Instruction Create(Type type, bool liftedToNull = false)
        {
            Debug.Assert(!type.GetTypeInfo().IsEnum);
            if (liftedToNull)
            {
                switch (System.Dynamic.Utils.TypeExtensions.GetTypeCode(TypeUtils.GetNonNullableType(type)))
                {
                    case TypeCode.SByte: return s_liftedToNullSByte ?? (s_liftedToNullSByte = new LessThanSByte(null));
                    case TypeCode.Byte: return s_liftedToNullByte ?? (s_liftedToNullByte = new LessThanByte(null));
                    case TypeCode.Char: return s_liftedToNullChar ?? (s_liftedToNullChar = new LessThanChar(null));
                    case TypeCode.Int16: return s_liftedToNullInt16 ?? (s_liftedToNullInt16 = new LessThanInt16(null));
                    case TypeCode.Int32: return s_liftedToNullInt32 ?? (s_liftedToNullInt32 = new LessThanInt32(null));
                    case TypeCode.Int64: return s_liftedToNullInt64 ?? (s_liftedToNullInt64 = new LessThanInt64(null));
                    case TypeCode.UInt16: return s_liftedToNullUInt16 ?? (s_liftedToNullUInt16 = new LessThanUInt16(null));
                    case TypeCode.UInt32: return s_liftedToNullUInt32 ?? (s_liftedToNullUInt32 = new LessThanUInt32(null));
                    case TypeCode.UInt64: return s_liftedToNullUInt64 ?? (s_liftedToNullUInt64 = new LessThanUInt64(null));
                    case TypeCode.Single: return s_liftedToNullSingle ?? (s_liftedToNullSingle = new LessThanSingle(null));
                    case TypeCode.Double: return s_liftedToNullDouble ?? (s_liftedToNullDouble = new LessThanDouble(null));

                    default:
                        throw Error.ExpressionNotSupportedForType("LessThan", type);
                }
            }
            else
            {
                switch (System.Dynamic.Utils.TypeExtensions.GetTypeCode(TypeUtils.GetNonNullableType(type)))
                {
                    case TypeCode.SByte: return s_SByte ?? (s_SByte = new LessThanSByte(ScriptingRuntimeHelpers.False));
                    case TypeCode.Byte: return s_byte ?? (s_byte = new LessThanByte(ScriptingRuntimeHelpers.False));
                    case TypeCode.Char: return s_char ?? (s_char = new LessThanChar(ScriptingRuntimeHelpers.False));
                    case TypeCode.Int16: return s_int16 ?? (s_int16 = new LessThanInt16(ScriptingRuntimeHelpers.False));
                    case TypeCode.Int32: return s_int32 ?? (s_int32 = new LessThanInt32(ScriptingRuntimeHelpers.False));
                    case TypeCode.Int64: return s_int64 ?? (s_int64 = new LessThanInt64(ScriptingRuntimeHelpers.False));
                    case TypeCode.UInt16: return s_UInt16 ?? (s_UInt16 = new LessThanUInt16(ScriptingRuntimeHelpers.False));
                    case TypeCode.UInt32: return s_UInt32 ?? (s_UInt32 = new LessThanUInt32(ScriptingRuntimeHelpers.False));
                    case TypeCode.UInt64: return s_UInt64 ?? (s_UInt64 = new LessThanUInt64(ScriptingRuntimeHelpers.False));
                    case TypeCode.Single: return s_single ?? (s_single = new LessThanSingle(ScriptingRuntimeHelpers.False));
                    case TypeCode.Double: return s_double ?? (s_double = new LessThanDouble(ScriptingRuntimeHelpers.False));

                    default:
                        throw Error.ExpressionNotSupportedForType("LessThan", type);
                }
            }
        }
예제 #8
0
        public static Instruction Create(Type type, bool liftedToNull = false)
        {
            Debug.Assert(!type.IsEnum);
            if (liftedToNull)
            {
                switch (type.GetNonNullableType().GetTypeCode())
                {
                case TypeCode.SByte: return(_liftedToNullSByte ?? (_liftedToNullSByte = new LessThanSByte(null)));

                case TypeCode.Int16: return(_liftedToNullInt16 ?? (_liftedToNullInt16 = new LessThanInt16(null)));

                case TypeCode.Char: return(_liftedToNullChar ?? (_liftedToNullChar = new LessThanChar(null)));

                case TypeCode.Int32: return(_liftedToNullInt32 ?? (_liftedToNullInt32 = new LessThanInt32(null)));

                case TypeCode.Int64: return(_liftedToNullInt64 ?? (_liftedToNullInt64 = new LessThanInt64(null)));

                case TypeCode.Byte: return(_liftedToNullByte ?? (_liftedToNullByte = new LessThanByte(null)));

                case TypeCode.UInt16: return(_liftedToNullUInt16 ?? (_liftedToNullUInt16 = new LessThanUInt16(null)));

                case TypeCode.UInt32: return(_liftedToNullUInt32 ?? (_liftedToNullUInt32 = new LessThanUInt32(null)));

                case TypeCode.UInt64: return(_liftedToNullUInt64 ?? (_liftedToNullUInt64 = new LessThanUInt64(null)));

                case TypeCode.Single: return(_liftedToNullSingle ?? (_liftedToNullSingle = new LessThanSingle(null)));

                case TypeCode.Double: return(_liftedToNullDouble ?? (_liftedToNullDouble = new LessThanDouble(null)));

                default:
                    throw Assert.Unreachable;
                }
            }

            switch (type.GetNonNullableType().GetTypeCode())
            {
            case TypeCode.SByte: return(_SByte ?? (_SByte = new LessThanSByte(ScriptingRuntimeHelpers.False)));

            case TypeCode.Int16: return(_Int16 ?? (_Int16 = new LessThanInt16(ScriptingRuntimeHelpers.False)));

            case TypeCode.Char: return(_Char ?? (_Char = new LessThanChar(ScriptingRuntimeHelpers.False)));

            case TypeCode.Int32: return(_Int32 ?? (_Int32 = new LessThanInt32(ScriptingRuntimeHelpers.False)));

            case TypeCode.Int64: return(_Int64 ?? (_Int64 = new LessThanInt64(ScriptingRuntimeHelpers.False)));

            case TypeCode.Byte: return(_Byte ?? (_Byte = new LessThanByte(ScriptingRuntimeHelpers.False)));

            case TypeCode.UInt16: return(_UInt16 ?? (_UInt16 = new LessThanUInt16(ScriptingRuntimeHelpers.False)));

            case TypeCode.UInt32: return(_UInt32 ?? (_UInt32 = new LessThanUInt32(ScriptingRuntimeHelpers.False)));

            case TypeCode.UInt64: return(_UInt64 ?? (_UInt64 = new LessThanUInt64(ScriptingRuntimeHelpers.False)));

            case TypeCode.Single: return(_Single ?? (_Single = new LessThanSingle(ScriptingRuntimeHelpers.False)));

            case TypeCode.Double: return(_Double ?? (_Double = new LessThanDouble(ScriptingRuntimeHelpers.False)));

            default:
                throw Assert.Unreachable;
            }
        }
예제 #9
0
        public static Instruction Create(Type type, bool liftedToNull = false)
        {
            Debug.Assert(!type.IsEnum);
            if (liftedToNull)
            {
                switch (Type.GetTypeCode(type.GetNonNullable()))
                {
                case TypeCode.SByte: return(_liftedToNullSByte ?? (_liftedToNullSByte = new LessThanSByte(null)));

                case TypeCode.Int16: return(_liftedToNullInt16 ?? (_liftedToNullInt16 = new LessThanInt16(null)));

                case TypeCode.Char: return(_liftedToNullChar ?? (_liftedToNullChar = new LessThanChar(null)));

                case TypeCode.Int32: return(_liftedToNullInt32 ?? (_liftedToNullInt32 = new LessThanInt32(null)));

                case TypeCode.Int64: return(_liftedToNullInt64 ?? (_liftedToNullInt64 = new LessThanInt64(null)));

                case TypeCode.Byte: return(_liftedToNullByte ?? (_liftedToNullByte = new LessThanByte(null)));

                case TypeCode.UInt16: return(_liftedToNullUInt16 ?? (_liftedToNullUInt16 = new LessThanUInt16(null)));

                case TypeCode.UInt32: return(_liftedToNullUInt32 ?? (_liftedToNullUInt32 = new LessThanUInt32(null)));

                case TypeCode.UInt64: return(_liftedToNullUInt64 ?? (_liftedToNullUInt64 = new LessThanUInt64(null)));

                case TypeCode.Single: return(_liftedToNullSingle ?? (_liftedToNullSingle = new LessThanSingle(null)));

                case TypeCode.Double: return(_liftedToNullDouble ?? (_liftedToNullDouble = new LessThanDouble(null)));

                default:
                    throw ContractUtils.Unreachable;
                }
            }

            switch (Type.GetTypeCode(type.GetNonNullable()))
            {
            case TypeCode.SByte: return(_sByte ?? (_sByte = new LessThanSByte(Utils.BoxedFalse)));

            case TypeCode.Int16: return(_int16 ?? (_int16 = new LessThanInt16(Utils.BoxedFalse)));

            case TypeCode.Char: return(_char ?? (_char = new LessThanChar(Utils.BoxedFalse)));

            case TypeCode.Int32: return(_int32 ?? (_int32 = new LessThanInt32(Utils.BoxedFalse)));

            case TypeCode.Int64: return(_int64 ?? (_int64 = new LessThanInt64(Utils.BoxedFalse)));

            case TypeCode.Byte: return(_byte ?? (_byte = new LessThanByte(Utils.BoxedFalse)));

            case TypeCode.UInt16: return(_uInt16 ?? (_uInt16 = new LessThanUInt16(Utils.BoxedFalse)));

            case TypeCode.UInt32: return(_uInt32 ?? (_uInt32 = new LessThanUInt32(Utils.BoxedFalse)));

            case TypeCode.UInt64: return(_uInt64 ?? (_uInt64 = new LessThanUInt64(Utils.BoxedFalse)));

            case TypeCode.Single: return(_single ?? (_single = new LessThanSingle(Utils.BoxedFalse)));

            case TypeCode.Double: return(_double ?? (_double = new LessThanDouble(Utils.BoxedFalse)));

            default:
                throw ContractUtils.Unreachable;
            }
        }
예제 #10
0
        public static Instruction CreateLifted(Type type)
        {
            Debug.Assert(!type.IsEnum());
            switch (type.GetTypeCode())
            {
            case TypeCode.SByte: return(_SByteLifted ?? (_SByteLifted = new LessThanSByte()
                {
                    LiftedToNull = true
                }));

            case TypeCode.Byte: return(_ByteLifted ?? (_ByteLifted = new LessThanByte()
                {
                    LiftedToNull = true
                }));

            case TypeCode.Char: return(_CharLifted ?? (_CharLifted = new LessThanChar()
                {
                    LiftedToNull = true
                }));

            case TypeCode.Int16: return(_Int16Lifted ?? (_Int16Lifted = new LessThanInt16()
                {
                    LiftedToNull = true
                }));

            case TypeCode.Int32: return(_Int32Lifted ?? (_Int32Lifted = new LessThanInt32()
                {
                    LiftedToNull = true
                }));

            case TypeCode.Int64: return(_Int64Lifted ?? (_Int64Lifted = new LessThanInt64()
                {
                    LiftedToNull = true
                }));

            case TypeCode.UInt16: return(_UInt16Lifted ?? (_UInt16Lifted = new LessThanUInt16()
                {
                    LiftedToNull = true
                }));

            case TypeCode.UInt32: return(_UInt32Lifted ?? (_UInt32Lifted = new LessThanUInt32()
                {
                    LiftedToNull = true
                }));

            case TypeCode.UInt64: return(_UInt64Lifted ?? (_UInt64Lifted = new LessThanUInt64()
                {
                    LiftedToNull = true
                }));

            case TypeCode.Single: return(_SingleLifted ?? (_SingleLifted = new LessThanSingle()
                {
                    LiftedToNull = true
                }));

            case TypeCode.Double: return(_DoubleLifted ?? (_DoubleLifted = new LessThanDouble()
                {
                    LiftedToNull = true
                }));

            default:
                throw Assert.Unreachable;
            }
        }
예제 #11
0
 public static Instruction Create(Type type, bool liftedToNull = false)
 {
     Debug.Assert(!type.GetTypeInfo().IsEnum);
     if (liftedToNull)
     {
         switch (type.GetNonNullableType().GetTypeCode())
         {
             case TypeCode.SByte: return s_liftedToNullSByte ?? (s_liftedToNullSByte = new LessThanSByte(null));
             case TypeCode.Int16: return s_liftedToNullInt16 ?? (s_liftedToNullInt16 = new LessThanInt16(null));
             case TypeCode.Char: return s_liftedToNullChar ?? (s_liftedToNullChar = new LessThanChar(null));
             case TypeCode.Int32: return s_liftedToNullInt32 ?? (s_liftedToNullInt32 = new LessThanInt32(null));
             case TypeCode.Int64: return s_liftedToNullInt64 ?? (s_liftedToNullInt64 = new LessThanInt64(null));
             case TypeCode.Byte: return s_liftedToNullByte ?? (s_liftedToNullByte = new LessThanByte(null));
             case TypeCode.UInt16: return s_liftedToNullUInt16 ?? (s_liftedToNullUInt16 = new LessThanUInt16(null));
             case TypeCode.UInt32: return s_liftedToNullUInt32 ?? (s_liftedToNullUInt32 = new LessThanUInt32(null));
             case TypeCode.UInt64: return s_liftedToNullUInt64 ?? (s_liftedToNullUInt64 = new LessThanUInt64(null));
             case TypeCode.Single: return s_liftedToNullSingle ?? (s_liftedToNullSingle = new LessThanSingle(null));
             case TypeCode.Double: return s_liftedToNullDouble ?? (s_liftedToNullDouble = new LessThanDouble(null));
             default:
                 throw Error.ExpressionNotSupportedForType("LessThan", type);
         }
     }
     else
     {
         switch (type.GetNonNullableType().GetTypeCode())
         {
             case TypeCode.SByte: return s_SByte ?? (s_SByte = new LessThanSByte(Utils.BoxedFalse));
             case TypeCode.Int16: return s_Int16 ?? (s_Int16 = new LessThanInt16(Utils.BoxedFalse));
             case TypeCode.Char: return s_Char ?? (s_Char = new LessThanChar(Utils.BoxedFalse));
             case TypeCode.Int32: return s_Int32 ?? (s_Int32 = new LessThanInt32(Utils.BoxedFalse));
             case TypeCode.Int64: return s_Int64 ?? (s_Int64 = new LessThanInt64(Utils.BoxedFalse));
             case TypeCode.Byte: return s_Byte ?? (s_Byte = new LessThanByte(Utils.BoxedFalse));
             case TypeCode.UInt16: return s_UInt16 ?? (s_UInt16 = new LessThanUInt16(Utils.BoxedFalse));
             case TypeCode.UInt32: return s_UInt32 ?? (s_UInt32 = new LessThanUInt32(Utils.BoxedFalse));
             case TypeCode.UInt64: return s_UInt64 ?? (s_UInt64 = new LessThanUInt64(Utils.BoxedFalse));
             case TypeCode.Single: return s_Single ?? (s_Single = new LessThanSingle(Utils.BoxedFalse));
             case TypeCode.Double: return s_Double ?? (s_Double = new LessThanDouble(Utils.BoxedFalse));
             default:
                 throw Error.ExpressionNotSupportedForType("LessThan", type);
         }
     }
 }