Methods Summary |
---|
public boolean | equals(java.lang.Object other){@inheritDoc}
if (!(other instanceof RegisterSpecSet)) {
return false;
}
RegisterSpecSet otherSet = (RegisterSpecSet) other;
RegisterSpec[] otherSpecs = otherSet.specs;
int len = specs.length;
if ((len != otherSpecs.length) || (size() != otherSet.size())) {
return false;
}
for (int i = 0; i < len; i++) {
RegisterSpec s1 = specs[i];
RegisterSpec s2 = otherSpecs[i];
if (s1 == s2) {
continue;
}
if ((s1 == null) || !s1.equals(s2)) {
return false;
}
}
return true;
|
public RegisterSpec | findMatchingLocal(RegisterSpec spec)Returns the spec in this set that's currently associated with a
given local (type, name, and signature), or {@code null} if there is
none. This ignores the register number of the given spec but
matches on everything else.
int length = specs.length;
for (int reg = 0; reg < length; reg++) {
RegisterSpec s = specs[reg];
if (s == null) {
continue;
}
if (spec.matchesVariable(s)) {
return s;
}
}
return null;
|
public RegisterSpec | get(int reg)Gets the element with the given register number, if any.
try {
return specs[reg];
} catch (ArrayIndexOutOfBoundsException ex) {
// Translate the exception.
throw new IllegalArgumentException("bogus reg");
}
|
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
{@code get(spec.getReg())}.
return get(spec.getReg());
|
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.
return specs.length;
|
public int | hashCode(){@inheritDoc}
int len = specs.length;
int hash = 0;
for (int i = 0; i < len; i++) {
RegisterSpec spec = specs[i];
int oneHash = (spec == null) ? 0 : spec.hashCode();
hash = (hash * 31) + oneHash;
}
return hash;
|
public void | intersect(com.android.dexgen.rop.code.RegisterSpecSet other, boolean localPrimary)Intersects this instance with the given one, modifying this
instance. The intersection consists of the pairwise
{@link RegisterSpec#intersect} of corresponding elements from
this instance and the given one where both are non-null.
throwIfImmutable();
RegisterSpec[] otherSpecs = other.specs;
int thisLen = specs.length;
int len = Math.min(thisLen, otherSpecs.length);
size = -1;
for (int i = 0; i < len; i++) {
RegisterSpec spec = specs[i];
if (spec == null) {
continue;
}
RegisterSpec intersection =
spec.intersect(otherSpecs[i], localPrimary);
if (intersection != spec) {
specs[i] = intersection;
}
}
for (int i = len; i < thisLen; i++) {
specs[i] = null;
}
|
public RegisterSpec | localItemToSpec(LocalItem local)Returns the spec in this set that's currently associated with a given
local (name and signature), or {@code null} if there is none.
int length = specs.length;
for (int reg = 0; reg < length; reg++) {
RegisterSpec spec = specs[reg];
if ((spec != null) && local.equals(spec.getLocalItem())) {
return spec;
}
}
return null;
|
public com.android.dexgen.rop.code.RegisterSpecSet | mutableCopy()Makes and return a mutable copy of this instance.
int len = specs.length;
RegisterSpecSet copy = new RegisterSpecSet(len);
for (int i = 0; i < len; i++) {
RegisterSpec spec = specs[i];
if (spec != null) {
copy.put(spec);
}
}
copy.size = size;
return copy;
|
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.
throwIfImmutable();
if (spec == null) {
throw new NullPointerException("spec == null");
}
size = -1;
try {
int reg = spec.getReg();
specs[reg] = spec;
if (reg > 0) {
int prevReg = reg - 1;
RegisterSpec prevSpec = specs[prevReg];
if ((prevSpec != null) && (prevSpec.getCategory() == 2)) {
specs[prevReg] = null;
}
}
if (spec.getCategory() == 2) {
specs[reg + 1] = null;
}
} catch (ArrayIndexOutOfBoundsException ex) {
// Translate the exception.
throw new IllegalArgumentException("spec.getReg() out of range");
}
|
public void | putAll(com.android.dexgen.rop.code.RegisterSpecSet set)Put the entire contents of the given set into this one.
int max = set.getMaxSize();
for (int i = 0; i < max; i++) {
RegisterSpec spec = set.get(i);
if (spec != null) {
put(spec);
}
}
|
public void | remove(RegisterSpec toRemove)Removes a spec from the set. Only the register number
of the parameter is significant.
try {
specs[toRemove.getReg()] = null;
size = -1;
} catch (ArrayIndexOutOfBoundsException ex) {
// Translate the exception.
throw new IllegalArgumentException("bogus reg");
}
|
public int | size()Gets the current size of this instance.
int result = size;
if (result < 0) {
int len = specs.length;
result = 0;
for (int i = 0; i < len; i++) {
if (specs[i] != null) {
result++;
}
}
size = result;
}
return result;
|
public java.lang.String | toString(){@inheritDoc}
int len = specs.length;
StringBuffer sb = new StringBuffer(len * 25);
sb.append('{");
boolean any = false;
for (int i = 0; i < len; i++) {
RegisterSpec spec = specs[i];
if (spec != null) {
if (any) {
sb.append(", ");
} else {
any = true;
}
sb.append(spec);
}
}
sb.append('}");
return sb.toString();
|
public com.android.dexgen.rop.code.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.
int len = specs.length;
RegisterSpecSet result = new RegisterSpecSet(len + delta);
for (int i = 0; i < len; i++) {
RegisterSpec spec = specs[i];
if (spec != null) {
result.put(spec.withOffset(delta));
}
}
result.size = size;
if (isImmutable()) {
result.setImmutable();
}
return result;
|