Commit 11d8b28f authored by Skylot's avatar Skylot

core: fix variable rename

parent 12b63712
......@@ -200,7 +200,7 @@ public class MethodGen {
return name;
}
name = getUniqVarName(name);
arg.getSVar().setName(name);
arg.getSVar().setVariableName(name);
return name;
}
......
......@@ -107,6 +107,23 @@ public class SSAVar {
}
}
public void setVariableName(String name) {
setName(name);
if (isUsedInPhi()) {
PhiInsn phi = getUsedInPhi();
phi.getResult().getSVar().setVariableName(name);
for (InsnArg arg : phi.getArguments()) {
if (arg.isRegister()) {
RegisterArg reg = (RegisterArg) arg;
SSAVar sVar = reg.getSVar();
if (sVar != this && !name.equals(reg.getName())) {
sVar.setVariableName(name);
}
}
}
}
}
public void mergeName(RegisterArg arg) {
if (arg.getName() != null) {
setName(arg.getName());
......
......@@ -11,7 +11,7 @@ import static org.junit.Assert.assertThat;
public class TestInline2 extends InternalJadxTest {
public static class TestCls {
public int simple_loops() throws InterruptedException {
public int test() throws InterruptedException {
int[] a = new int[]{1, 2, 4, 6, 8};
int b = 0;
for (int i = 0; i < a.length; i++) {
......@@ -28,7 +28,11 @@ public class TestInline2 extends InternalJadxTest {
public void test() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
System.out.println(code);
assertThat(code, containsString("i < a.length"));
assertThat(code, containsString("long i_2 ="));
assertThat(code, containsString("+ i_2"));
assertThat(code, containsString("i_2--;"));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment