com.android.dx.rop.code
Class RegisterSpecSet

java.lang.Object
  extended by com.android.dx.util.MutabilityControl
      extended by com.android.dx.rop.code.RegisterSpecSet

public final class RegisterSpecSet
extends MutabilityControl

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


Field Summary
static RegisterSpecSet EMPTY
          non-null; no-element instance
 
Constructor Summary
RegisterSpecSet(int maxSize)
          Constructs an instance.
 
Method Summary
 boolean equals(Object other)
          
 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.
 RegisterSpec get(int reg)
          Gets the element with the given register number, if any.
 RegisterSpec get(RegisterSpec spec)
          Gets the element with the same register number as the given spec, if any.
 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.
 int hashCode()
          
 void intersect(RegisterSpecSet other, boolean localPrimary)
          Intersects this instance with the given one, modifying this instance.
 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.
 RegisterSpecSet mutableCopy()
          Makes and return a mutable copy of this instance.
 void put(RegisterSpec spec)
          Puts the given spec into the set.
 void putAll(RegisterSpecSet set)
          Put the entire contents of the given set into this one.
 void remove(RegisterSpec toRemove)
          Removes a spec from the set.
 int size()
          Gets the current size of this instance.
 String toString()
          
 RegisterSpecSet withOffset(int delta)
          Returns an instance that is identical to this one, except that all register numbers are offset by the given amount.
 
Methods inherited from class com.android.dx.util.MutabilityControl
isImmutable, isMutable, setImmutable, throwIfImmutable, throwIfMutable
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

public static final RegisterSpecSet EMPTY
non-null; no-element instance

Constructor Detail

RegisterSpecSet

public RegisterSpecSet(int maxSize)
Constructs an instance. The instance is initially empty.

Parameters:
maxSize - >= 0; the maximum register number (exclusive) that may be represented in this instance
Method Detail

equals

public boolean equals(Object other)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

toString

public String toString()

Overrides:
toString in class Object

getMaxSize

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:
>= 0; the maximum size

size

public int size()
Gets the current size of this instance.

Returns:
>= 0; the size

get

public RegisterSpec get(int reg)
Gets the element with the given register number, if any.

Parameters:
reg - >= 0; the desired register number
Returns:
null-ok; the element with the given register number or null if there is none

get

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 - non-null; spec with the desired register number
Returns:
null-ok; the element with the matching register number or null if there is none

findMatchingLocal

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 - non-null; local to look for
Returns:
null-ok; first register found that matches, if any

localItemToSpec

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 - non-null; local item to search for
Returns:
null-ok; first register found with matching name and signature

remove

public void remove(RegisterSpec toRemove)
Removes a spec from the set. Only the register number of the parameter is significant.

Parameters:
toRemove - non-null; register to remove.

put

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 - non-null; the register spec to put in the instance

putAll

public void putAll(RegisterSpecSet set)
Put the entire contents of the given set into this one.

Parameters:
set - non-null; the set to put into this instance

intersect

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(com.android.dx.rop.code.RegisterSpec, boolean) of corresponding elements from this instance and the given one where both are non-null.

Parameters:
other - non-null; set to intersect with
localPrimary - 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)

withOffset

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 - the amount to offset the register numbers by
Returns:
non-null; an appropriately-constructed instance

mutableCopy

public RegisterSpecSet mutableCopy()
Makes and return a mutable copy of this instance.

Returns:
non-null; the mutable copy


Copyright © 2013. All Rights Reserved.