Methods Summary |
---|
public int | codeSize()Gets the size of this instance, in 16-bit code units. This will only
return a meaningful result if the instructions in this instance all
have valid addresses.
int sz = size();
if (sz == 0) {
return 0;
}
DalvInsn last = get(sz - 1);
return last.getNextAddress();
|
public void | debugPrint(java.io.OutputStream out, java.lang.String prefix, boolean verbose)Does a human-friendly dump of this instance.
Writer w = new OutputStreamWriter(out);
debugPrint(w, prefix, verbose);
try {
w.flush();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
|
public void | debugPrint(java.io.Writer out, java.lang.String prefix, boolean verbose)Does a human-friendly dump of this instance.
IndentingWriter iw = new IndentingWriter(out, 0, prefix);
int sz = size();
try {
for (int i = 0; i < sz; i++) {
DalvInsn insn = (DalvInsn) get0(i);
String s;
if ((insn.codeSize() != 0) || verbose) {
s = insn.listingString("", 0, verbose);
} else {
s = null;
}
if (s != null) {
iw.write(s);
}
}
iw.flush();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
|
public DalvInsn | get(int n)Gets the element at the given index. It is an error to call
this with the index for an element which was never set; if you
do that, this will throw {@code NullPointerException}.
return (DalvInsn) get0(n);
|
public int | getOutsSize()Gets the size of the outgoing arguments area required by this
method. This is equal to the largest argument word count of any
method referred to by this instance.
int sz = size();
int result = 0;
for (int i = 0; i < sz; i++) {
DalvInsn insn = (DalvInsn) get0(i);
if (!(insn instanceof CstInsn)) {
continue;
}
Constant cst = ((CstInsn) insn).getConstant();
if (!(cst instanceof CstBaseMethodRef)) {
continue;
}
boolean isStatic =
(insn.getOpcode().getFamily() == Opcodes.INVOKE_STATIC);
int count =
((CstBaseMethodRef) cst).getParameterWordCount(isStatic);
if (count > result) {
result = count;
}
}
return result;
|
public int | getRegistersSize()Gets the minimum required register count implied by this
instance. This includes any unused parameters that could
potentially be at the top of the register space.
return regCount;
|
public static com.android.dx.dex.code.DalvInsnList | makeImmutable(java.util.ArrayList list, int regCount)Constructs and returns an immutable instance whose elements are
identical to the ones in the given list, in the same order.
int size = list.size();
DalvInsnList result = new DalvInsnList(size, regCount);
for (int i = 0; i < size; i++) {
result.set(i, list.get(i));
}
result.setImmutable();
return result;
|
public void | set(int n, DalvInsn insn)Sets the instruction at the given index.
set0(n, insn);
|
public void | writeTo(com.android.dx.util.AnnotatedOutput out)Writes all the instructions in this instance to the given output
destination.
int startCursor = out.getCursor();
int sz = size();
if (out.annotates()) {
boolean verbose = out.isVerbose();
for (int i = 0; i < sz; i++) {
DalvInsn insn = (DalvInsn) get0(i);
int codeBytes = insn.codeSize() * 2;
String s;
if ((codeBytes != 0) || verbose) {
s = insn.listingString(" ", out.getAnnotationWidth(),
true);
} else {
s = null;
}
if (s != null) {
out.annotate(codeBytes, s);
} else if (codeBytes != 0) {
out.annotate(codeBytes, "");
}
}
}
for (int i = 0; i < sz; i++) {
DalvInsn insn = (DalvInsn) get0(i);
try {
insn.writeTo(out);
} catch (RuntimeException ex) {
throw ExceptionWithContext.withContext(ex,
"...while writing " + insn);
}
}
// Sanity check of the amount written.
int written = (out.getCursor() - startCursor) / 2;
if (written != codeSize()) {
throw new RuntimeException("write length mismatch; expected " +
codeSize() + " but actually wrote " + written);
}
|