Package jadx.core.utils

Examples of jadx.core.utils.InsnList


  private static void shrinkBlock(MethodNode mth, BlockNode block) {
    if (block.getInstructions().isEmpty()) {
      return;
    }
    InsnList insnList = new InsnList(block.getInstructions());
    int insnCount = insnList.size();
    List<ArgsInfo> argsList = new ArrayList<ArgsInfo>(insnCount);
    for (int i = 0; i < insnCount; i++) {
      argsList.add(new ArgsInfo(insnList.get(i), argsList, i));
    }
    List<WrapInfo> wrapList = new ArrayList<WrapInfo>();
    for (ArgsInfo argsInfo : argsList) {
      List<RegisterArg> args = argsInfo.getArgs();
      if (args.isEmpty()) {
        continue;
      }
      ListIterator<RegisterArg> it = args.listIterator(args.size());
      while (it.hasPrevious()) {
        RegisterArg arg = it.previous();
//        if (arg.getName() != null) {
//          continue;
//        }
        SSAVar sVar = arg.getSVar();
        // allow inline only one use arg or 'this'
        if (sVar.getVariableUseCount() != 1 && !arg.isThis()) {
          continue;
        }
        InsnNode assignInsn = sVar.getAssign().getParentInsn();
        if (assignInsn == null || assignInsn.contains(AFlag.DONT_INLINE)) {
          continue;
        }
        int assignPos = insnList.getIndex(assignInsn);
        if (assignPos != -1) {
          WrapInfo wrapInfo = argsInfo.checkInline(assignPos, arg);
          if (wrapInfo != null) {
            wrapList.add(wrapInfo);
          }
        } else {
          // another block
          BlockNode assignBlock = BlockUtils.getBlockByInsn(mth, assignInsn);
          if (assignBlock != null
              && assignInsn != arg.getParentInsn()
              && canMoveBetweenBlocks(assignInsn, assignBlock, block, argsInfo.getInsn())) {
            arg.wrapInstruction(assignInsn);
            InsnList.remove(assignBlock, assignInsn);
          }
        }
      }
    }
    if (!wrapList.isEmpty()) {
      for (WrapInfo wrapInfo : wrapList) {
        wrapInfo.getArg().wrapInstruction(wrapInfo.getInsn());
      }
      for (WrapInfo wrapInfo : wrapList) {
        insnList.remove(wrapInfo.getInsn());
      }
    }
  }
View Full Code Here

TOP

Related Classes of jadx.core.utils.InsnList

Copyright © 2018 www.massapicom. 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.