Interface IDImm
- All Superinterfaces:
IDElement,IDExpression,IInstructionOperand
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;
^ ^^^^^^^ ^^^^
-
Field Summary
Fields inherited from interface com.pnfsoftware.jeb.core.units.code.android.ir.IDElement
DEFAULT_COMPARE_WITH_FULL_EQUALITY -
Method Summary
Modifier and TypeMethodDescriptionPerform an integer addition.Perform a bitwise and operation.intPerform a signed operand comparison.intPerform an unsigned operand comparison.Perform an integer division.booleanDetermine whether this immediate (treated as an unsigned integer) is a power of 2._log2()Perform an exact log2 on this immediate treated as an unsigned integer.Perform an integer multiplication._neg()Perform an integer negation._not()Perform a bitwise not operation.Perform a bitwise or operation._pow(int exponent) Perform an exponentiation.Perform an integer modulo operation._sar(int cnt) Perform an arithmetic right-shift operation (sign bit is maintained)._shl(int cnt) Perform a left-shift operation._shr(int cnt) Perform a regular right-shift operation.Perform an integer subtraction.boolean_testbit(int pos) Test if a given bit is set.Perform a bitwise xor operation.booleanDetermine whether this immediate can be read as a long value.Duplicate this element.Duplicate this immediate and assign it a different type.Resolve this primitive or pooled string immediate to a Java object: either the effectiveStringvalue if it is a string, or one of boxed primitive object type if it is a primitive.intGet the reference object id.longRetrieve the raw value encoded by this immediate.intRetrieve the pool index of a pooled string immediate.Resolve the pooled string constant to its effective value.longRead this immediate as a long value.booleanDetermine whether this immediate is a non-null reference.booleanDetermine whether this immediate is a null reference.booleanisOnes()Determine whether this immediate has all its bits set to 1.booleanisRef()Determine whether this immediate is a reference.booleanisString()Determine whether this immediate is a pooled string.booleanisZero()Determine whether this immediate has all its bits set to 0.booleanDeprecated.booleanDetermine whether this immediate may be a reference that is not the null reference.booleanDetermine whether this immediate may be a reference that is the null reference.booleanmaybeRef()Determine whether this immediate may be a reference.doubletoDouble()Evaluate this immediate as a double-precision float.floattoFloat()Evaluate this immediate as a single-precision float.longtoLong()Evaluate this immediate as a signed long primitive.longtoLong(boolean treatSregAsInt) Evaluate this immediate as a signed long primitive.longEvaluate this immediate as an unsigned long.Methods inherited from interface com.pnfsoftware.jeb.core.units.code.android.ir.IDElement
equalsEx, format, toString, toStringMethods inherited from interface com.pnfsoftware.jeb.core.units.code.android.ir.IDExpression
asArrayElt, asCallInfo, asImm, asInstanceField, asInstruction, asNewArrayInfo, asNewInfo, asOperation, asReferenceType, asStaticField, asVar, canThrow, checkType, collectAllPhysicalMethodIndices, collectAllPhysicalOffsets, collectSubExpressions, collectVarIds, copy, countVariable, evaluate, evaluate, evaluate, find, findByType, findByType, findParent, findParent, generateAST, getCustomCanThrow, getData, getOrigin, getPhysicalMethodIndex, getPhysicalOffset, getSubExpressions, getType, getVarIds, hasSideEffects, isArrayElt, isCallInfo, isCallInfo, isCastOperation, isCastOperation, isConstantImm, isConstantImm, isImm, isInstanceField, isInstruction, isNewArrayInfo, isNewInfo, isOperation, isOperation, isOperation, isOperation, isOperation, isOperation, isOperation, isReferenceType, isStaticField, isStringImm, isVar, isVar, removeData, replaceSubExpression, replaceVariable, setCustomCanThrow, setData, setOrigin, setPhysicalMethodIndex, setPhysicalOffset, setType, setType, setType, spawn, transferMetadataFrom, updateAllPhysicalMethodIndices, updateAllPhysicalOffsets, updateTypes, visitDepthPost, visitDepthPost, visitDepthPost, visitDepthPre, visitDepthPre, visitDepthPreMethods inherited from interface com.pnfsoftware.jeb.core.units.code.IInstructionOperand
format
-
Method Details
-
duplicateWithDifferentType
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 implementingjava.lang.CharSequence- Returns:
- the duplicated immediate
-
isZeroEquivalent
boolean isZeroEquivalent()Deprecated.useisZero()instead- Returns:
- true if this immediate is equivalent to zero
-
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:
- true if all bits are 0
-
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:
- true if all bits are 1
-
isString
boolean isString()Determine whether this immediate is a pooled string.- Returns:
- true if this immediate is a pooled string
-
getStringIndex
int getStringIndex()Retrieve the pool index of a pooled string immediate. This method will fail unlessisString()istrue.- Returns:
- string pool index
-
getStringValue
Resolve the pooled string constant to its effective value. This method will throw if this immediate is nota string constant.- Parameters:
gctx- global IR context used to resolve the string- Returns:
- effective string value
-
getRawValue
long getRawValue()Retrieve the raw value encoded by this immediate. All values (primitives, pool indices, object references) can fit on along; hence this method's return type.- Returns:
- raw encoded value
-
getImmediateAsJavaObject
Resolve this primitive or pooled string immediate to a Java object: either the effectiveStringvalue if it is a string, or one of boxed primitive object type if it is a primitive.- Parameters:
gctx- global IR context used to resolve pooled strings- Returns:
- Java object representation
-
toUnsignedLong
Evaluate this immediate as an unsigned long.Note: if this constant is an object reference, the reference id is returned.
- Returns:
- unsigned long value
- Throws:
DexDecEvaluationException- the type of this immediate does not permit its resolution to a long primitive
-
toLong
Evaluate this immediate as a signed long primitive.Note: if this constant is an object reference, the reference id is returned.
- Returns:
- signed long value
- Throws:
DexDecEvaluationException- if the value cannot be read as a long
-
toLong
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 asingle-slot wildcard, it is treated as a signed immediate (and sign-extension is applied)- Returns:
- signed long value
- Throws:
DexDecEvaluationException- if the value cannot be read as a long
-
toFloat
Evaluate this immediate as a single-precision float. The immediate must be of typefloat.- Returns:
- float value
- Throws:
DexDecEvaluationException- if the value cannot be read as a float
-
toDouble
Evaluate this immediate as a double-precision float. The immediate must be of typefloatordouble.- Returns:
- double value
- Throws:
DexDecEvaluationException- if the value cannot be read as a double
-
isRef
boolean isRef()Determine whether this immediate is a reference.Note: pooled strings are not treated as references by this method.
- Returns:
- true if this immediate is a reference
-
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:
- true if this immediate is a null reference
-
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:
- true if this immediate is a non-null reference
-
maybeRef
boolean maybeRef()Determine whether this immediate may be a reference.Note: pooled strings are not treated as references by this method.
- Returns:
- true if this immediate may be a reference
-
maybeNullRef
boolean maybeNullRef()Determine whether this immediate may be a reference that is the null reference.- Returns:
- true if this immediate may be a null reference
-
maybeNonNullRef
boolean maybeNonNullRef()Determine whether this immediate may be a reference that is not the null reference.- Returns:
- true if this immediate may be a non-null reference
-
getObjectReferenceId
int getObjectReferenceId()Get the reference object id. The value returned by this method is moot unlessisRef()is true.- Returns:
- object reference id
-
duplicate
IDImm duplicate()Description copied from interface:IDElementDuplicate this element.- Specified by:
duplicatein interfaceIDElement- Specified by:
duplicatein interfaceIDExpression- 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()Determine whether this immediate can be read as a long value.- Returns:
- true if this immediate can be read as a long value
-
getValueAsLong
long getValueAsLong()Read this immediate as a long value.- Returns:
- long value
-
_add
Perform an integer addition.- Parameters:
o- addend- Returns:
- the resulting immediate
-
_sub
Perform an integer subtraction.- Parameters:
o- subtrahend- Returns:
- the resulting immediate
-
_mul
Perform an integer multiplication.- Parameters:
o- multiplier- Returns:
- the resulting immediate
-
_div
Perform an integer division.- Parameters:
o- divisor- Returns:
- the resulting immediate
-
_rem
Perform an integer modulo operation.- Parameters:
o- divisor- Returns:
- the resulting immediate
-
_neg
IDImm _neg()Perform an integer negation.- Returns:
- the resulting immediate
-
_not
IDImm _not()Perform a bitwise not operation.- Returns:
- the resulting immediate
-
_and
Perform a bitwise and operation.- Parameters:
o- other immediate- Returns:
- the resulting immediate
-
_or
Perform a bitwise or operation.- Parameters:
o- other immediate- Returns:
- the resulting immediate
-
_xor
Perform a bitwise xor operation.- Parameters:
o- other immediate- Returns:
- the resulting immediate
-
_testbit
boolean _testbit(int pos) Test if a given bit is set.- Parameters:
pos- bit position- Returns:
- true if set, false if unset
-
_shl
Perform a left-shift operation. The effective count is computed modulo-positive 32 or 64, depending on the type of this integer.- Parameters:
cnt- shift count- Returns:
- the resulting immediate
-
_shr
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- shift count- Returns:
- the resulting immediate
-
_sar
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- shift count- Returns:
- the resulting immediate
-
_pow
Perform an exponentiation.- Parameters:
exponent- must be positive or zero- Returns:
- the resulting immediate
-
_cmp
Perform a signed operand comparison.- Parameters:
o- other immediate- Returns:
- 0, 1, or -1
-
_cmpU
Perform an unsigned operand comparison.- Parameters:
o- other immediate- Returns:
- 0, 1, or -1
-
_isPowerOf2
boolean _isPowerOf2()Determine whether this immediate (treated as an unsigned integer) is a power of 2.- Returns:
- true if this immediate is a power of 2
-
_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
-
isZero()instead