Check for unreachable instructions and comment them out

git-svn-id: https://smali.googlecode.com/svn/trunk@673 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
JesusFreke@JesusFreke.com 2010-03-06 06:12:16 +00:00
parent 10a9518111
commit 650725bbd3

View File

@ -291,6 +291,8 @@ public class MethodDefinition {
BitSet printPreRegister = new BitSet(registerCount);
BitSet printPostRegister = new BitSet(registerCount);
boolean lastIsUnreachable = false;
int currentCodeAddress = 0;
for (int i=0; i<instructions.size(); i++) {
AnalyzedInstruction instruction = instructions.get(i);
@ -301,13 +303,25 @@ public class MethodDefinition {
if (instruction.isDead()) {
methodItems.add(new CommentedOutMethodItem(stg, methodItem));
lastIsUnreachable = false;
} else if (instruction.getPredecessorCount() == 0 &&
!instruction.getInstruction().getFormat().variableSizeFormat) {
if (!lastIsUnreachable) {
methodItems.add(
new CommentMethodItem(stg, "Unreachable code", currentCodeAddress, Double.MIN_VALUE));
}
methodItems.add(new CommentedOutMethodItem(stg, methodItem));
lastIsUnreachable = true;
} else {
methodItems.add(methodItem);
lastIsUnreachable = false;
}
if (instruction.getInstruction().getFormat() == Format.UnresolvedNullReference) {
methodItems.add(new CommentedOutMethodItem(stg, InstructionMethodItemFactory.makeInstructionFormatMethodItem(this,
encodedMethod.codeItem, currentCodeAddress, stg, instruction.getOriginalInstruction(), false)));
methodItems.add(new CommentedOutMethodItem(stg,
InstructionMethodItemFactory.makeInstructionFormatMethodItem(this, encodedMethod.codeItem,
currentCodeAddress, stg, instruction.getOriginalInstruction(), false)));
}
if (i != instructions.size() - 1) {