Top Description Fields Constructors Methods
org.droidparts.dexmaker.dx.rop.code

public final Class RegisterSpecSet

extends MutabilityControl
Class Inheritance
Imports
org.droidparts.dexmaker.dx.util.MutabilityControl

Set of RegisterSpec instances, where a given register number may appear only once in the set.

Field Summary

Modifier and TypeField and Description
public static final RegisterSpecSet
EMPTY

non-null; no-element instance

private int
size

>= -1; size of the set or -1 if not yet calculated

private final RegisterSpec[]
specs

non-null; array of register specs, where each element is null or is an instance whose reg matches the array index

Constructor Summary

AccessConstructor and Description
public
RegisterSpecSet(int
>= 0; the maximum register number (exclusive) that may be represented in this instance
maxSize
)

Constructs an instance.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public RegisterSpec

Returns:

null-ok; first register found that matches, if any
findMatchingLocal
(RegisterSpec
non-null; local to look for
spec
)

Returns the spec in this set that's currently associated with a given local (type, name, and signature), or null if there is none.

public RegisterSpec

Returns:

null-ok; the element with the given register number or null if there is none
get
(int
>= 0; the desired register number
reg
)

Gets the element with the given register number, if any.

public RegisterSpec

Returns:

null-ok; the element with the matching register number or null if there is none
get
(RegisterSpec
non-null; spec with the desired register number
spec
)

Gets the element with the same register number as the given spec, if any.

public int

Returns:

>= 0; the maximum size
getMaxSize
()

Gets the maximum number of registers that may be in this instance, which is also the maximum-plus-one of register numbers that may be represented.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public void
intersect(RegisterSpecSet
non-null; set to intersect with
other
,
boolean
whether local variables are primary to the intersection; if true, then the only non-null result elements occur when registers being intersected have equal names (or both have null names)
localPrimary
)

Intersects this instance with the given one, modifying this instance.

public RegisterSpec

Returns:

null-ok; first register found with matching name and signature
localItemToSpec
(LocalItem
non-null; local item to search for
local
)

Returns the spec in this set that's currently associated with a given local (name and signature), or null if there is none.

public RegisterSpecSet

Returns:

non-null; the mutable copy
mutableCopy
()

Makes and return a mutable copy of this instance.

public void
put(RegisterSpec
non-null; the register spec to put in the instance
spec
)

Puts the given spec into the set.

public void
putAll(RegisterSpecSet
non-null; the set to put into this instance
set
)

Put the entire contents of the given set into this one.

public void
remove(RegisterSpec
non-null; register to remove.
toRemove
)

Removes a spec from the set.

public int

Returns:

>= 0; the size
size
()

Gets the current size of this instance.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public RegisterSpecSet

Returns:

non-null; an appropriately-constructed instance
withOffset
(int
the amount to offset the register numbers by
delta
)

Returns an instance that is identical to this one, except that all register numbers are offset by the given amount.

Inherited from org.droidparts.dexmaker.dx.util.MutabilityControl:
isImmutableisMutablesetImmutablethrowIfImmutablethrowIfMutable

Field Detail

EMPTYback to summary
public static final RegisterSpecSet EMPTY

non-null; no-element instance

sizeback to summary
private int size

>= -1; size of the set or -1 if not yet calculated

specsback to summary
private final RegisterSpec[] specs

non-null; array of register specs, where each element is null or is an instance whose reg matches the array index

Constructor Detail

RegisterSpecSetback to summary
public RegisterSpecSet(int maxSize)

Constructs an instance. The instance is initially empty.

Parameters
maxSize:int

>= 0; the maximum register number (exclusive) that may be represented in this instance

Method Detail

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
findMatchingLocalback to summary
public RegisterSpec findMatchingLocal(RegisterSpec spec)

Returns the spec in this set that's currently associated with a given local (type, name, and signature), or null if there is none. This ignores the register number of the given spec but matches on everything else.

Parameters
spec:RegisterSpec

non-null; local to look for

Returns:RegisterSpec

null-ok; first register found that matches, if any

getback to summary
public RegisterSpec get(int reg)

Gets the element with the given register number, if any.

Parameters
reg:int

>= 0; the desired register number

Returns:RegisterSpec

null-ok; the element with the given register number or null if there is none

getback to summary
public RegisterSpec get(RegisterSpec spec)

Gets the element with the same register number as the given spec, if any. This is just a convenient shorthand for get(spec.getReg()).

Parameters
spec:RegisterSpec

non-null; spec with the desired register number

Returns:RegisterSpec

null-ok; the element with the matching register number or null if there is none

getMaxSizeback to summary
public int getMaxSize()

Gets the maximum number of registers that may be in this instance, which is also the maximum-plus-one of register numbers that may be represented.

Returns:int

>= 0; the maximum size

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
intersectback to summary
public void intersect(RegisterSpecSet other, boolean localPrimary)

Intersects this instance with the given one, modifying this instance. The intersection consists of the pairwise RegisterSpec#intersect of corresponding elements from this instance and the given one where both are non-null.

Parameters
other:RegisterSpecSet

non-null; set to intersect with

localPrimary:boolean

whether local variables are primary to the intersection; if true, then the only non-null result elements occur when registers being intersected have equal names (or both have null names)

localItemToSpecback to summary
public RegisterSpec localItemToSpec(LocalItem local)

Returns the spec in this set that's currently associated with a given local (name and signature), or null if there is none.

Parameters
local:LocalItem

non-null; local item to search for

Returns:RegisterSpec

null-ok; first register found with matching name and signature

mutableCopyback to summary
public RegisterSpecSet mutableCopy()

Makes and return a mutable copy of this instance.

Returns:RegisterSpecSet

non-null; the mutable copy

putback to summary
public void put(RegisterSpec spec)

Puts the given spec into the set. If there is already an element in the set with the same register number, it is replaced. Additionally, if the previous element is for a category-2 register, then that previous element is nullified. Finally, if the given spec is for a category-2 register, then the immediately subsequent element is nullified.

Parameters
spec:RegisterSpec

non-null; the register spec to put in the instance

putAllback to summary
public void putAll(RegisterSpecSet set)

Put the entire contents of the given set into this one.

Parameters
set:RegisterSpecSet

non-null; the set to put into this instance

removeback to summary
public void remove(RegisterSpec toRemove)

Removes a spec from the set. Only the register number of the parameter is significant.

Parameters
toRemove:RegisterSpec

non-null; register to remove.

sizeback to summary
public int size()

Gets the current size of this instance.

Returns:int

>= 0; the size

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
withOffsetback to summary
public RegisterSpecSet withOffset(int delta)

Returns an instance that is identical to this one, except that all register numbers are offset by the given amount. Mutability of the result is inherited from the original.

Parameters
delta:int

the amount to offset the register numbers by

Returns:RegisterSpecSet

non-null; an appropriately-constructed instance