|
21 | 21 | import jadx.core.dex.instructions.InsnType;
|
22 | 22 | import jadx.core.dex.instructions.PhiInsn;
|
23 | 23 | import jadx.core.dex.instructions.args.ArgType;
|
| 24 | +import jadx.core.dex.instructions.args.CodeVar; |
24 | 25 | import jadx.core.dex.instructions.args.InsnArg;
|
25 | 26 | import jadx.core.dex.instructions.args.LiteralArg;
|
26 | 27 | import jadx.core.dex.instructions.args.PrimitiveType;
|
@@ -81,7 +82,11 @@ public void visit(MethodNode mth) {
|
81 | 82 | resolved = false;
|
82 | 83 | }
|
83 | 84 | }
|
84 |
| - if (!resolved) { |
| 85 | + if (resolved) { |
| 86 | + for (SSAVar var : new ArrayList<>(mth.getSVars())) { |
| 87 | + processIncompatiblePrimitives(mth, var); |
| 88 | + } |
| 89 | + } else { |
85 | 90 | for (SSAVar var : new ArrayList<>(mth.getSVars())) {
|
86 | 91 | tryInsertAdditionalInsn(mth, var);
|
87 | 92 | }
|
@@ -249,7 +254,7 @@ private ITypeBound makeUseBound(RegisterArg regArg) {
|
249 | 254 | if (insn == null) {
|
250 | 255 | return null;
|
251 | 256 | }
|
252 |
| - return new TypeBoundConst(BoundEnum.USE, regArg.getInitType()); |
| 257 | + return new TypeBoundConst(BoundEnum.USE, regArg.getInitType(), regArg); |
253 | 258 | }
|
254 | 259 |
|
255 | 260 | private boolean tryPossibleTypes(SSAVar var, ArgType type) {
|
@@ -375,4 +380,39 @@ private boolean tryWiderObjects(MethodNode mth, SSAVar var) {
|
375 | 380 | }
|
376 | 381 | return false;
|
377 | 382 | }
|
| 383 | + |
| 384 | + private void processIncompatiblePrimitives(MethodNode mth, SSAVar var) { |
| 385 | + if (var.getAssign().getType() == ArgType.BOOLEAN) { |
| 386 | + for (ITypeBound bound : var.getTypeInfo().getBounds()) { |
| 387 | + if (bound.getBound() == BoundEnum.USE |
| 388 | + && bound.getType().isPrimitive() && bound.getType() != ArgType.BOOLEAN) { |
| 389 | + InsnNode insn = bound.getArg().getParentInsn(); |
| 390 | + if (insn.getType() == InsnType.CAST) { |
| 391 | + continue; |
| 392 | + }; |
| 393 | + |
| 394 | + IndexInsnNode castNode = new IndexInsnNode(InsnType.CAST, bound.getType(), 1); |
| 395 | + castNode.addArg(bound.getArg()); |
| 396 | + castNode.setResult(InsnArg.reg(bound.getArg().getRegNum(), bound.getType())); |
| 397 | + |
| 398 | + SSAVar newVar = mth.makeNewSVar(castNode.getResult().getRegNum(), castNode.getResult()); |
| 399 | + CodeVar codeVar = new CodeVar(); |
| 400 | + codeVar.setType(bound.getType()); |
| 401 | + newVar.setCodeVar(codeVar); |
| 402 | + newVar.getTypeInfo().setType(bound.getType()); |
| 403 | + |
| 404 | + for (int i = insn.getArgsCount() - 1; i >= 0; i--) { |
| 405 | + if (insn.getArg(i) == bound.getArg()) { |
| 406 | + insn.setArg(i, castNode.getResult().duplicate()); |
| 407 | + break; |
| 408 | + } |
| 409 | + } |
| 410 | + |
| 411 | + BlockNode blockNode = BlockUtils.getBlockByInsn(mth, insn); |
| 412 | + List<InsnNode> insnList = blockNode.getInstructions(); |
| 413 | + insnList.add(insnList.indexOf(insn), castNode); |
| 414 | + } |
| 415 | + } |
| 416 | + } |
| 417 | + } |
378 | 418 | }
|
0 commit comments