Package jadx.core.dex.regions

Examples of jadx.core.dex.regions.Region


      removeSynchronized(mth);
    }
  }

  private static void removeSynchronized(MethodNode mth) {
    Region startRegion = mth.getRegion();
    List<IContainer> subBlocks = startRegion.getSubBlocks();
    if (!subBlocks.isEmpty() && subBlocks.get(0) instanceof SynchronizedRegion) {
      SynchronizedRegion synchRegion = (SynchronizedRegion) subBlocks.get(0);
      InsnNode synchInsn = synchRegion.getEnterInsn();
      if (!synchInsn.getArg(0).isThis()) {
        LOG.warn("In synchronized method {}, top region not synchronized by 'this' {}", mth, synchInsn);
        return;
      }
      // replace synchronized block with inner region
      startRegion.getSubBlocks().set(0, synchRegion.getRegion());
      // remove 'monitor-enter' instruction
      InstructionRemover.remove(mth, synchInsn);
      // remove 'monitor-exit' instruction
      for (InsnNode exit : synchRegion.getExitInsns()) {
        InstructionRemover.remove(mth, exit);
View Full Code Here


    if (region instanceof LoopRegion) {
      LoopRegion loop = (LoopRegion) region;
      region = loop.getBody();
    }

    Region tryRegion = new Region(region);
    List<IContainer> subBlocks = region.getSubBlocks();
    for (IContainer cont : subBlocks) {
      if (RegionUtils.isDominatedBy(dominator, cont)) {
        if (isHandlerPath(tb, cont)) {
          break;
        }
        tryRegion.getSubBlocks().add(cont);
      }
    }
    if (tryRegion.getSubBlocks().isEmpty()) {
      return false;
    }

    TryCatchRegion tryCatchRegion = new TryCatchRegion(region, tryRegion);
    tryRegion.setParent(tryCatchRegion);
    tryCatchRegion.setTryCatchBlock(tb.getCatchAttr().getTryBlock());

    // replace first node by region
    IContainer firstNode = tryRegion.getSubBlocks().get(0);
    if (!region.replaceSubBlock(firstNode, tryCatchRegion)) {
      return false;
    }
    subBlocks.removeAll(tryRegion.getSubBlocks());

    // fix parents for tryRegion sub blocks
    for (IContainer cont : tryRegion.getSubBlocks()) {
      if (cont instanceof AbstractRegion) {
        AbstractRegion aReg = (AbstractRegion) cont;
        aReg.setParent(tryRegion);
      }
    }
View Full Code Here

    return false;
  }

  private static BlockNode getTernaryInsnBlock(IContainer thenRegion) {
    if (thenRegion instanceof Region) {
      Region r = (Region) thenRegion;
      if (r.getSubBlocks().size() == 1) {
        IContainer container = r.getSubBlocks().get(0);
        if (container instanceof BlockNode) {
          BlockNode block = (BlockNode) container;
          if (block.getInstructions().size() == 1) {
            return block;
          }
View Full Code Here

    regionsCount++;
    if (regionsCount > REGIONS_LIMIT) {
      throw new JadxOverflowException("Regions count limit reached");
    }

    Region r = new Region(stack.peekRegion());
    BlockNode next = startBlock;
    while (next != null) {
      next = traverse(r, next, stack);
    }
    return r;
View Full Code Here

        // exit to already processed outer loop
        out = null;
      }
      stack.addExit(out);
      BlockNode loopBody = condInfo.getThenBlock();
      Region body = makeRegion(loopBody, stack);
      // add blocks from loop start to first condition block
      BlockNode conditionBlock = condInfo.getIfBlock();
      if (loopStart != conditionBlock) {
        Set<BlockNode> blocks = BlockUtils.getAllPathsBlocks(loopStart, conditionBlock);
        blocks.remove(conditionBlock);
        for (BlockNode block : blocks) {
          if (block.getInstructions().isEmpty()
              && !block.contains(AFlag.SKIP)
              && !RegionUtils.isRegionContainsBlock(body, block)) {
            body.add(block);
          }
        }
      }
      loopRegion.setBody(body);
    }
View Full Code Here

          loopExit = nextBlock;
        }
      }
    }

    Region body = makeRegion(loopStart, stack);
    BlockNode loopEnd = loop.getEnd();
    if (!RegionUtils.isRegionContainsBlock(body, loopEnd)
        && !loopEnd.contains(AType.EXC_HANDLER)) {
      body.getSubBlocks().add(loopEnd);
    }
    loopRegion.setBody(body);

    if (loopExit == null) {
      BlockNode next = getNextBlock(loopEnd);
View Full Code Here

    }
    for (Entry<BlockNode, List<Object>> entry : blocksMap.entrySet()) {
      BlockNode c = entry.getKey();
      if (stack.containsExit(c)) {
        // empty case block
        sw.addCase(entry.getValue(), new Region(stack.peekRegion()));
      } else {
        sw.addCase(entry.getValue(), makeRegion(c, stack));
      }
    }
View Full Code Here

        && insnsCount(ifRegion.getThenRegion()) == 2
        && insnsCount(ifRegion.getElseRegion()) == 2) {
      return false;
    }
    IRegion parent = ifRegion.getParent();
    Region newRegion = new Region(parent);
    if (parent.replaceSubBlock(ifRegion, newRegion)) {
      newRegion.add(ifRegion);
      newRegion.add(ifRegion.getElseRegion());
      ifRegion.setElseRegion(null);
      return true;
    }
    return false;
  }
View Full Code Here

TOP

Related Classes of jadx.core.dex.regions.Region

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.