Example #1
0
        public static Instruction Create(Type type, bool liftedToNull)
        {
            if (liftedToNull)
            {
                switch (Type.GetTypeCode(type.GetNonNullable()))
                {
                    case TypeCode.Boolean: return ExclusiveOrInstruction.Create(type);
                    case TypeCode.SByte: return _sByteLiftedToNull ??= new NotEqualSByteLiftedToNull();
                    case TypeCode.Int16: return _int16LiftedToNull ??= new NotEqualInt16LiftedToNull();
                    case TypeCode.Char: return _charLiftedToNull ??= new NotEqualCharLiftedToNull();
                    case TypeCode.Int32: return _int32LiftedToNull ??= new NotEqualInt32LiftedToNull();
                    case TypeCode.Int64: return _int64LiftedToNull ??= new NotEqualInt64LiftedToNull();
                    case TypeCode.Byte: return _byteLiftedToNull ??= new NotEqualByteLiftedToNull();
                    case TypeCode.UInt16: return _uInt16LiftedToNull ??= new NotEqualUInt16LiftedToNull();
                    case TypeCode.UInt32: return _uInt32LiftedToNull ??= new NotEqualUInt32LiftedToNull();
                    case TypeCode.UInt64: return _uInt64LiftedToNull ??= new NotEqualUInt64LiftedToNull();
                    case TypeCode.Single: return _singleLiftedToNull ??= new NotEqualSingleLiftedToNull();
                    default:
                        Debug.Assert(Type.GetTypeCode(type.GetNonNullable()) == TypeCode.Double);
                        return _doubleLiftedToNull ??= new NotEqualDoubleLiftedToNull();
                }
            }

            switch (Type.GetTypeCode(type.GetNonNullable()))
            {
                case TypeCode.Boolean: return _boolean ??= new NotEqualBoolean();
                case TypeCode.SByte: return _sByte ??= new NotEqualSByte();
                case TypeCode.Int16: return _int16 ??= new NotEqualInt16();
                case TypeCode.Char: return _char ??= new NotEqualChar();
                case TypeCode.Int32: return _int32 ??= new NotEqualInt32();
                case TypeCode.Int64: return _int64 ??= new NotEqualInt64();
                case TypeCode.Byte: return _byte ??= new NotEqualByte();
                case TypeCode.UInt16: return _uInt16 ??= new NotEqualUInt16();
                case TypeCode.UInt32: return _uInt32 ??= new NotEqualUInt32();
                case TypeCode.UInt64: return _uInt64 ??= new NotEqualUInt64();
                case TypeCode.Single: return _single ??= new NotEqualSingle();
                case TypeCode.Double: return _double ??= new NotEqualDouble();
                default:
                    // Nullable only valid if one operand is constant null, so this assert is slightly too broad.
                    Debug.Assert(type.CanBeNull());
                    return _reference ??= new NotEqualReference();
            }
        }
Example #2
0
        public static Instruction Create(Type type, bool liftedToNull)
        {
            if (liftedToNull)
            {
                switch (type.GetNonNullableType().GetTypeCode())
                {
                case TypeCode.Boolean: return(ExclusiveOrInstruction.Create(type));

                case TypeCode.SByte: return(s_SByteLiftedToNull ?? (s_SByteLiftedToNull = new NotEqualSByteLiftedToNull()));

                case TypeCode.Int16: return(s_Int16LiftedToNull ?? (s_Int16LiftedToNull = new NotEqualInt16LiftedToNull()));

                case TypeCode.Char: return(s_CharLiftedToNull ?? (s_CharLiftedToNull = new NotEqualCharLiftedToNull()));

                case TypeCode.Int32: return(s_Int32LiftedToNull ?? (s_Int32LiftedToNull = new NotEqualInt32LiftedToNull()));

                case TypeCode.Int64: return(s_Int64LiftedToNull ?? (s_Int64LiftedToNull = new NotEqualInt64LiftedToNull()));

                case TypeCode.Byte: return(s_ByteLiftedToNull ?? (s_ByteLiftedToNull = new NotEqualByteLiftedToNull()));

                case TypeCode.UInt16: return(s_UInt16LiftedToNull ?? (s_UInt16LiftedToNull = new NotEqualUInt16LiftedToNull()));

                case TypeCode.UInt32: return(s_UInt32LiftedToNull ?? (s_UInt32LiftedToNull = new NotEqualUInt32LiftedToNull()));

                case TypeCode.UInt64: return(s_UInt64LiftedToNull ?? (s_UInt64LiftedToNull = new NotEqualUInt64LiftedToNull()));

                case TypeCode.Single: return(s_SingleLiftedToNull ?? (s_SingleLiftedToNull = new NotEqualSingleLiftedToNull()));

                default:
                    Debug.Assert(type.GetNonNullableType().GetTypeCode() == TypeCode.Double);
                    return(s_DoubleLiftedToNull ?? (s_DoubleLiftedToNull = new NotEqualDoubleLiftedToNull()));
                }
            }
            else
            {
                switch (type.GetNonNullableType().GetTypeCode())
                {
                case TypeCode.Boolean: return(s_Boolean ?? (s_Boolean = new NotEqualBoolean()));

                case TypeCode.SByte: return(s_SByte ?? (s_SByte = new NotEqualSByte()));

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

                case TypeCode.Char: return(s_Char ?? (s_Char = new NotEqualChar()));

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

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

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

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

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

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

                case TypeCode.Single: return(s_Single ?? (s_Single = new NotEqualSingle()));

                case TypeCode.Double: return(s_Double ?? (s_Double = new NotEqualDouble()));

                default:
                    // Nullable only valid if one operand is constant null, so this assert is slightly too broad.
                    Debug.Assert(type.IsNullableOrReferenceType());
                    return(s_reference ?? (s_reference = new NotEqualReference()));
                }
            }
        }
Example #3
0
 public void EmitExclusiveOr(Type type)
 {
     Emit(ExclusiveOrInstruction.Create(type));
 }