コード例 #1
0
        public static Instruction Create(Type type)
        {
            Debug.Assert(!type.IsEnum);
            switch (type.GetNonNullableType().GetTypeCode())
            {
            case TypeCode.SByte: return(s_SByte ?? (s_SByte = new OnesComplementSByte()));

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

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

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

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

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

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

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

            default:
                throw Error.ExpressionNotSupportedForType("OnesComplement", type);
            }
        }
コード例 #2
0
 public static Instruction Create(Type type)
 {
     Debug.Assert(!type.GetTypeInfo().IsEnum);
     switch (type.GetNonNullableType().GetTypeCode())
     {
         case TypeCode.SByte: return s_SByte ?? (s_SByte = new OnesComplementSByte());
         case TypeCode.Int16: return s_Int16 ?? (s_Int16 = new OnesComplementInt16());
         case TypeCode.Int32: return s_Int32 ?? (s_Int32 = new OnesComplementInt32());
         case TypeCode.Int64: return s_Int64 ?? (s_Int64 = new OnesComplementInt64());
         case TypeCode.Byte: return s_Byte ?? (s_Byte = new OnesComplementByte());
         case TypeCode.UInt16: return s_UInt16 ?? (s_UInt16 = new OnesComplementUInt16());
         case TypeCode.UInt32: return s_UInt32 ?? (s_UInt32 = new OnesComplementUInt32());
         case TypeCode.UInt64: return s_UInt64 ?? (s_UInt64 = new OnesComplementUInt64());
         default:
             throw Error.ExpressionNotSupportedForType("OnesComplement", type);
     }
 }