mirror of
https://github.com/revanced/smali.git
synced 2025-06-12 12:17:37 +02:00
Refactor the MethodAnalyzer API so that the instructions are returned as a read-only list
git-svn-id: https://smali.googlecode.com/svn/trunk@662 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
@ -170,6 +170,8 @@ public class AnalyzedInstruction implements Comparable<AnalyzedInstruction> {
|
||||
* @return a boolean value indicating whether this instruction is a beginning instruction
|
||||
*/
|
||||
public boolean isBeginningInstruction() {
|
||||
//if this instruction has no predecessors, it is either the fake "StartOfMethod" instruction or it is an
|
||||
//unreachable instruction.
|
||||
if (predecessors.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
@ -110,12 +110,13 @@ public class MethodAnalyzer {
|
||||
return analyzerState == VERIFIED;
|
||||
}
|
||||
|
||||
public AnalyzedInstruction[] analyze() {
|
||||
public void analyze() {
|
||||
assert encodedMethod != null;
|
||||
assert encodedMethod.codeItem != null;
|
||||
|
||||
if (analyzerState >= ANALYZED) {
|
||||
return makeInstructionArray();
|
||||
//the instructions have already been analyzed, so there is nothing to do
|
||||
return;
|
||||
}
|
||||
|
||||
CodeItem codeItem = encodedMethod.codeItem;
|
||||
@ -273,7 +274,6 @@ public class MethodAnalyzer {
|
||||
}
|
||||
|
||||
analyzerState = ANALYZED;
|
||||
return makeInstructionArray();
|
||||
}
|
||||
|
||||
private int getThisRegister() {
|
||||
@ -309,12 +309,11 @@ public class MethodAnalyzer {
|
||||
return startOfMethod;
|
||||
}
|
||||
|
||||
public AnalyzedInstruction[] makeInstructionArray() {
|
||||
AnalyzedInstruction[] instructionArray = new AnalyzedInstruction[instructions.size()];
|
||||
for (int i=0; i<instructions.size(); i++) {
|
||||
instructionArray[i] = instructions.valueAt(i);
|
||||
}
|
||||
return instructionArray;
|
||||
/**
|
||||
* @return a read-only list containing the instructions for tihs method.
|
||||
*/
|
||||
public List<AnalyzedInstruction> getInstructions() {
|
||||
return instructions.getValues();
|
||||
}
|
||||
|
||||
public ValidationException getValidationException() {
|
||||
|
@ -16,6 +16,10 @@
|
||||
|
||||
package org.jf.dexlib.Util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* SparseArrays map integers to Objects. Unlike a normal array of Objects,
|
||||
* there can be gaps in the indices. It is intended to be more efficient
|
||||
@ -340,6 +344,14 @@ public class SparseArray<E> {
|
||||
return ~high;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a read-only list of the values in this SparseArray which are in ascending order, based on their
|
||||
* associated key
|
||||
*/
|
||||
public List<E> getValues() {
|
||||
return Collections.unmodifiableList(Arrays.asList((E[])mValues));
|
||||
}
|
||||
|
||||
private int[] mKeys;
|
||||
private Object[] mValues;
|
||||
private int mSize;
|
||||
|
Reference in New Issue
Block a user