mirror of
https://github.com/pxb1988/dex2jar.git
synced 2024-11-26 22:50:42 +00:00
init all reg to 0 at top of a method.
Update issue 219 a simple and tricky fix for this issue by init all reg to 0 at top of a method. --HG-- branch : 0.0.9.x
This commit is contained in:
parent
b80161fc56
commit
4cf69a2ef2
@ -75,6 +75,7 @@ import static com.googlecode.dex2jar.ir.stmt.Stmts.nUnLock;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.googlecode.dex2jar.ir.stmt.Stmts;
|
||||
import org.objectweb.asm.Label;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.Type;
|
||||
@ -148,7 +149,10 @@ public class V3CodeAdapter implements DexCodeVisitor, Opcodes, DexOpcodes {
|
||||
}
|
||||
for (int i = 0; i < locals.length; i++) {
|
||||
if (locals[i] == null) {
|
||||
locals[i] = nLocal("a" + i);
|
||||
Local local = nLocal("a" + i);
|
||||
locals[i] = local;
|
||||
// simple fix for issue 219, init all tmp register to 0 at the start of insn.
|
||||
list.add(Stmts.nAssign(local, nInt(0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,51 @@
|
||||
package com.googlecode.dex2jar.test;
|
||||
|
||||
import com.googlecode.dex2jar.DexLabel;
|
||||
import com.googlecode.dex2jar.Method;
|
||||
import com.googlecode.dex2jar.visitors.DexClassVisitor;
|
||||
import com.googlecode.dex2jar.visitors.DexCodeVisitor;
|
||||
import com.googlecode.dex2jar.visitors.DexMethodVisitor;
|
||||
import org.junit.Test;
|
||||
|
||||
import static com.googlecode.dex2jar.DexOpcodes.*;
|
||||
|
||||
public class UnInitRegisterTest {
|
||||
public static void i219(DexClassVisitor cv) {
|
||||
DexMethodVisitor mv = cv.visitMethod(ACC_PUBLIC | ACC_STATIC, new Method("La;", "a",
|
||||
new String[] { "Ljava/lang/String;" }, "I"));
|
||||
DexCodeVisitor code = mv.visitCode();
|
||||
|
||||
int v0 = 0;
|
||||
int v1 = 1;
|
||||
|
||||
code.visitArguments(2, new int[] { v1 });
|
||||
code.visitReturnStmt(OP_RETURN, v0, TYPE_INT);
|
||||
code.visitEnd();
|
||||
mv.visitEnd();
|
||||
}
|
||||
|
||||
public static void i220(DexClassVisitor cv) {
|
||||
DexMethodVisitor mv = cv.visitMethod(ACC_PUBLIC, new Method("La;", "a", new String[] {}, "Ljava/lang/String;"));
|
||||
DexCodeVisitor code = mv.visitCode();
|
||||
|
||||
int v0 = 0;
|
||||
int v1 = 1;
|
||||
int v2 = 2;
|
||||
int v6 = 6;
|
||||
|
||||
DexLabel L6 = new DexLabel();
|
||||
code.visitArguments(7, new int[] { v6 });
|
||||
code.visitJumpStmt(OP_IF_EQZ, v1, L6);
|
||||
code.visitMoveStmt(OP_MOVE, v0, v6);
|
||||
code.visitLabel(L6);
|
||||
code.visitReturnStmt(OP_RETURN, v2, TYPE_OBJECT);
|
||||
code.visitEnd();
|
||||
mv.visitEnd();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
TestUtils.testDexASMifier(getClass(), "i219");
|
||||
TestUtils.testDexASMifier(getClass(), "i220");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user