Methods Summary |
---|
public int | compareTo(com.android.dexgen.rop.code.RegisterSpec other)Compares by (in priority order) register number, unwrapped type
(that is types not {@link TypeBearer}s, and local info.
if (this.reg < other.reg) {
return -1;
} else if (this.reg > other.reg) {
return 1;
}
int compare = type.getType().compareTo(other.type.getType());
if (compare != 0) {
return compare;
}
if (this.local == null) {
return (other.local == null) ? 0 : -1;
} else if (other.local == null) {
return 1;
}
return this.local.compareTo(other.local);
|
private boolean | equals(int reg, com.android.dexgen.rop.type.TypeBearer type, LocalItem local)Helper for {@link #equals} and {@link #ForComparison.equals},
which actually does the test.
return (this.reg == reg)
&& this.type.equals(type)
&& ((this.local == local)
|| ((this.local != null) && this.local.equals(local)));
|
public boolean | equals(java.lang.Object other){@inheritDoc}
if (!(other instanceof RegisterSpec)) {
if (other instanceof ForComparison) {
ForComparison fc = (ForComparison) other;
return equals(fc.reg, fc.type, fc.local);
}
return false;
}
RegisterSpec spec = (RegisterSpec) other;
return equals(spec.reg, spec.type, spec.local);
|
public boolean | equalsUsingSimpleType(com.android.dexgen.rop.code.RegisterSpec other)Like {@code equals}, but only consider the simple types of the
registers. That is, this compares {@code getType()} on the types
to ignore whatever arbitrary extra stuff might be carried around
by an outer {@link TypeBearer}.
if (!matchesVariable(other)) {
return false;
}
return (reg == other.reg);
|
public final int | getBasicFrameType(){@inheritDoc}
return type.getBasicFrameType();
|
public final int | getBasicType(){@inheritDoc}
return type.getBasicType();
|
public int | getCategory()Gets the category of this instance's type. This is just a convenient
shorthand for {@code getType().getCategory()}.
return type.getType().getCategory();
|
public com.android.dexgen.rop.type.TypeBearer | getFrameType(){@inheritDoc}
return type.getFrameType();
|
public LocalItem | getLocalItem()Gets the variable info associated with this instance, if any.
return local;
|
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.
return reg + getCategory();
|
public int | getReg()Gets the register number.
return reg;
|
public com.android.dexgen.rop.type.Type | getType(){@inheritDoc}
return type.getType();
|
public com.android.dexgen.rop.type.TypeBearer | getTypeBearer()Gets the type (or actual value) which is loaded from or stored
to the register associated with this instance.
return type;
|
public int | hashCode(){@inheritDoc}
return hashCodeOf(reg, type, local);
|
private static int | hashCodeOf(int reg, com.android.dexgen.rop.type.TypeBearer type, LocalItem local)Helper for {@link #hashCode} and {@link #ForComparison.hashCode},
which actually does the calculation.
int hash = (local != null) ? local.hashCode() : 0;
hash = (hash * 31 + type.hashCode()) * 31 + reg;
return hash;
|
private static com.android.dexgen.rop.code.RegisterSpec | intern(int reg, com.android.dexgen.rop.type.TypeBearer type, LocalItem local)Intern the given triple as an instance of this class.
theInterningItem.set(reg, type, local);
RegisterSpec found = theInterns.get(theInterningItem);
if (found != null) {
return found;
}
found = theInterningItem.toRegisterSpec();
theInterns.put(found, found);
return found;
|
public com.android.dexgen.rop.code.RegisterSpec | intersect(com.android.dexgen.rop.code.RegisterSpec other, boolean localPrimary)Returns an instance that is the intersection between this instance
and the given one, if any. The intersection is defined as follows:
- If {@code other} is {@code null}, then the result
is {@code null}.
- If the register numbers don't match, then the intersection
is {@code null}. Otherwise, the register number of the
intersection is the same as the one in the two instances.
- If the types returned by {@code getType()} are not
{@code equals()}, then the intersection is null.
- If the type bearers returned by {@code getTypeBearer()}
are {@code equals()}, then the intersection's type bearer
is the one from this instance. Otherwise, the intersection's
type bearer is the {@code getType()} of this instance.
- If the locals are {@code equals()}, then the local info
of the intersection is the local info of this instance. Otherwise,
the local info of the intersection is {@code null}.
if (this == other) {
// Easy out.
return this;
}
if ((other == null) || (reg != other.getReg())) {
return null;
}
LocalItem resultLocal =
((local == null) || !local.equals(other.getLocalItem()))
? null : local;
boolean sameName = (resultLocal == local);
if (localPrimary && !sameName) {
return null;
}
Type thisType = getType();
Type otherType = other.getType();
// Note: Types are always interned.
if (thisType != otherType) {
return null;
}
TypeBearer resultTypeBearer =
type.equals(other.getTypeBearer()) ? type : thisType;
if ((resultTypeBearer == type) && sameName) {
// It turns out that the intersection is "this" after all.
return this;
}
return (resultLocal == null) ? make(reg, resultTypeBearer) :
make(reg, resultTypeBearer, resultLocal);
|
public boolean | isCategory1()Gets whether this instance's type is category 1. This is just a
convenient shorthand for {@code getType().isCategory1()}.
return type.getType().isCategory1();
|
public boolean | isCategory2()Gets whether this instance's type is category 2. This is just a
convenient shorthand for {@code getType().isCategory2()}.
return type.getType().isCategory2();
|
public final boolean | isConstant(){@inheritDoc}
return false;
|
public static com.android.dexgen.rop.code.RegisterSpec | make(int reg, com.android.dexgen.rop.type.TypeBearer type)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).
return intern(reg, type, null);
|
public static com.android.dexgen.rop.code.RegisterSpec | make(int reg, com.android.dexgen.rop.type.TypeBearer type, LocalItem local)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).
if (local == null) {
throw new NullPointerException("local == null");
}
return intern(reg, type, local);
|
public static com.android.dexgen.rop.code.RegisterSpec | makeLocalOptional(int reg, com.android.dexgen.rop.type.TypeBearer type, LocalItem local)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).
return intern(reg, type, local);
|
public boolean | matchesVariable(com.android.dexgen.rop.code.RegisterSpec other)Like {@link #equalsUsingSimpleType} but ignoring the register number.
This is useful to determine if two instances refer to the "same"
local variable.
if (other == null) {
return false;
}
return type.getType().equals(other.type.getType())
&& ((local == other.local)
|| ((local != null) && local.equals(other.local)));
|
public java.lang.String | regString()Gets the string form for just the register number of this instance.
return regString(reg);
|
public static java.lang.String | regString(int reg)Gets the string form for the given register number.
return PREFIX + reg;
|
public java.lang.String | toHuman(){@inheritDoc}
return toString0(true);
|
public java.lang.String | toString(){@inheritDoc}
return toString0(false);
|
private java.lang.String | toString0(boolean human)Helper for {@link #toString} and {@link #toHuman}.
StringBuffer sb = new StringBuffer(40);
sb.append(regString());
sb.append(":");
if (local != null) {
sb.append(local.toString());
}
Type justType = type.getType();
sb.append(justType);
if (justType != type) {
sb.append("=");
if (human && (type instanceof Constant)) {
sb.append(((Constant) type).toHuman());
} else {
sb.append(type);
}
}
return sb.toString();
|
public com.android.dexgen.rop.code.RegisterSpec | withLocalItem(LocalItem local)Returns an instance that is identical to this one except that the
local variable is as specified in the parameter.
if ((this.local== local)
|| ((this.local != null) && this.local.equals(local))) {
return this;
}
return makeLocalOptional(reg, type, local);
|
public com.android.dexgen.rop.code.RegisterSpec | withOffset(int delta)Returns an instance that is identical to this one, except that the
register number is offset by the given amount.
if (delta == 0) {
return this;
}
return withReg(reg + delta);
|
public com.android.dexgen.rop.code.RegisterSpec | withReg(int newReg)Returns an instance that is identical to this one, except that the
register number is replaced by the given one.
if (reg == newReg) {
return this;
}
return makeLocalOptional(newReg, type, local);
|
public com.android.dexgen.rop.code.RegisterSpec | 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.
TypeBearer orig = type;
Type newType;
if (orig instanceof Type) {
newType = (Type) orig;
} else {
newType = orig.getType();
}
if (newType.isUninitialized()) {
newType = newType.getInitializedType();
}
if (newType == orig) {
return this;
}
return makeLocalOptional(reg, newType, local);
|
public com.android.dexgen.rop.code.RegisterSpec | withType(com.android.dexgen.rop.type.TypeBearer newType)Returns an instance that is identical to this one, except that
the type is replaced by the given one.
return makeLocalOptional(reg, newType, local);
|