コード例 #1
0
ファイル: RegionMaker.java プロジェクト: qiyeboy/jadx
  private void processExcHandler(ExceptionHandler handler, Set<BlockNode> exits) {
    BlockNode start = handler.getHandlerBlock();
    if (start == null) {
      return;
    }
    RegionStack stack = new RegionStack(mth);
    BlockNode dom;
    if (handler.isFinally()) {
      SplitterBlockAttr splitterAttr = start.get(AType.SPLITTER_BLOCK);
      if (splitterAttr == null) {
        return;
      }
      dom = splitterAttr.getBlock();
    } else {
      dom = start;
      stack.addExits(exits);
    }
    BitSet domFrontier = dom.getDomFrontier();
    List<BlockNode> handlerExits = BlockUtils.bitSetToBlocks(mth, domFrontier);
    boolean inLoop = mth.getLoopForBlock(start) != null;
    for (BlockNode exit : handlerExits) {
      if ((!inLoop || BlockUtils.isPathExists(start, exit))
          && RegionUtils.isRegionContainsBlock(mth.getRegion(), exit)) {
        stack.addExit(exit);
      }
    }
    handler.setHandlerRegion(makeRegion(start, stack));

    ExcHandlerAttr excHandlerAttr = start.get(AType.EXC_HANDLER);
    if (excHandlerAttr == null) {
      LOG.warn("Missing exception handler attribute for start block");
    } else {
      handler.getHandlerRegion().addAttr(excHandlerAttr);
    }
  }
コード例 #2
0
ファイル: RegionMaker.java プロジェクト: qiyeboy/jadx
 private static boolean canInsertContinue(
     BlockNode pred,
     List<BlockNode> predecessors,
     BlockNode loopEnd,
     Set<BlockNode> loopExitNodes) {
   if (!pred.contains(AFlag.SYNTHETIC) || BlockUtils.checkLastInsnType(pred, InsnType.CONTINUE)) {
     return false;
   }
   List<BlockNode> preds = pred.getPredecessors();
   if (preds.isEmpty()) {
     return false;
   }
   BlockNode codePred = preds.get(0);
   if (codePred.contains(AFlag.SKIP)) {
     return false;
   }
   if (loopEnd.isDominator(codePred) || loopExitNodes.contains(codePred)) {
     return false;
   }
   if (isDominatedOnBlocks(codePred, predecessors)) {
     return false;
   }
   boolean gotoExit = false;
   for (BlockNode exit : loopExitNodes) {
     if (BlockUtils.isPathExists(codePred, exit)) {
       gotoExit = true;
       break;
     }
   }
   return gotoExit;
 }