Methods Summary |
---|
public void | annotate(com.android.dex.util.ExceptionWithContext ex)
ex.addContext("(locals array set; primary)");
primary.annotate(ex);
int sz = secondaries.size();
for (int label = 0; label < sz; label++) {
LocalsArray la = secondaries.get(label);
if (la != null) {
ex.addContext("(locals array set: primary for caller "
+ Hex.u2(label) + ')");
la.getPrimary().annotate(ex);
}
}
|
public LocalsArray | copy()
return new LocalsArraySet(this);
|
public com.android.dx.rop.type.TypeBearer | get(int idx)
return primary.get(idx);
|
public com.android.dx.rop.type.TypeBearer | getCategory1(int idx)
return primary.getCategory1(idx);
|
public com.android.dx.rop.type.TypeBearer | getCategory2(int idx)
return primary.getCategory2(idx);
|
public int | getMaxLocals()
return primary.getMaxLocals();
|
public com.android.dx.rop.type.TypeBearer | getOrNull(int idx)
return primary.getOrNull(idx);
|
protected OneLocalsArray | getPrimary(){@inheritDoc}
return primary;
|
private LocalsArray | getSecondaryForLabel(int label)Gets the {@code LocalsArray} instance for a specified subroutine
caller label, or null if label has no locals associated with it.
if (label >= secondaries.size()) {
return null;
}
return secondaries.get(label);
|
public void | invalidate(int idx)
throwIfImmutable();
primary.invalidate(idx);
for (LocalsArray la : secondaries) {
if (la != null) {
la.invalidate(idx);
}
}
|
public void | makeInitialized(com.android.dx.rop.type.Type type)
int len = primary.getMaxLocals();
if (len == 0) {
// We have to check for this before checking for immutability.
return;
}
throwIfImmutable();
primary.makeInitialized(type);
for (LocalsArray la : secondaries) {
if (la != null) {
la.makeInitialized(type);
}
}
|
public com.android.dx.cf.code.LocalsArraySet | merge(LocalsArray other)
LocalsArraySet result;
try {
if (other instanceof LocalsArraySet) {
result = mergeWithSet((LocalsArraySet) other);
} else {
result = mergeWithOne((OneLocalsArray) other);
}
} catch (SimException ex) {
ex.addContext("underlay locals:");
annotate(ex);
ex.addContext("overlay locals:");
other.annotate(ex);
throw ex;
}
result.setImmutable();
return result;
|
private com.android.dx.cf.code.LocalsArraySet | mergeWithOne(OneLocalsArray other)Merges this set with a {@code OneLocalsArray} instance.
OneLocalsArray newPrimary;
ArrayList<LocalsArray> newSecondaries;
boolean secondariesChanged = false;
newPrimary = primary.merge(other.getPrimary());
newSecondaries = new ArrayList(secondaries.size());
int sz = secondaries.size();
for (int i = 0; i < sz; i++) {
LocalsArray la = secondaries.get(i);
LocalsArray resultla = null;
if (la != null) {
try {
resultla = la.merge(other);
} catch (SimException ex) {
ex.addContext("Merging one locals against caller block "
+ Hex.u2(i));
}
}
secondariesChanged = secondariesChanged || (la != resultla);
newSecondaries.add(resultla);
}
if ((primary == newPrimary) && ! secondariesChanged ) {
return this;
}
return new LocalsArraySet(newPrimary, newSecondaries);
|
private com.android.dx.cf.code.LocalsArraySet | mergeWithSet(com.android.dx.cf.code.LocalsArraySet other)Merges this set with another {@code LocalsArraySet} instance.
OneLocalsArray newPrimary;
ArrayList<LocalsArray> newSecondaries;
boolean secondariesChanged = false;
newPrimary = primary.merge(other.getPrimary());
int sz1 = secondaries.size();
int sz2 = other.secondaries.size();
int sz = Math.max(sz1, sz2);
newSecondaries = new ArrayList(sz);
for (int i = 0; i < sz; i++) {
LocalsArray la1 = (i < sz1 ? secondaries.get(i) : null);
LocalsArray la2 = (i < sz2 ? other.secondaries.get(i) : null);
LocalsArray resultla = null;
if (la1 == la2) {
resultla = la1;
} else if (la1 == null) {
resultla = la2;
} else if (la2 == null) {
resultla = la1;
} else {
try {
resultla = la1.merge(la2);
} catch (SimException ex) {
ex.addContext(
"Merging locals set for caller block " + Hex.u2(i));
}
}
secondariesChanged = secondariesChanged || (la1 != resultla);
newSecondaries.add(resultla);
}
if ((primary == newPrimary) && ! secondariesChanged ) {
return this;
}
return new LocalsArraySet(newPrimary, newSecondaries);
|
public com.android.dx.cf.code.LocalsArraySet | mergeWithSubroutineCaller(LocalsArray other, int predLabel){@inheritDoc}
LocalsArray mine = getSecondaryForLabel(predLabel);
LocalsArray newSecondary;
OneLocalsArray newPrimary;
newPrimary = primary.merge(other.getPrimary());
if (mine == other) {
newSecondary = mine;
} else if (mine == null) {
newSecondary = other;
} else {
newSecondary = mine.merge(other);
}
if ((newSecondary == mine) && (newPrimary == primary)) {
return this;
} else {
/*
* We're going to re-build a primary as a merge of all the
* secondaries.
*/
newPrimary = null;
int szSecondaries = secondaries.size();
int sz = Math.max(predLabel + 1, szSecondaries);
ArrayList<LocalsArray> newSecondaries = new ArrayList(sz);
for (int i = 0; i < sz; i++) {
LocalsArray la = null;
if (i == predLabel) {
/*
* This LocalsArray always replaces any existing one,
* since this is the result of a refined iteration.
*/
la = newSecondary;
} else if (i < szSecondaries) {
la = secondaries.get(i);
}
if (la != null) {
if (newPrimary == null) {
newPrimary = la.getPrimary();
} else {
newPrimary = newPrimary.merge(la.getPrimary());
}
}
newSecondaries.add(la);
}
LocalsArraySet result
= new LocalsArraySet(newPrimary, newSecondaries);
result.setImmutable();
return result;
}
|
public void | set(int idx, com.android.dx.rop.type.TypeBearer type)
throwIfImmutable();
primary.set(idx, type);
for (LocalsArray la : secondaries) {
if (la != null) {
la.set(idx, type);
}
}
|
public void | set(com.android.dx.rop.code.RegisterSpec spec)
set(spec.getReg(), spec);
|
public void | setImmutable()
primary.setImmutable();
for (LocalsArray la : secondaries) {
if (la != null) {
la.setImmutable();
}
}
super.setImmutable();
|
public LocalsArray | subArrayForLabel(int subLabel)Returns a LocalsArray instance representing the locals state that should
be used when returning to a subroutine caller.
LocalsArray result = getSecondaryForLabel(subLabel);
return result;
|
public java.lang.String | toHuman(){@inheritDoc
StringBuilder sb = new StringBuilder();
sb.append("(locals array set; primary)\n");
sb.append(getPrimary().toHuman());
sb.append('\n");
int sz = secondaries.size();
for (int label = 0; label < sz; label++) {
LocalsArray la = secondaries.get(label);
if (la != null) {
sb.append("(locals array set: primary for caller "
+ Hex.u2(label) + ")\n");
sb.append(la.getPrimary().toHuman());
sb.append('\n");
}
}
return sb.toString();
|