* @param args commandline parsedArgs
*/
public static void dump(byte[] bytes, PrintStream out,
- String filePath, boolean rop, Args args) {
- BlockDumper bd =
- new BlockDumper(bytes, out, filePath,
- rop, args);
+ String filePath, boolean rop, Args args) {
+ BlockDumper bd = new BlockDumper(bytes, out, filePath,
+ rop, args);
bd.dump();
}
* Constructs an instance. This class is not publicly instantiable.
* Use {@link #dump}.
*/
- BlockDumper(byte[] bytes, PrintStream out,
- String filePath,
- boolean rop, Args args) {
+ BlockDumper(byte[] bytes, PrintStream out, String filePath,
+ boolean rop, Args args) {
super(bytes, out, filePath, args);
this.rop = rop;
/** {@inheritDoc} */
@Override
public void startParsingMember(ByteArray bytes, int offset, String name,
- String descriptor) {
+ String descriptor) {
if (descriptor.indexOf('(') < 0) {
// It's a field, not a method
return;
/** {@inheritDoc} */
@Override
public void endParsingMember(ByteArray bytes, int offset, String name,
- String descriptor, Member member) {
+ String descriptor, Member member) {
if (!(member instanceof Method)) {
return;
}
return;
}
- ConcreteMethod meth = new ConcreteMethod((Method) member, classFile,
- true, true);
+ ConcreteMethod meth =
+ new ConcreteMethod((Method) member, classFile, true, true);
if (rop) {
ropDump(meth);
int sz = list.size();
CodeObserver codeObserver = new CodeObserver(bytes, BlockDumper.this);
- // Reset the dump cursor to the start of the bytecode
+ // Reset the dump cursor to the start of the bytecode.
setAt(bytes, 0);
suppressDump = false;
}
parsed(bytes, start, 0,
- "block " + Hex.u2(bb.getLabel()) + ": " +
- Hex.u2(start) + ".." + Hex.u2(end));
+ "block " + Hex.u2(bb.getLabel()) + ": " +
+ Hex.u2(start) + ".." + Hex.u2(end));
changeIndent(1);
int len;
int end = bytes.size();
if (byteAt < end) {
parsed(bytes, byteAt, end - byteAt,
- "dead code " + Hex.u2(byteAt) + ".." + Hex.u2(end));
+ "dead code " + Hex.u2(byteAt) + ".." + Hex.u2(end));
}
suppressDump = true;
* @param meth {@code non-null;} method data to dump
*/
private void ropDump(ConcreteMethod meth) {
+ TranslationAdvice advice = DexTranslationAdvice.THE_ONE;
BytecodeArray code = meth.getCode();
ByteArray bytes = code.getBytes();
-
- TranslationAdvice advice = DexTranslationAdvice.THE_ONE;
-
- RopMethod rmeth =
- Ropper.convert(meth, advice);
+ RopMethod rmeth = Ropper.convert(meth, advice);
StringBuffer sb = new StringBuffer(2000);
if (optimize) {
boolean isStatic = AccessFlags.isStatic(meth.getAccessFlags());
-
int paramWidth = computeParamWidth(meth, isStatic);
- rmeth = Optimizer.optimize(rmeth, paramWidth, isStatic, true,
- advice);
+ rmeth =
+ Optimizer.optimize(rmeth, paramWidth, isStatic, true, advice);
}
BasicBlockList blocks = rmeth.getBlocks();
package com.android.dx.util;
-import com.android.dx.cf.code.ByteBlock;
-
/**
* A list of labeled items, allowing easy lookup by label.
*/
public class LabeledList extends FixedSizeList {
-
/**
- * Sparse array indexed by label to FixedSizeList index.
- * -1 = invalid label.
+ * Sparse array indexed by label to FixedSizeList index;
+ * {@code -1} for an invalid label.
*/
private final IntList labelToIndex;
*
* @param old instance to copy
*/
- protected LabeledList(LabeledList old) {
+ public LabeledList(LabeledList old) {
super(old.size());
labelToIndex = old.labelToIndex.mutableCopy();
public int getMaxLabel() {
int sz = labelToIndex.size();
- // Gobble any deleted labels that may be at the end...
+ // Gobble any deleted labels that may be at the end.
int i;
for (i = sz - 1; (i >= 0) && (labelToIndex.get(i) < 0); i--)
- ;
+ /*empty*/ ;
- int newSize = i+1;
+ int newSize = i + 1;
labelToIndex.shrink(newSize);
}
/**
- * Removes a label from the label-to-index mapping
+ * Removes a label from the label-to-index mapping.
+ *
* @param oldLabel label to remove
*/
- protected void removeLabel(int oldLabel) {
+ private void removeLabel(int oldLabel) {
labelToIndex.set(oldLabel, -1);
}
/**
- * Adds a label and index to the label-to-index mapping
+ * Adds a label and index to the label-to-index mapping.
+ *
* @param label new label
* @param index index of block.
*/
- protected void addLabelIndex(int label, int index) {
+ private void addLabelIndex(int label, int index) {
int origSz = labelToIndex.size();
for (int i = 0; i <= (label - origSz); i++) {
}
/**
- * Rebuilds the label-to-index mapping after a shrinkToFit().
- * Note: assumes that the labels that are in the list are the same
- * although the indicies may have changed.
+ * Rebuilds the label-to-index mapping after a {@code shrinkToFit()}.
+ * Note: This assumes that the labels that are in the list are the
+ * same, although the indicies may have changed.
*/
- protected void rebuildLabelToIndex() {
+ private void rebuildLabelToIndex() {
int szItems = size();
for (int i = 0; i < szItems; i++) {