Ejemplo n.º 1
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.º 2
0
 /// <summary>
 /// Generate an Move_result opcode.
 /// </summary>
 internal static RCode MoveResult(this XTypeReference type)
 {
     if (type.IsDexWide())
     {
         return(RCode.Move_result_wide);
     }
     if (type.IsVoid())
     {
         throw new ArgumentException("Unexpected void expression type");
     }
     if (type.IsDexValue())
     {
         return(RCode.Move_result);
     }
     if (type.IsDexObject())
     {
         return(RCode.Move_result_object);
     }
     throw new ArgumentException("Unknown type in move_result " + type);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Generate a iput opcode.
 /// </summary>
 internal static RCode IPut(this XTypeReference type)
 {
     if (type.IsDexWide())
     {
         return(RCode.Iput_wide);
     }
     if (type.IsVoid())
     {
         throw new ArgumentException("Unexpected void expression type");
     }
     if (type.IsDexBoolean())
     {
         return(RCode.Iput_boolean);
     }
     if (type.IsDexChar())
     {
         return(RCode.Iput_char);
     }
     if (type.IsDexShort())
     {
         return(RCode.Iput_short);
     }
     if (type.IsDexByte())
     {
         return(RCode.Iput_byte);
     }
     if (type.IsDexValue())
     {
         return(RCode.Iput);
     }
     if (type.IsDexObject())
     {
         return(RCode.Iput_object);
     }
     throw new ArgumentException("Unknown type in iput " + type);
 }