Skip to content

Commit

Permalink
ddd
Browse files Browse the repository at this point in the history
  • Loading branch information
pxb1988 committed Aug 30, 2023
1 parent bc39f20 commit d916d88
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ public static Constant nShort(short i) {
public static Constant nString(String i) {
return new Constant(i);
}

public static Constant nMethodHandle(MethodHandle i) {
return new Constant(i);
}
public static Constant nProto(Proto i) {
return new Constant(i);
}
public static BinopExpr nAdd(Value a, Value b, String type) {
return new BinopExpr(VT.ADD, a, b, type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public void execute(DexStmtNode insn, DvmInterpreter<V> interpreter) {
case CONST_STRING:
case CONST_STRING_JUMBO:
case CONST_CLASS:
case CONST_METHOD_HANDLE:
case CONST_METHOD_TYPE:
setReg(((ConstStmtNode) insn).a, interpreter.newOperation(insn));
setTmp(null);
break;
Expand Down Expand Up @@ -378,7 +380,7 @@ public void execute(DexStmtNode insn, DvmInterpreter<V> interpreter) {
setTmp(null);
break;
default:
throw new RuntimeException();
throw new RuntimeException("not support " + insn.op);
}
}

Expand Down
Binary file added dex-reader/src/test/resources/dex039.dex
Binary file not shown.
Binary file removed dex-translator/libs/dx-27.0.3.jar
Binary file not shown.
Binary file added dex-translator/libs/dx-30.0.2.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.googlecode.d2j.DexType;
import com.googlecode.d2j.Field;
import com.googlecode.d2j.Method;
import com.googlecode.d2j.MethodHandle;
import com.googlecode.d2j.Proto;
import com.googlecode.d2j.node.DexCodeNode;
import com.googlecode.d2j.node.TryCatchNode;
import com.googlecode.d2j.node.analysis.DvmFrame;
Expand Down Expand Up @@ -560,6 +562,10 @@ public DvmValue newOperation(DexStmtNode insn) {
case CONST_STRING:
case CONST_STRING_JUMBO:
return b(nString((String) ((ConstStmtNode) insn).value));
case CONST_METHOD_HANDLE:
return b(nMethodHandle((MethodHandle) ((ConstStmtNode) insn).value));
case CONST_METHOD_TYPE:
return b(nProto((Proto) ((ConstStmtNode) insn).value));
case SGET:
case SGET_BOOLEAN:
case SGET_BYTE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.googlecode.d2j.DexType;
import com.googlecode.d2j.Method;
import com.googlecode.d2j.MethodHandle;
import com.googlecode.d2j.Proto;
import com.googlecode.d2j.asm.LdcOptimizeAdapter;
import com.googlecode.d2j.dex.Dex2Asm;
Expand Down Expand Up @@ -679,8 +680,8 @@ private void accept(Value value, MethodVisitor asm) {
Constant cst = (Constant) value;
if (cst.value.equals(Constant.Null)) {
asm.visitInsn(ACONST_NULL);
} else if (cst.value instanceof DexType) {
asm.visitLdcInsn(Type.getType(((DexType) cst.value).desc));
} else if (cst.value instanceof DexType || cst.value instanceof MethodHandle || cst.value instanceof Proto) {
asm.visitLdcInsn(Dex2Asm.convertConstantValue(cst.value));
} else {
asm.visitLdcInsn(cst.value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,12 @@ public ClassVisitor create(String classInternalName) {
CfOptions cfOptions = new CfOptions();
cfOptions.strictNameCheck = false;
DexOptions dexOptions = new DexOptions();
if (fileNode != null && fileNode.dexVersion >= DexConstants.DEX_037) {
dexOptions.minSdkVersion = 26;
if (fileNode != null) {
if (fileNode.dexVersion >= DexConstants.DEX_039) {
dexOptions.minSdkVersion = 28;
} else if (fileNode.dexVersion >= DexConstants.DEX_037) {
dexOptions.minSdkVersion = 26;
}
}

DirectClassFile dcf = new DirectClassFile(data, rca.getClassName() + ".class", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ public void visitFillArrayDataStmt(Op op, int ra, Object value) {
@Override
public void visitConstStmt(Op op, int ra, Object value) {
switch (op.format) {
case kFmt21c:// value is field,type,string
case kFmt21c:// value is field,type,string,method_handle,proto
case kFmt31c:// value is string,
value = cp.wrapEncodedItem(value);
ops.add(new CodeWriter.IndexedInsn(op, ra, 0, (BaseItem) value));
Expand Down

0 comments on commit d916d88

Please sign in to comment.