mirror of
https://github.com/revanced/smali.git
synced 2025-05-09 10:54:29 +02:00
Add support for empty packed switch data instructions
This commit is contained in:
parent
4879652a47
commit
c89097680e
@ -345,14 +345,18 @@ public class CodeItem {
|
|||||||
out.indent();
|
out.indent();
|
||||||
|
|
||||||
out.annotate(2, "size = %d", elements.size());
|
out.annotate(2, "size = %d", elements.size());
|
||||||
out.annotate(4, "first_key = %d", elements.get(0).getKey());
|
if (elements.size() == 0) {
|
||||||
out.annotate(0, "targets:");
|
out.annotate(4, "first_key");
|
||||||
out.indent();
|
} else {
|
||||||
for (int i=0; i<elements.size(); i++) {
|
out.annotate(4, "first_key = %d", elements.get(0).getKey());
|
||||||
out.annotate(4, "target[%d] = %d", i, elements.get(i).getOffset());
|
out.annotate(0, "targets:");
|
||||||
|
out.indent();
|
||||||
|
for (int i=0; i<elements.size(); i++) {
|
||||||
|
out.annotate(4, "target[%d] = %d", i, elements.get(i).getOffset());
|
||||||
|
}
|
||||||
|
out.deindent();
|
||||||
}
|
}
|
||||||
out.deindent();
|
out.deindent();
|
||||||
out.deindent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void annotateSparseSwitchPayload(@Nonnull AnnotatedBytes out,
|
private void annotateSparseSwitchPayload(@Nonnull AnnotatedBytes out,
|
||||||
|
@ -525,7 +525,8 @@ public class CodeItemPool {
|
|||||||
|
|
||||||
public void writeSparseSwitchPayload(@Nonnull DexWriter writer, @Nonnull SparseSwitchPayload instruction)
|
public void writeSparseSwitchPayload(@Nonnull DexWriter writer, @Nonnull SparseSwitchPayload instruction)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
writer.writeUshort(instruction.getOpcode().value);
|
writer.writeUbyte(0);
|
||||||
|
writer.writeUbyte(instruction.getOpcode().value >> 8);
|
||||||
List<? extends SwitchElement> elements = instruction.getSwitchElements();
|
List<? extends SwitchElement> elements = instruction.getSwitchElements();
|
||||||
writer.writeUshort(elements.size());
|
writer.writeUshort(elements.size());
|
||||||
for (SwitchElement element: elements) {
|
for (SwitchElement element: elements) {
|
||||||
@ -538,12 +539,17 @@ public class CodeItemPool {
|
|||||||
|
|
||||||
public void writePackedSwitchPayload(@Nonnull DexWriter writer, @Nonnull PackedSwitchPayload instruction)
|
public void writePackedSwitchPayload(@Nonnull DexWriter writer, @Nonnull PackedSwitchPayload instruction)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
writer.writeUshort(instruction.getOpcode().value);
|
writer.writeUbyte(0);
|
||||||
|
writer.writeUbyte(instruction.getOpcode().value >> 8);
|
||||||
List<? extends SwitchElement> elements = instruction.getSwitchElements();
|
List<? extends SwitchElement> elements = instruction.getSwitchElements();
|
||||||
writer.writeUshort(elements.size());
|
writer.writeUshort(elements.size());
|
||||||
writer.writeInt(elements.get(0).getKey());
|
if (elements.size() == 0) {
|
||||||
for (SwitchElement element: elements) {
|
writer.writeInt(0);
|
||||||
writer.writeInt(element.getOffset());
|
} else {
|
||||||
|
writer.writeInt(elements.get(0).getKey());
|
||||||
|
for (SwitchElement element: elements) {
|
||||||
|
writer.writeInt(element.getOffset());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user