Esempio n. 1
0
        public static Instruction Create(Type t)
        {
            if (!t.GetTypeInfo().IsEnum)
            {
                switch (t.GetTypeCode())
                {
                case TypeCode.Boolean: return(s_boolean ?? (s_boolean = new CastInstructionT <bool>()));

                case TypeCode.Byte: return(s_byte ?? (s_byte = new CastInstructionT <byte>()));

                case TypeCode.Char: return(s_char ?? (s_char = new CastInstructionT <char>()));

                case TypeCode.DateTime: return(s_dateTime ?? (s_dateTime = new CastInstructionT <DateTime>()));

                case TypeCode.Decimal: return(s_decimal ?? (s_decimal = new CastInstructionT <decimal>()));

                case TypeCode.Double: return(s_double ?? (s_double = new CastInstructionT <double>()));

                case TypeCode.Int16: return(s_int16 ?? (s_int16 = new CastInstructionT <short>()));

                case TypeCode.Int32: return(s_int32 ?? (s_int32 = new CastInstructionT <int>()));

                case TypeCode.Int64: return(s_int64 ?? (s_int64 = new CastInstructionT <long>()));

                case TypeCode.SByte: return(s_SByte ?? (s_SByte = new CastInstructionT <sbyte>()));

                case TypeCode.Single: return(s_single ?? (s_single = new CastInstructionT <float>()));

                case TypeCode.String: return(s_string ?? (s_string = new CastInstructionT <string>()));

                case TypeCode.UInt16: return(s_UInt16 ?? (s_UInt16 = new CastInstructionT <ushort>()));

                case TypeCode.UInt32: return(s_UInt32 ?? (s_UInt32 = new CastInstructionT <uint>()));

                case TypeCode.UInt64: return(s_UInt64 ?? (s_UInt64 = new CastInstructionT <ulong>()));
                }
            }

            return(CastInstructionNoT.Create(t));
        }
Esempio n. 2
0
        public static Instruction Create(Type t)
        {
            if (!t.GetTypeInfo().IsEnum)
            {
                switch (System.Dynamic.Utils.TypeExtensions.GetTypeCode(t))
                {
                case TypeCode.Boolean: return(s_boolean ?? (s_boolean = new CastInstructionT <Boolean>()));

                case TypeCode.Byte: return(s_byte ?? (s_byte = new CastInstructionT <Byte>()));

                case TypeCode.Char: return(s_char ?? (s_char = new CastInstructionT <Char>()));

                case TypeCode.DateTime: return(s_dateTime ?? (s_dateTime = new CastInstructionT <DateTime>()));

                case TypeCode.Decimal: return(s_decimal ?? (s_decimal = new CastInstructionT <Decimal>()));

                case TypeCode.Double: return(s_double ?? (s_double = new CastInstructionT <Double>()));

                case TypeCode.Int16: return(s_int16 ?? (s_int16 = new CastInstructionT <Int16>()));

                case TypeCode.Int32: return(s_int32 ?? (s_int32 = new CastInstructionT <Int32>()));

                case TypeCode.Int64: return(s_int64 ?? (s_int64 = new CastInstructionT <Int64>()));

                case TypeCode.SByte: return(s_SByte ?? (s_SByte = new CastInstructionT <SByte>()));

                case TypeCode.Single: return(s_single ?? (s_single = new CastInstructionT <Single>()));

                case TypeCode.String: return(s_string ?? (s_string = new CastInstructionT <String>()));

                case TypeCode.UInt16: return(s_UInt16 ?? (s_UInt16 = new CastInstructionT <UInt16>()));

                case TypeCode.UInt32: return(s_UInt32 ?? (s_UInt32 = new CastInstructionT <UInt32>()));

                case TypeCode.UInt64: return(s_UInt64 ?? (s_UInt64 = new CastInstructionT <UInt64>()));
                }
            }

            return(CastInstructionNoT.Create(t));
        }
Esempio n. 3
0
        public static Instruction Create(Type t)
        {
            Debug.Assert(!t.IsEnum);
            switch (Type.GetTypeCode(t))
            {
            case TypeCode.Boolean: return(_boolean ?? (_boolean = new CastInstructionT <bool>()));

            case TypeCode.Byte: return(_byte ?? (_byte = new CastInstructionT <byte>()));

            case TypeCode.Char: return(_char ?? (_char = new CastInstructionT <char>()));

            case TypeCode.DateTime: return(_dateTime ?? (_dateTime = new CastInstructionT <DateTime>()));

            case TypeCode.Decimal: return(_decimal ?? (_decimal = new CastInstructionT <decimal>()));

            case TypeCode.Double: return(_double ?? (_double = new CastInstructionT <double>()));

            case TypeCode.Int16: return(_int16 ?? (_int16 = new CastInstructionT <short>()));

            case TypeCode.Int32: return(_int32 ?? (_int32 = new CastInstructionT <int>()));

            case TypeCode.Int64: return(_int64 ?? (_int64 = new CastInstructionT <long>()));

            case TypeCode.SByte: return(_sByte ?? (_sByte = new CastInstructionT <sbyte>()));

            case TypeCode.Single: return(_single ?? (_single = new CastInstructionT <float>()));

            case TypeCode.String: return(_string ?? (_string = new CastInstructionT <string>()));

            case TypeCode.UInt16: return(_uInt16 ?? (_uInt16 = new CastInstructionT <ushort>()));

            case TypeCode.UInt32: return(_uInt32 ?? (_uInt32 = new CastInstructionT <uint>()));

            case TypeCode.UInt64: return(_uInt64 ?? (_uInt64 = new CastInstructionT <ulong>()));

            default: return(CastInstructionNoT.Create(t));
            }
        }
Esempio n. 4
0
        public static Instruction Create(Type t)
        {
            Debug.Assert(!t.IsEnum);
            return(t.GetTypeCode() switch
            {
                TypeCode.Boolean => s_Boolean ?? (s_Boolean = new CastInstructionT <bool>()),
                TypeCode.Byte => s_Byte ?? (s_Byte = new CastInstructionT <byte>()),
                TypeCode.Char => s_Char ?? (s_Char = new CastInstructionT <char>()),
                TypeCode.DateTime => s_DateTime ?? (s_DateTime = new CastInstructionT <DateTime>()),
                TypeCode.Decimal => s_Decimal ?? (s_Decimal = new CastInstructionT <decimal>()),
                TypeCode.Double => s_Double ?? (s_Double = new CastInstructionT <double>()),
                TypeCode.Int16 => s_Int16 ?? (s_Int16 = new CastInstructionT <short>()),
                TypeCode.Int32 => s_Int32 ?? (s_Int32 = new CastInstructionT <int>()),
                TypeCode.Int64 => s_Int64 ?? (s_Int64 = new CastInstructionT <long>()),
                TypeCode.SByte => s_SByte ?? (s_SByte = new CastInstructionT <sbyte>()),
                TypeCode.Single => s_Single ?? (s_Single = new CastInstructionT <float>()),
                TypeCode.String => s_String ?? (s_String = new CastInstructionT <string>()),
                TypeCode.UInt16 => s_UInt16 ?? (s_UInt16 = new CastInstructionT <ushort>()),
                TypeCode.UInt32 => s_UInt32 ?? (s_UInt32 = new CastInstructionT <uint>()),
                TypeCode.UInt64 => s_UInt64 ?? (s_UInt64 = new CastInstructionT <ulong>()),

                _ => CastInstructionNoT.Create(t),
            });
Esempio n. 5
0
 public void EmitCast(Type toType)
 {
     Emit(CastInstruction.Create(toType));
 }