Beispiel #1
0
        // Returns true of the two types are equivalent primitive types. Used by array casts.
        private static bool ArePrimitveTypesEquivalentSize(TypeDesc type1, TypeDesc type2)
        {
            Debug.Assert(type1.IsPrimitive && type2.IsPrimitive);

            // Primitive types such as E_T_I4 and E_T_U4 are interchangeable
            // Enums with interchangeable underlying types are interchangable
            // BOOL is NOT interchangeable with I1/U1, neither CHAR -- with I2/U2
            // Float and double are not interchangable here.

            int sourcePrimitiveTypeEquivalenceSize = type1.GetIntegralTypeMatchSize();

            // Quick check to see if the first type can be matched.
            if (sourcePrimitiveTypeEquivalenceSize == 0)
            {
                return(false);
            }

            int targetPrimitiveTypeEquivalenceSize = type2.GetIntegralTypeMatchSize();

            return(sourcePrimitiveTypeEquivalenceSize == targetPrimitiveTypeEquivalenceSize);
        }
Beispiel #2
0
        // Returns true of the two types are equivalent primitive types. Used by array casts.
        static private bool ArePrimitveTypesEquivalentSize(TypeDesc type1, TypeDesc type2)
        {
            Debug.Assert(type1.IsPrimitive && type2.IsPrimitive);

            // Primitive types such as E_T_I4 and E_T_U4 are interchangeable
            // Enums with interchangeable underlying types are interchangable
            // BOOL is NOT interchangeable with I1/U1, neither CHAR -- with I2/U2
            // Float and double are not interchangable here.

            int sourcePrimitiveTypeEquivalenceSize = type1.GetIntegralTypeMatchSize();

            // Quick check to see if the first type can be matched.
            if (sourcePrimitiveTypeEquivalenceSize == 0)
            {
                return false;
            }

            int targetPrimitiveTypeEquivalenceSize = type2.GetIntegralTypeMatchSize();

            return sourcePrimitiveTypeEquivalenceSize == targetPrimitiveTypeEquivalenceSize;
        }