All Superinterfaces:
IDElement, IDExpression, IInstructionOperand

public interface IDImm extends IDExpression
This dual-purpose dexdec IR element serves to encode immediate values (primitives and pooled strings) and evaluated values (primitives and objects).

They can be:
- primitives
- null objects
- pooled java.lang.String objects
- references to live objects (including arrays) living in an IR state

Examples:

 String s = a == 1 ? "hello": null;
                 ^   ^^^^^^^  ^^^^
 
  • Method Details

    • duplicateWithDifferentType

      IDImm duplicateWithDifferentType(IJavaType type)
      Duplicate this immediate and assign it a different type.
      Parameters:
      type - type of the duplicated immediate; note for String constants: although type update is allowed, it must be a type implementing java.lang.CharSequence
      Returns:
      the duplicated immediate
    • isZeroEquivalent

      boolean isZeroEquivalent()
      Determine whether the immediate encodes zero (e.g. integer/float:0, boolean:false, ref:null). Same as isZero().
      Returns:
    • isZero

      boolean isZero()
      Determine whether this immediate has all its bits set to 0.

      Note: do not mix this up with a zero-value equality check. That works if the underlying value is to be interpreted as an 2-complement integer, but may not work if the imm is to be understood as an ieee754 float value, for example.

      Returns:
    • isOnes

      boolean isOnes()
      Determine whether this immediate has all its bits set to 1.

      Note: do not mix this up with a zero-value equality check. That works if the underlying value is to be interpreted as an 2-complement integer, but may not work if the imm is to be understood as an ieee754 float value, for example.

      Returns:
    • isString

      boolean isString()
      Determine whether this immediate is a pooled string.
      Returns:
    • getStringIndex

      int getStringIndex()
      Retrieve the pool index of a pooled string immediate. This method will fail unless isString() is true.
      Returns:
    • getStringValue

      String getStringValue(IDGlobalContext gctx)
      Resolve the pooled string constant to its effective value. This method will throw if this immediate is not a string constant.
      Parameters:
      gctx -
      Returns:
    • getRawValue

      long getRawValue()
      Retrieve the raw value encoded by this immediate. All values (primitives, pool indices, object references) can fit on a long; hence this method's return type.
      Returns:
    • getImmediateAsJavaObject

      Object getImmediateAsJavaObject(IDGlobalContext gctx)
      Resolve this primitive or pooled string immediate to a Java object: either the effective String value if it is a string, or one of boxed primitive object type if it is a primitive.
      Parameters:
      gctx -
      Returns:
    • toUnsignedLong

      long toUnsignedLong() throws DexDecEvaluationException
      Evaluate this immediate as an unsigned long.

      Note: if this constant is an object reference, the reference id is returned.

      Returns:
      Throws:
      DexDecEvaluationException - the type of this immediate does not permit its resolution to a long primitive
    • toLong

      long toLong() throws DexDecEvaluationException
      Evaluate this immediate as a signed long primitive.

      Note: if this constant is an object reference, the reference id is returned.

      Returns:
      Throws:
      DexDecEvaluationException
    • toLong

      long toLong(boolean treatSregAsInt) throws DexDecEvaluationException
      Evaluate this immediate as a signed long primitive.

      Note: if this constant is an object reference, the reference id is returned.

      Parameters:
      treatSregAsInt - if true, and if this object is typed as a single-slot wildcard, it is treated as a signed immediate (and sign-extension is applied)
      Returns:
      Throws:
      DexDecEvaluationException
    • toFloat

      float toFloat() throws DexDecEvaluationException
      Evaluate this immediate as a single-precision float. The immediate must be of type float.
      Returns:
      Throws:
      DexDecEvaluationException
    • toDouble

      double toDouble() throws DexDecEvaluationException
      Evaluate this immediate as a double-precision float. The immediate must be of type float or double.
      Returns:
      Throws:
      DexDecEvaluationException
    • isRef

      boolean isRef()
      Determine whether this immediate is a reference.

      Note: pooled strings are not treated as references by this method.

      Returns:
    • isNullRef

      boolean isNullRef()
      Determine whether this immediate is a null reference. Beware: if the immediate is not typed as an object, this method will return false in all case.
      Returns:
    • isNonNullRef

      boolean isNonNullRef()
      Determine whether this immediate is a non-null reference. Beware: if the immediate is not typed as an object, this method will return false in all case.
      Returns:
    • maybeRef

      boolean maybeRef()
      Determine whether this immediate may be a reference.

      Note: pooled strings are not treated as references by this method.

      Returns:
    • maybeNullRef

      boolean maybeNullRef()
      Determine whether this immediate may be a reference that is the null reference.
      Returns:
    • maybeNonNullRef

      boolean maybeNonNullRef()
      Determine whether this immediate may be a reference that is not the null reference.
      Returns:
    • getObjectReferenceId

      int getObjectReferenceId()
      Get the reference object id. The value returned by this method is moot unless isRef() is true.
      Returns:
    • duplicate

      IDImm duplicate()
      Description copied from interface: IDElement
      Duplicate this element.
      Specified by:
      duplicate in interface IDElement
      Specified by:
      duplicate in interface IDExpression
      Returns:
      a deep copy of this element; the type of the duplicated element should be the same as this element's type
    • canReadAsLong

      boolean canReadAsLong()
      Returns:
    • getValueAsLong

      long getValueAsLong()
      Returns:
    • _add

      IDImm _add(IDImm o)
      Perform an integer addition.
      Parameters:
      o -
      Returns:
    • _sub

      IDImm _sub(IDImm o)
      Perform an integer subtraction.
      Parameters:
      o -
      Returns:
    • _mul

      IDImm _mul(IDImm o)
      Perform an integer multiplication.
      Parameters:
      o -
      Returns:
    • _div

      IDImm _div(IDImm o)
      Perform an integer division.
      Parameters:
      o -
      Returns:
    • _rem

      IDImm _rem(IDImm o)
      Perform an integer modulo operation.
      Parameters:
      o -
      Returns:
    • _neg

      IDImm _neg()
      Perform an integer negation.
      Parameters:
      o -
      Returns:
    • _not

      IDImm _not()
      Perform a bitwise not operation.
      Parameters:
      o -
      Returns:
    • _and

      IDImm _and(IDImm o)
      Perform a bitwise and operation.
      Parameters:
      o -
      Returns:
    • _or

      IDImm _or(IDImm o)
      Perform a bitwise or operation.
      Parameters:
      o -
      Returns:
    • _xor

      IDImm _xor(IDImm o)
      Perform a bitwise xor operation.
      Parameters:
      o -
      Returns:
    • _testbit

      boolean _testbit(int pos)
      Test if a given bit is set.
      Parameters:
      pos -
      Returns:
      true if set, false if unset
    • _shl

      IDImm _shl(int cnt)
      Perform a left-shift operation. The effective count is computed modulo-positive 32 or 64, depending on the type of this integer.
      Parameters:
      cnt -
      Returns:
    • _shr

      IDImm _shr(int cnt)
      Perform a regular right-shift operation. The effective count is computed modulo-positive 32 or 64, depending on the type of this integer.
      Parameters:
      cnt -
      Returns:
    • _sar

      IDImm _sar(int cnt)
      Perform an arithmetic right-shift operation (sign bit is maintained). The effective count is computed modulo-positive 32 or 64, depending on the type of this integer.
      Parameters:
      cnt -
      Returns:
    • _pow

      IDImm _pow(int exponent)
      Perform an exponentiation.
      Parameters:
      exponent - must be positive or zero
      Returns:
    • _cmp

      int _cmp(IDImm o)
      Perform a signed operand comparison.
      Parameters:
      o -
      Returns:
      0, 1, or -1
    • _cmpU

      int _cmpU(IDImm o)
      Perform an unsigned operand comparison.
      Parameters:
      o -
      Returns:
      0, 1, or -1
    • _isPowerOf2

      boolean _isPowerOf2()
      Determine whether this immediate (treated as an unsigned integer) is a power of 2.
      Returns:
    • _log2

      Integer _log2()
      Perform an exact log2 on this immediate treated as an unsigned integer. If the immediate is not a power of 2, a null value is returned.
      Returns:
      a non-null log2 of this immediate