Esempio n. 1
0
  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);
    }
  }