Examples of ArithNode


Examples of jadx.core.dex.instructions.ArithNode

    }
    return null;
  }

  private static InsnNode simplifyArith(InsnNode insn) {
    ArithNode arith = (ArithNode) insn;
    if (arith.getArgsCount() != 2) {
      return null;
    }
    InsnArg litArg = null;
    InsnArg secondArg = arith.getArg(1);
    if (secondArg.isInsnWrap()) {
      InsnNode wr = ((InsnWrapArg) secondArg).getWrapInsn();
      if (wr.getType() == InsnType.CONST) {
        litArg = wr.getArg(0);
      }
    } else if (secondArg.isLiteral()) {
      litArg = secondArg;
    }
    if (litArg != null) {
      long lit = ((LiteralArg) litArg).getLiteral();
      // fix 'c + (-1)' => 'c - (1)'
      if (arith.getOp() == ArithOp.ADD && lit < 0) {
        return new ArithNode(ArithOp.SUB,
            arith.getResult(), insn.getArg(0),
            InsnArg.lit(-lit, litArg.getType()));
      }
    }
    return null;
  }
View Full Code Here

Examples of jadx.core.dex.instructions.ArithNode

      FieldArg fArg = new FieldArg(field, reg);
      if (reg != null) {
        fArg.setType(get.getArg(0).getType());
      }
      if (wrapType == InsnType.ARITH) {
        ArithNode ar = (ArithNode) wrap;
        return new ArithNode(ar.getOp(), fArg, ar.getArg(1));
      } else {
        int argsCount = wrap.getArgsCount();
        InsnNode concat = new InsnNode(InsnType.STR_CONCAT, argsCount - 1);
        for (int i = 1; i < argsCount; i++) {
          concat.addArg(wrap.getArg(i));
        }
        return new ArithNode(ArithOp.ADD, fArg, InsnArg.wrapArg(concat));
      }
    } catch (Throwable e) {
      LOG.debug("Can't convert field arith insn: {}, mth: {}", insn, mth, e);
    }
    return null;
View Full Code Here

Examples of jadx.core.dex.instructions.ArithNode

  private static LoopType checkArrayForEach(MethodNode mth, InsnNode initInsn, InsnNode incrInsn, IfCondition condition) {
    if (!(incrInsn instanceof ArithNode)) {
      return null;
    }
    ArithNode arithNode = (ArithNode) incrInsn;
    if (arithNode.getOp() != ArithOp.ADD) {
      return null;
    }
    InsnArg lit = incrInsn.getArg(1);
    if (!lit.isLiteral() || ((LiteralArg) lit).getLiteral() != 1) {
      return null;
View Full Code Here

Examples of jadx.core.dex.instructions.ArithNode

   * Remove parenthesis for wrapped insn  in arith '+' or '-'
   * ('(a + b) +c' => 'a + b + c')
   */
  private static void checkInsn(InsnNode insn) {
    if (insn.getType() == InsnType.ARITH) {
      ArithNode arith = (ArithNode) insn;
      ArithOp op = arith.getOp();
      if (op == ArithOp.ADD || op == ArithOp.SUB) {
        for (int i = 0; i < 2; i++) {
          InsnArg arg = arith.getArg(i);
          if (arg.isInsnWrap()) {
            InsnNode wrapInsn = ((InsnWrapArg) arg).getWrapInsn();
            wrapInsn.add(AFlag.DONT_WRAP);
            checkInsn(wrapInsn);
          }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.