Search in sources :

Example 6 with DexCodeVisitor

use of com.googlecode.d2j.visitors.DexCodeVisitor in project dex2jar by pxb1988.

the class DexCodeNode method accept.

public void accept(DexMethodVisitor v) {
    DexCodeVisitor cv = v.visitCode();
    if (cv != null) {
        accept(cv);
        cv.visitEnd();
    }
}
Also used : DexCodeVisitor(com.googlecode.d2j.visitors.DexCodeVisitor)

Example 7 with DexCodeVisitor

use of com.googlecode.d2j.visitors.DexCodeVisitor in project dex2jar by pxb1988.

the class I121Test method i121.

@Test
public static void i121(DexClassVisitor cv) {
    DexMethodVisitor mv = cv.visitMethod(ACC_PUBLIC | ACC_STATIC, new Method("La;", "a", new String[] { "Ljava/lang/String;", "Ljava/lang/String;" }, "Ljava/lang/String;"));
    DexCodeVisitor code = mv.visitCode();
    int p0 = 2;
    int p1 = 3;
    int v0 = 0;
    int v1 = 1;
    DexLabel cond_7 = new DexLabel();
    DexLabel try_start_2 = new DexLabel();
    DexLabel try_end_9 = new DexLabel();
    DexLabel catch_a = new DexLabel();
    DexLabel goto_2 = new DexLabel();
    code.visitTryCatch(try_start_2, try_end_9, new DexLabel[] { catch_a }, new String[] { "Ljava/io/UnsupportedEncodingException;" });
    code.visitRegister(4);
    code.visitJumpStmt(IF_EQZ, p1, -1, cond_7);
    code.visitLabel(goto_2);
    code.visitLabel(try_start_2);
    code.visitMethodStmt(INVOKE_STATIC, new int[] { p0, p1 }, new Method("Ljava/net/URLEncoder;", "encode", new String[] { "Ljava/lang/String;", "Ljava/lang/String;" }, "Ljava/lang/String;"));
    code.visitStmt1R(MOVE_RESULT_OBJECT, v0);
    code.visitStmt1R(RETURN_OBJECT, v0);
    code.visitLabel(cond_7);
    code.visitConstStmt(CONST_STRING, p1, "ISO-8859-1");
    code.visitLabel(try_end_9);
    code.visitJumpStmt(GOTO, -1, -1, goto_2);
    code.visitLabel(catch_a);
    code.visitStmt1R(MOVE_EXCEPTION, v0);
    code.visitTypeStmt(NEW_INSTANCE, v1, -1, "Ljava/lang/IllegalArgumentException;");
    code.visitMethodStmt(INVOKE_DIRECT, new int[] { v1, v0 }, new Method("Ljava/lang/IllegalArgumentException;", "<init>", new String[] { "Ljava/lang/Throwable;" }, "V"));
    code.visitStmt1R(THROW, v1);
    code.visitEnd();
    mv.visitEnd();
}
Also used : DexCodeVisitor(com.googlecode.d2j.visitors.DexCodeVisitor) DexLabel(com.googlecode.d2j.DexLabel) Method(com.googlecode.d2j.Method) DexMethodVisitor(com.googlecode.d2j.visitors.DexMethodVisitor) Test(org.junit.Test)

Example 8 with DexCodeVisitor

use of com.googlecode.d2j.visitors.DexCodeVisitor in project dex2jar by pxb1988.

the class I168Test method i168.

@Test
public static void i168(DexClassVisitor cv) {
    DexMethodVisitor mv = cv.visitMethod(ACC_PUBLIC | ACC_STATIC, new Method("La;", "a", new String[] {}, "I"));
    DexCodeVisitor code = mv.visitCode();
    // 2000 locals
    code.visitRegister(2000);
    for (int i = 0; i < 2000; i++) {
        // 2000 insns
        code.visitConstStmt(Op.CONST, i, i);
    }
    for (int i = 0; i < 18000; i++) {
        // 18000 insns
        code.visitConstStmt(Op.CONST, 25, i);
    }
    code.visitStmt1R(Op.RETURN, 25);
    code.visitEnd();
    mv.visitEnd();
}
Also used : DexCodeVisitor(com.googlecode.d2j.visitors.DexCodeVisitor) Method(com.googlecode.d2j.Method) DexMethodVisitor(com.googlecode.d2j.visitors.DexMethodVisitor) Test(org.junit.Test)

Example 9 with DexCodeVisitor

use of com.googlecode.d2j.visitors.DexCodeVisitor in project dex2jar by pxb1988.

the class I63Test method i63.

@Test
public static void i63(DexClassVisitor cv) {
    DexMethodVisitor mv = cv.visitMethod(ACC_STATIC, new Method("La;", "b", new String[] {}, "V"));
    if (mv != null) {
        DexCodeVisitor code = mv.visitCode();
        if (code != null) {
            code.visitRegister(1);
            DexLabel L1 = new DexLabel();
            DexLabel L2 = new DexLabel();
            code.visitLabel(L1);
            code.visitFieldStmt(Op.SGET, 0, -1, new Field("La;", "f", "J"));
            code.visitLabel(L2);
            code.visitStmt0R(Op.RETURN_VOID);
            code.visitEnd();
            code.visitTryCatch(L1, L2, new DexLabel[] { L2 }, new String[] { "La;" });
        }
        mv.visitEnd();
    }
}
Also used : Field(com.googlecode.d2j.Field) DexCodeVisitor(com.googlecode.d2j.visitors.DexCodeVisitor) DexLabel(com.googlecode.d2j.DexLabel) Method(com.googlecode.d2j.Method) DexMethodVisitor(com.googlecode.d2j.visitors.DexMethodVisitor) Test(org.junit.Test)

Example 10 with DexCodeVisitor

use of com.googlecode.d2j.visitors.DexCodeVisitor in project dex2jar by pxb1988.

the class Issue71Test method i71.

@Test
public static void i71(DexClassVisitor cv) {
    DexMethodVisitor mv = cv.visitMethod(ACC_STATIC, new Method("La;", "test", new String[] {}, "V"));
    if (mv != null) {
        DexCodeVisitor code = mv.visitCode();
        if (code != null) {
            code.visitRegister(2);
            code.visitConstStmt(CONST_WIDE, 0, 0L);
            code.visitConstStmt(CONST_WIDE, 1, 2L);
            code.visitStmt3R(ADD_LONG, 0, 0, 1);
            code.visitStmt0R(RETURN_VOID);
            code.visitEnd();
        }
        mv.visitEnd();
    }
}
Also used : DexCodeVisitor(com.googlecode.d2j.visitors.DexCodeVisitor) Method(com.googlecode.d2j.Method) DexMethodVisitor(com.googlecode.d2j.visitors.DexMethodVisitor) Test(org.junit.Test)

Aggregations

DexCodeVisitor (com.googlecode.d2j.visitors.DexCodeVisitor)23 DexMethodVisitor (com.googlecode.d2j.visitors.DexMethodVisitor)19 Method (com.googlecode.d2j.Method)18 Test (org.junit.Test)13 DexLabel (com.googlecode.d2j.DexLabel)9 Field (com.googlecode.d2j.Field)8 Op (com.googlecode.d2j.reader.Op)4 DexClassVisitor (com.googlecode.d2j.visitors.DexClassVisitor)4 HashMap (java.util.HashMap)4 DexMethodNode (com.googlecode.d2j.node.DexMethodNode)2 DexAnnotationVisitor (com.googlecode.d2j.visitors.DexAnnotationVisitor)2 DexFieldVisitor (com.googlecode.d2j.visitors.DexFieldVisitor)2 File (java.io.File)2 DexFileWriter (com.googlecode.d2j.dex.writer.DexFileWriter)1 DexCodeNode (com.googlecode.d2j.node.DexCodeNode)1 DexFieldNode (com.googlecode.d2j.node.DexFieldNode)1 DexStmtNode (com.googlecode.d2j.node.insn.DexStmtNode)1 DexFileReader (com.googlecode.d2j.reader.DexFileReader)1 ASMifierFileV (com.googlecode.d2j.util.ASMifierFileV)1 DexAnnotationAble (com.googlecode.d2j.visitors.DexAnnotationAble)1