use of com.googlecode.d2j.DexLabel in project dex2jar by pxb1988.
the class BaksmaliCodeDumper method visitSparseSwitchStmt.
@Override
public void visitSparseSwitchStmt(Op op, int ra, int[] cases, DexLabel[] labels) {
DexLabel dx = new DexLabel();
dx.displayName = "L" + nextLabelNumber++;
usedLabel.add(dx);
out.s(op.displayName + " " + reg(ra) + ", " + xLabel(dx));
appendLast.add(new AbstractMap.SimpleEntry<DexLabel, Object>(dx, new SparseSwitchStmt(cases, labels)));
}
use of com.googlecode.d2j.DexLabel in project dex2jar by pxb1988.
the class BaksmaliCodeDumper method visitPackedSwitchStmt.
@Override
public void visitPackedSwitchStmt(Op op, int ra, int first_case, DexLabel[] labels) {
DexLabel dx = new DexLabel();
dx.displayName = "L" + nextLabelNumber++;
usedLabel.add(dx);
out.s(op.displayName + " " + reg(ra) + ", " + xLabel(dx));
appendLast.add(new AbstractMap.SimpleEntry<DexLabel, Object>(dx, new PackedSwitchStmt(first_case, labels)));
}
use of com.googlecode.d2j.DexLabel in project dex2jar by pxb1988.
the class BaksmaliCodeDumper method visitFillArrayDataStmt.
@Override
public void visitFillArrayDataStmt(Op op, int ra, Object array) {
DexLabel dx = new DexLabel();
dx.displayName = "L" + nextLabelNumber++;
usedLabel.add(dx);
out.s("%s %s, %s", op.displayName, reg(ra), xLabel(dx));
appendLast.add(new AbstractMap.SimpleEntry<DexLabel, Object>(dx, array));
}
use of com.googlecode.d2j.DexLabel in project dex2jar by pxb1988.
the class DexWeaver method buildInvocationClz.
public String buildInvocationClz(DexFileVisitor dfv) {
String typeName = getCurrentInvocationName();
String typeNameDesc = "L" + typeName + ";";
DexClassVisitor dcv = dfv.visit(DexConstants.ACC_PUBLIC, typeNameDesc, "Ljava/lang/Object;", new String[] { invocationInterfaceDesc });
dcv.visitField(DexConstants.ACC_PRIVATE | DexConstants.ACC_FINAL, new Field(typeNameDesc, "thiz", "Ljava/lang/Object;"), null).visitEnd();
dcv.visitField(DexConstants.ACC_PRIVATE | DexConstants.ACC_FINAL, new Field(typeNameDesc, "args", "[Ljava/lang/Object;"), null).visitEnd();
dcv.visitField(DexConstants.ACC_PRIVATE | DexConstants.ACC_FINAL, new Field(typeNameDesc, "idx", "I"), null).visitEnd();
{
DexMethodVisitor mv = dcv.visitMethod(DexConstants.ACC_PUBLIC | DexConstants.ACC_CONSTRUCTOR, new Method(typeNameDesc, "<init>", new String[] { "Ljava/lang/Object;", "[Ljava/lang/Object;", "I" }, "V"));
DexCodeVisitor codeVisitor = mv.visitCode();
codeVisitor.visitRegister(4);
codeVisitor.visitFieldStmt(Op.IPUT_OBJECT, 1, 0, new Field(typeNameDesc, "thiz", "Ljava/lang/Object;"));
codeVisitor.visitFieldStmt(Op.IPUT_OBJECT, 2, 0, new Field(typeNameDesc, "args", "[Ljava/lang/Object;"));
codeVisitor.visitFieldStmt(Op.IPUT, 3, 0, new Field(typeNameDesc, "idx", "I"));
codeVisitor.visitStmt0R(Op.RETURN_VOID);
codeVisitor.visitEnd();
mv.visitEnd();
}
{
genSwitchMethod(dcv, typeNameDesc, "getMethodOwner", new CB() {
@Override
public String getKey(Method mtd) {
return toInternal(mtd.getOwner());
}
});
genSwitchMethod(dcv, typeNameDesc, "getMethodName", new CB() {
@Override
public String getKey(Method mtd) {
return mtd.getName();
}
});
genSwitchMethod(dcv, typeNameDesc, "getMethodDesc", new CB() {
@Override
public String getKey(Method mtd) {
return mtd.getDesc();
}
});
}
{
DexMethodVisitor mv = dcv.visitMethod(DexConstants.ACC_PUBLIC, new Method(typeNameDesc, "getArguments", new String[0], "[Ljava/lang/Object;"));
DexCodeVisitor code = mv.visitCode();
code.visitRegister(2);
code.visitFieldStmt(Op.IGET, 0, 1, new Field(typeNameDesc, "args", "[Ljava/lang/Object;"));
code.visitStmt1R(Op.RETURN_OBJECT, 0);
code.visitEnd();
mv.visitEnd();
}
{
DexMethodVisitor mv = dcv.visitMethod(DexConstants.ACC_PUBLIC, new Method(typeNameDesc, "getThis", new String[0], "Ljava/lang/Object;"));
DexCodeVisitor code = mv.visitCode();
code.visitRegister(2);
code.visitFieldStmt(Op.IGET, 0, 1, new Field(typeNameDesc, "thiz", "Ljava/lang/Object;"));
code.visitStmt1R(Op.RETURN_OBJECT, 0);
code.visitEnd();
mv.visitEnd();
}
{
DexMethodVisitor mv = dcv.visitMethod(DexConstants.ACC_PUBLIC, new Method(typeNameDesc, "proceed", new String[0], "Ljava/lang/Object;"));
DexCodeVisitor code = mv.visitCode();
code.visitRegister(4);
code.visitFieldStmt(Op.IGET, 0, 3, new Field(typeNameDesc, "thiz", "Ljava/lang/Object;"));
code.visitFieldStmt(Op.IGET, 1, 3, new Field(typeNameDesc, "args", "[Ljava/lang/Object;"));
code.visitFieldStmt(Op.IGET, 2, 3, new Field(typeNameDesc, "idx", "I"));
DexLabel[] labels = new DexLabel[callbacks.size()];
for (int i = 0; i < labels.length; i++) {
labels[i] = new DexLabel();
}
code.visitPackedSwitchStmt(Op.PACKED_SWITCH, 2, 0, labels);
code.visitTypeStmt(Op.NEW_INSTANCE, 0, 0, "Ljava/lang/RuntimeException;");
code.visitConstStmt(Op.CONST_STRING, 1, "invalid idx");
code.visitMethodStmt(Op.INVOKE_DIRECT, new int[] { 0, 1 }, new Method("Ljava/lang/RuntimeException;", "<init>", new String[] { "Ljava/lang/String;" }, "V"));
code.visitStmt1R(Op.THROW, 0);
for (int i = 0; i < labels.length; i++) {
code.visitLabel(labels[i]);
Callback callback = callbacks.get(i);
Method mCallback = (Method) callback.callback;
if (callback.isStatic) {
code.visitMethodStmt(Op.INVOKE_STATIC, new int[] { 1 }, mCallback);
} else if (callback.isSpecial) {
code.visitTypeStmt(Op.CHECK_CAST, 0, -1, mCallback.getOwner());
code.visitMethodStmt(Op.INVOKE_VIRTUAL, new int[] { 0, 1 }, mCallback);
} else {
code.visitMethodStmt(Op.INVOKE_STATIC, new int[] { 0, 1 }, mCallback);
}
code.visitStmt1R(Op.MOVE_RESULT_OBJECT, 0);
code.visitStmt1R(Op.RETURN_OBJECT, 0);
}
code.visitEnd();
mv.visitEnd();
}
dcv.visitEnd();
return typeName;
}
use of com.googlecode.d2j.DexLabel in project dex2jar by pxb1988.
the class ASMifierCodeV method v.
public String v(DexLabel[] labels) {
StringBuilder sb = new StringBuilder("new DexLabel[]{");
boolean first = true;
for (DexLabel dexLabel : labels) {
if (first) {
first = false;
} else {
sb.append(",");
}
sb.append(v(dexLabel));
}
return sb.append("}").toString();
}
Aggregations