From fa773b53825e73392dc6d8bca8e4604bac7e2d57 Mon Sep 17 00:00:00 2001 From: Ben Gruver Date: Fri, 20 Mar 2015 16:38:19 -0700 Subject: [PATCH] Comment out unused switch payload instructions --- .../baksmali/Adaptors/Format/PackedSwitchMethodItem.java | 9 ++++++++- .../baksmali/Adaptors/Format/SparseSwitchMethodItem.java | 9 +++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/PackedSwitchMethodItem.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/PackedSwitchMethodItem.java index f0dd656b..30edfcd4 100644 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/PackedSwitchMethodItem.java +++ b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/Adaptors/Format/PackedSwitchMethodItem.java @@ -28,6 +28,7 @@ package org.jf.baksmali.Adaptors.Format; +import org.jf.baksmali.Adaptors.CommentingIndentingWriter; import org.jf.baksmali.Adaptors.LabelMethodItem; import org.jf.baksmali.Adaptors.MethodDefinition; import org.jf.dexlib2.iface.instruction.SwitchElement; @@ -43,6 +44,9 @@ public class PackedSwitchMethodItem extends InstructionMethodItem targets; private final int firstKey; + // Whether this sparse switch instruction should be commented out because it is never referenced + private boolean commentedOut; + public PackedSwitchMethodItem(MethodDefinition methodDef, int codeAddress, PackedSwitchPayload instruction) { super(methodDef, codeAddress, instruction); @@ -51,7 +55,6 @@ public class PackedSwitchMethodItem extends InstructionMethodItem(); boolean first = true; - //TODO: does dalvik allow switc payloads with no cases? int firstKey = 0; if (baseCodeAddress >= 0) { for (SwitchElement switchElement: instruction.getSwitchElements()) { @@ -65,6 +68,7 @@ public class PackedSwitchMethodItem extends InstructionMethodItem { private final List targets; + // Whether this sparse switch instruction should be commented out because it is never referenced + private boolean commentedOut; + public SparseSwitchMethodItem(MethodDefinition methodDef, int codeAddress, SparseSwitchPayload instruction) { super(methodDef, codeAddress, instruction); @@ -56,6 +60,7 @@ public class SparseSwitchMethodItem extends InstructionMethodItem