mirror of
https://github.com/revanced/smali.git
synced 2025-05-05 17:14:25 +02:00
Fix issues with converting switch statements in MutableMethodImplementation
This commit is contained in:
parent
135631b11b
commit
9f48c72390
@ -483,9 +483,11 @@ public class MutableMethodImplementation implements MethodImplementation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public Label newSwitchPayloadReferenceLabel(@Nonnull int[] codeAddressToIndex, int codeAddress) {
|
public Label newSwitchPayloadReferenceLabel(@Nonnull MethodLocation switchLocation,
|
||||||
|
@Nonnull int[] codeAddressToIndex, int codeAddress) {
|
||||||
MethodLocation referent = instructionList.get(mapCodeAddressToIndex(codeAddressToIndex, codeAddress));
|
MethodLocation referent = instructionList.get(mapCodeAddressToIndex(codeAddressToIndex, codeAddress));
|
||||||
Label label = new SwitchPayloadReferenceLabel();
|
SwitchPayloadReferenceLabel label = new SwitchPayloadReferenceLabel();
|
||||||
|
label.switchLocation = switchLocation;
|
||||||
referent.getLabels().add(label);
|
referent.getLabels().add(label);
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
@ -567,7 +569,7 @@ public class MutableMethodImplementation implements MethodImplementation {
|
|||||||
setInstruction(location, newBuilderInstruction31i((Instruction31i)instruction));
|
setInstruction(location, newBuilderInstruction31i((Instruction31i)instruction));
|
||||||
return;
|
return;
|
||||||
case Format31t:
|
case Format31t:
|
||||||
setInstruction(location, newBuilderInstruction31t(location.codeAddress, codeAddressToIndex,
|
setInstruction(location, newBuilderInstruction31t(location, codeAddressToIndex,
|
||||||
(Instruction31t)instruction));
|
(Instruction31t)instruction));
|
||||||
return;
|
return;
|
||||||
case Format32x:
|
case Format32x:
|
||||||
@ -771,12 +773,13 @@ public class MutableMethodImplementation implements MethodImplementation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private BuilderInstruction31t newBuilderInstruction31t(int codeAddress, int[] codeAddressToIndex,
|
private BuilderInstruction31t newBuilderInstruction31t(@Nonnull MethodLocation location , int[] codeAddressToIndex,
|
||||||
@Nonnull Instruction31t instruction) {
|
@Nonnull Instruction31t instruction) {
|
||||||
|
int codeAddress = location.getCodeAddress();
|
||||||
Label newLabel;
|
Label newLabel;
|
||||||
if (instruction.getOpcode() != Opcode.FILL_ARRAY_DATA) {
|
if (instruction.getOpcode() != Opcode.FILL_ARRAY_DATA) {
|
||||||
// if it's a sparse switch or packed switch
|
// if it's a sparse switch or packed switch
|
||||||
newLabel = newSwitchPayloadReferenceLabel(codeAddressToIndex, codeAddress + instruction.getCodeOffset());
|
newLabel = newSwitchPayloadReferenceLabel(location, codeAddressToIndex, codeAddress + instruction.getCodeOffset());
|
||||||
} else {
|
} else {
|
||||||
newLabel = newLabel(codeAddressToIndex, codeAddress + instruction.getCodeOffset());
|
newLabel = newLabel(codeAddressToIndex, codeAddress + instruction.getCodeOffset());
|
||||||
}
|
}
|
||||||
@ -873,7 +876,7 @@ public class MutableMethodImplementation implements MethodImplementation {
|
|||||||
|
|
||||||
List<Label> labels = Lists.newArrayList();
|
List<Label> labels = Lists.newArrayList();
|
||||||
for (SwitchElement element: switchElements) {
|
for (SwitchElement element: switchElements) {
|
||||||
labels.add(newLabel(codeAddressToIndex, element.getOffset() - baseAddress));
|
labels.add(newLabel(codeAddressToIndex, element.getOffset() + baseAddress));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new BuilderPackedSwitchPayload(switchElements.get(0).getKey(), labels);
|
return new BuilderPackedSwitchPayload(switchElements.get(0).getKey(), labels);
|
||||||
@ -899,7 +902,7 @@ public class MutableMethodImplementation implements MethodImplementation {
|
|||||||
List<SwitchLabelElement> labelElements = Lists.newArrayList();
|
List<SwitchLabelElement> labelElements = Lists.newArrayList();
|
||||||
for (SwitchElement element: switchElements) {
|
for (SwitchElement element: switchElements) {
|
||||||
labelElements.add(new SwitchLabelElement(element.getKey(),
|
labelElements.add(new SwitchLabelElement(element.getKey(),
|
||||||
newLabel(codeAddressToIndex, element.getOffset() - baseAddress)));
|
newLabel(codeAddressToIndex, element.getOffset() + baseAddress)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new BuilderSparseSwitchPayload(labelElements);
|
return new BuilderSparseSwitchPayload(labelElements);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user