# Interface: com.pnfsoftware.jeb.core.units.code.android.ir.IDImm

This dual\-purpose `dexdec` IR element serves to encode immediate values \(primitives and pooled strings\) and [evaluated](IDState) 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](IDState)
 

 Examples: 

```

 String s = a == 1 ? "hello": null;
                 ^   ^^^^^^^  ^^^^
 
```

## Method: _add
- parameter: `o`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`

Description: Perform an integer addition.
parameter: o: addend
return: the resulting immediate

## Method: _and
- parameter: `o`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`

Description: Perform a bitwise and operation.
parameter: o: other immediate
return: the resulting immediate

## Method: _cmp
- parameter: `o`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`
- return type: `int`

Description: Perform a signed operand comparison.
parameter: o: other immediate
return: 0, 1, or \-1

## Method: _cmpU
- parameter: `o`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`
- return type: `int`

Description: Perform an unsigned operand comparison.
parameter: o: other immediate
return: 0, 1, or \-1

## Method: _div
- parameter: `o`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`

Description: Perform an integer division.
parameter: o: divisor
return: the resulting immediate

## Method: _isPowerOf2
- return type: `boolean`

Description: Determine whether this immediate \(treated as an unsigned integer\) is a power of 2.
return: true if this immediate is a power of 2

## Method: _log2
- return type: `java.lang.Integer`

Description: 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.
return: a non\-null log2 of this immediate

## Method: _mul
- parameter: `o`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`

Description: Perform an integer multiplication.
parameter: o: multiplier
return: the resulting immediate

## Method: _neg
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`

Description: Perform an integer negation.
return: the resulting immediate

## Method: _not
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`

Description: Perform a bitwise not operation.
return: the resulting immediate

## Method: _or
- parameter: `o`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`

Description: Perform a bitwise or operation.
parameter: o: other immediate
return: the resulting immediate

## Method: _pow
- parameter: `exponent`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`

Description: Perform an exponentiation.
parameter: exponent: must be positive or zero
return: the resulting immediate

## Method: _rem
- parameter: `o`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`

Description: Perform an integer modulo operation.
parameter: o: divisor
return: the resulting immediate

## Method: _sar
- parameter: `cnt`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`

Description: 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.
parameter: cnt: shift count
return: the resulting immediate

## Method: _shl
- parameter: `cnt`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`

Description: Perform a left\-shift operation. The effective count is computed modulo\-positive 32 or 64, depending on the type of this integer.
parameter: cnt: shift count
return: the resulting immediate

## Method: _shr
- parameter: `cnt`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`

Description: Perform a regular right\-shift operation. The effective count is computed modulo\-positive 32 or 64, depending on the type of this integer.
parameter: cnt: shift count
return: the resulting immediate

## Method: _sub
- parameter: `o`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`

Description: Perform an integer subtraction.
parameter: o: subtrahend
return: the resulting immediate

## Method: _testbit
- parameter: `pos`, type: `int`
- return type: `boolean`

Description: Test if a given bit is set.
parameter: pos: bit position
return: true if set, false if unset

## Method: _xor
- parameter: `o`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`

Description: Perform a bitwise xor operation.
parameter: o: other immediate
return: the resulting immediate

## Method: canReadAsLong
- return type: `boolean`

Description: Determine whether this immediate can be read as a long value.
return: true if this immediate can be read as a long value

## Method: duplicate
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`


## Method: duplicateWithDifferentType
- parameter: `type`, type: `com.pnfsoftware.jeb.core.units.code.java.IJavaType`
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDImm`

Description: Duplicate this immediate and assign it a different type.
parameter: type: type of the duplicated immediate; note for String constants: although type update            is allowed, it must be a type implementing `java.lang.CharSequence`
return: the duplicated immediate

## Method: getImmediateAsJavaObject
- parameter: `gctx`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDGlobalContext`
- return type: `java.lang.Object`

Description: 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.
parameter: gctx: global IR context used to resolve pooled strings
return: Java object representation

## Method: getObjectReferenceId
- return type: `int`

Description: Get the reference object id. The value returned by this method is moot unless [#isRef()](#isRef()) is true.
return: object reference id

## Method: getRawValue
- return type: `long`

Description: 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.
return: raw encoded value

## Method: getStringIndex
- return type: `int`

Description: Retrieve the pool index of a pooled string immediate. This method will fail unless [#isString()](#isString()) is `true`.
return: string pool index

## Method: getStringValue
- parameter: `gctx`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDGlobalContext`
- return type: `java.lang.String`

Description: Resolve the pooled string constant to its effective value. This method will throw if this immediate is not [a string constant](#isStringImm()).
parameter: gctx: global IR context used to resolve the string
return: effective string value

## Method: getValueAsLong
- return type: `long`

Description: Read this immediate as a long value.
return: long value

## Method: isNonNullRef
- return type: `boolean`

Description: 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.
return: true if this immediate is a non\-null reference

## Method: isNullRef
- return type: `boolean`

Description: 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.
return: true if this immediate is a null reference

## Method: isOnes
- return type: `boolean`

Description: 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.
return: true if all bits are 1

## Method: isRef
- return type: `boolean`

Description: Determine whether this immediate is a reference. 

 Note: pooled strings are not treated as references by this method.
return: true if this immediate is a reference

## Method: isString
- return type: `boolean`

Description: Determine whether this immediate is a **pooled string**.
return: true if this immediate is a pooled string

## Method: isZero
- return type: `boolean`

Description: 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.
return: true if all bits are 0

## Method: isZeroEquivalent
- return type: `boolean`

Description: 
deprecated: use [#isZero()](#isZero()) instead
return: true if this immediate is equivalent to zero

## Method: maybeNonNullRef
- return type: `boolean`

Description: Determine whether this immediate may be a reference that is not the null reference.
return: true if this immediate may be a non\-null reference

## Method: maybeNullRef
- return type: `boolean`

Description: Determine whether this immediate may be a reference that is the null reference.
return: true if this immediate may be a null reference

## Method: maybeRef
- return type: `boolean`

Description: Determine whether this immediate may be a reference. 

 Note: pooled strings are not treated as references by this method.
return: true if this immediate may be a reference

## Method: toDouble
- return type: `double`

Description: Evaluate this immediate as a double\-precision float. The immediate must be of type `float` or `double`.
return: double value
throws: if the value cannot be read as a double

## Method: toFloat
- return type: `float`

Description: Evaluate this immediate as a single\-precision float. The immediate must be of type `float`.
return: float value
throws: if the value cannot be read as a float

## Method: toLong
- return type: `long`

Description: Evaluate this immediate as a signed long primitive. 

 Note: if this constant is an object reference, the reference id is returned.
return: signed long value
throws: if the value cannot be read as a long

## Method: toLong
- parameter: `treatSregAsInt`, type: `boolean`
- return type: `long`

Description: Evaluate this immediate as a signed long primitive. 

 Note: if this constant is an object reference, the reference id is returned.
parameter: treatSregAsInt: if true, and if this object is typed as a            [single\-slot wildcard](IJavaType#isSingleSlotWildcard()), it is treated as a            signed immediate \(and sign\-extension is applied\)
return: signed long value
throws: if the value cannot be read as a long

## Method: toUnsignedLong
- return type: `long`

Description: Evaluate this immediate as an unsigned long. 

 Note: if this constant is an object reference, the reference id is returned.
return: unsigned long value
throws: the type of this immediate does not permit its resolution             to a long primitive

