Ejemplo n.º 1
0
        /// <summary>
        /// Gets the box information for the given type.
        /// </summary>
        private static BoxInfo Get(XTypeReference type)
        {
            var info = Infos.FirstOrDefault(x => type.Is(x.metadataType));

            if (info != null)
            {
                return(info);
            }
            throw new ArgumentException(string.Format("No box information for for type {0}", type.FullName));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Does the type require a non-object register in Dex?
 /// </summary>
 public static bool IsDexValue(this XTypeReference type)
 {
     // Check most likely case
     if (type.Is(XTypeReferenceKind.Byte, XTypeReferenceKind.SByte, XTypeReferenceKind.Bool, XTypeReferenceKind.Char,
                 XTypeReferenceKind.Short, XTypeReferenceKind.UShort,
                 XTypeReferenceKind.Int, XTypeReferenceKind.UInt, XTypeReferenceKind.Float,
                 XTypeReferenceKind.IntPtr, XTypeReferenceKind.UIntPtr))
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 3
0
        private static bool CanPullComparisonUp(AstCode code, XTypeReference arg1, XTypeReference arg2, PullTarget target)
        {
            if (arg1 == null || arg2 == null)
            {
                return(false);
            }

            bool isReference = arg1.IsDexObject() && arg1.IsDexObject();

            if (!isReference && !arg1.IsSame(arg2))
            {
                return(false);
            }

            if (target == PullTarget.Comparison)
            {
                return(true);
            }

            if (arg1.Is(XTypeReferenceKind.Float))
            {
                return(false);
            }
            if (arg1.IsDexWide())
            {
                return(false);
            }

            bool isEq = IsEqualsBranchOrComparison(code);

            if (isEq)
            {
                return(true);
            }


            bool isUnsigned = arg1.IsUInt16() || arg1.IsUInt32(); // TODO: check if we really have to exclude unsigned.

            if (isReference || isUnsigned)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Does the type require a boolean instruction in Dex?
 /// </summary>
 public static bool IsDexShort(this XTypeReference type)
 {
     return(type.Is(XTypeReferenceKind.Short, XTypeReferenceKind.UShort));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Does the type require a boolean instruction in Dex?
 /// </summary>
 public static bool IsDexChar(this XTypeReference type)
 {
     return(type.Is(XTypeReferenceKind.Char));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Does the type require a boolean instruction in Dex?
 /// </summary>
 public static bool IsDexByte(this XTypeReference type)
 {
     return(type.Is(XTypeReferenceKind.Byte, XTypeReferenceKind.SByte));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Does the type require a boolean instruction in Dex?
 /// </summary>
 public static bool IsDexBoolean(this XTypeReference type)
 {
     return(type.Is(XTypeReferenceKind.Bool));
 }