Package com.android.dx.rop.code
Class RegisterSpec
java.lang.Object
com.android.dx.rop.code.RegisterSpec
- All Implemented Interfaces:
TypeBearer
,ToHuman
,Comparable<RegisterSpec>
public final class RegisterSpec
extends Object
implements TypeBearer, ToHuman, Comparable<RegisterSpec>
Combination of a register number and a type, used as the sources and
destinations of register-based operations.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
int
compareTo
(RegisterSpec other) Compares by (in priority order) register number, unwrapped type (that is types notTypeBearer
s, and local info.boolean
boolean
Likeequals
, but only consider the simple types of the registers.final int
Gets the basic type corresponding to this instance's frame type.final int
Gets the basic type corresponding to this instance.int
Gets the category of this instance's type.Gets the frame type corresponding to this type.Gets the variable info associated with this instance, if any.int
Gets the next available register number after the one in this instance.int
getReg()
Gets the register number.getType()
Gets the type associated with this instance.Gets the type (or actual value) which is loaded from or stored to the register associated with this instance.int
hashCode()
intersect
(RegisterSpec other, boolean localPrimary) Returns an instance that is the intersection between this instance and the given one, if any.boolean
Gets whether this instance's type is category 1.boolean
Gets whether this instance's type is category 2.final boolean
Returns whether this instance represents a constant value.boolean
static RegisterSpec
make
(int reg, TypeBearer type) Returns an instance for the given register number and type, with no variable info.static RegisterSpec
make
(int reg, TypeBearer type, LocalItem local) Returns an instance for the given register number, type, and variable info.static RegisterSpec
makeLocalOptional
(int reg, TypeBearer type, LocalItem local) Returns an instance for the given register number, type, and variable info.boolean
matchesVariable
(RegisterSpec other) LikeequalsUsingSimpleType(com.android.dx.rop.code.RegisterSpec)
but ignoring the register number.Gets the string form for just the register number of this instance.static String
regString
(int reg) Gets the string form for the given register number.toHuman()
Return the "human" string form of this instance.toString()
withLocalItem
(LocalItem local) Returns an instance that is identical to this one except that the local variable is as specified in the parameter.withOffset
(int delta) Returns an instance that is identical to this one, except that the register number is offset by the given amount.withReg
(int newReg) Returns an instance that is identical to this one, except that the register number is replaced by the given one.Returns an instance that is identical to this one, except that the type bearer is replaced by the actual underlying type (thereby stripping off non-type information) with any initialization information stripped away as well.withType
(TypeBearer newType) Returns an instance that is identical to this one, except that the type is replaced by the given one.
-
Field Details
-
PREFIX
non-null;
string to prefix register numbers with- See Also:
-
-
Method Details
-
make
Returns an instance for the given register number and type, with no variable info. This method is allowed to return shared instances (but doesn't necessarily do so).- Parameters:
reg
->= 0;
the register numbertype
-non-null;
the type (or possibly actual value) which is loaded from or stored to the indicated register- Returns:
non-null;
an appropriately-constructed instance
-
make
Returns an instance for the given register number, type, and variable info. This method is allowed to return shared instances (but doesn't necessarily do so).- Parameters:
reg
->= 0;
the register numbertype
-non-null;
the type (or possibly actual value) which is loaded from or stored to the indicated registerlocal
-non-null;
the associated local variable- Returns:
non-null;
an appropriately-constructed instance
-
makeLocalOptional
Returns an instance for the given register number, type, and variable info. This method is allowed to return shared instances (but doesn't necessarily do so).- Parameters:
reg
->= 0;
the register numbertype
-non-null;
the type (or possibly actual value) which is loaded from or stored to the indicated registerlocal
-null-ok;
the associated variable info or null for none- Returns:
non-null;
an appropriately-constructed instance
-
regString
Gets the string form for the given register number.- Parameters:
reg
->= 0;
the register number- Returns:
non-null;
the string form
-
equals
-
equalsUsingSimpleType
Likeequals
, but only consider the simple types of the registers. That is, this comparesgetType()
on the types to ignore whatever arbitrary extra stuff might be carried around by an outerTypeBearer
.- Parameters:
other
-null-ok;
spec to compare to- Returns:
true
iffthis
andother
are equal in the stated way
-
matchesVariable
LikeequalsUsingSimpleType(com.android.dx.rop.code.RegisterSpec)
but ignoring the register number. This is useful to determine if two instances refer to the "same" local variable.- Parameters:
other
-null-ok;
spec to compare to- Returns:
true
iffthis
andother
are equal in the stated way
-
compareTo
Compares by (in priority order) register number, unwrapped type (that is types notTypeBearer
s, and local info.- Specified by:
compareTo
in interfaceComparable<RegisterSpec>
- Parameters:
other
-non-null;
spec to compare to- Returns:
-1..1;
standard result of comparison
-
hashCode
public int hashCode() -
toString
-
toHuman
Return the "human" string form of this instance. This is generally less "debuggy" thantoString()
. -
getType
Gets the type associated with this instance.- Specified by:
getType
in interfaceTypeBearer
- Returns:
non-null;
the type
-
getFrameType
Gets the frame type corresponding to this type. This method returnsthis
, except ifType.isIntlike()
on the underlying type returnstrue
but the underlying type is not in factType.INT
, in which case this method returns an instance whose underlying type isINT
.- Specified by:
getFrameType
in interfaceTypeBearer
- Returns:
non-null;
the frame type for this instance
-
getBasicType
public final int getBasicType()Gets the basic type corresponding to this instance.- Specified by:
getBasicType
in interfaceTypeBearer
- Returns:
- the basic type; one of the
BT_*
constants defined byType
-
getBasicFrameType
public final int getBasicFrameType()Gets the basic type corresponding to this instance's frame type. This is equivalent togetFrameType().getBasicType()
, and is the same as callinggetFrameType()
unless this instance is an int-like type, in which case this method returnsBT_INT
.- Specified by:
getBasicFrameType
in interfaceTypeBearer
- Returns:
- the basic frame type; one of the
BT_*
constants defined byType
- See Also:
-
isConstant
public final boolean isConstant()Returns whether this instance represents a constant value.- Specified by:
isConstant
in interfaceTypeBearer
- Returns:
true
if this instance represents a constant value andfalse
if not
-
getReg
public int getReg()Gets the register number.- Returns:
>= 0;
the register number
-
getTypeBearer
Gets the type (or actual value) which is loaded from or stored to the register associated with this instance.- Returns:
non-null;
the type
-
getLocalItem
Gets the variable info associated with this instance, if any.- Returns:
null-ok;
the variable info, ornull
if this instance has none
-
getNextReg
public int getNextReg()Gets the next available register number after the one in this instance. This is equal to the register number plus the width (category) of the type used. Among other things, this may also be used to determine the minimum required register count implied by this instance.- Returns:
>= 0;
the required registers size
-
getCategory
public int getCategory()Gets the category of this instance's type. This is just a convenient shorthand forgetType().getCategory()
.- Returns:
1..2;
the category of this instance's type- See Also:
-
isCategory1
public boolean isCategory1()Gets whether this instance's type is category 1. This is just a convenient shorthand forgetType().isCategory1()
.- Returns:
- whether or not this instance's type is of category 1
- See Also:
-
isCategory2
public boolean isCategory2()Gets whether this instance's type is category 2. This is just a convenient shorthand forgetType().isCategory2()
.- Returns:
- whether or not this instance's type is of category 2
- See Also:
-
regString
Gets the string form for just the register number of this instance.- Returns:
non-null;
the register string form
-
intersect
Returns an instance that is the intersection between this instance and the given one, if any. The intersection is defined as follows:- If
other
isnull
, then the result isnull
. - If the register numbers don't match, then the intersection
is
null
. Otherwise, the register number of the intersection is the same as the one in the two instances. - If the types returned by
getType()
are notequals()
, then the intersection is null. - If the type bearers returned by
getTypeBearer()
areequals()
, then the intersection's type bearer is the one from this instance. Otherwise, the intersection's type bearer is thegetType()
of this instance. - If the locals are
equals()
, then the local info of the intersection is the local info of this instance. Otherwise, the local info of the intersection isnull
.
- Parameters:
other
-null-ok;
instance to intersect with (ornull
)localPrimary
- whether local variables are primary to the intersection; iftrue
, then the only non-null results occur when registers being intersected have equal local infos (or both havenull
local infos)- Returns:
null-ok;
the intersection
- If
-
withReg
Returns an instance that is identical to this one, except that the register number is replaced by the given one.- Parameters:
newReg
->= 0;
the new register number- Returns:
non-null;
an appropriately-constructed instance
-
withType
Returns an instance that is identical to this one, except that the type is replaced by the given one.- Parameters:
newType
-non-null;
the new type- Returns:
non-null;
an appropriately-constructed instance
-
withOffset
Returns an instance that is identical to this one, except that the register number is offset by the given amount.- Parameters:
delta
- the amount to offset the register number by- Returns:
non-null;
an appropriately-constructed instance
-
withSimpleType
Returns an instance that is identical to this one, except that the type bearer is replaced by the actual underlying type (thereby stripping off non-type information) with any initialization information stripped away as well.- Returns:
non-null;
an appropriately-constructed instance
-
withLocalItem
Returns an instance that is identical to this one except that the local variable is as specified in the parameter.- Parameters:
local
-null-ok;
the local item or null for none- Returns:
- an appropriate instance
-
isEvenRegister
public boolean isEvenRegister()- Returns:
- boolean specifying if this instance is an even register or not.
-
clearInternTable
public static void clearInternTable()
-