Package jadx.core.dex.nodes

Examples of jadx.core.dex.nodes.IRegion


    regionStack.push(region);
  }

  @Override
  public final void processBlock(MethodNode mth, IBlock container) {
    IRegion curRegion = regionStack.peek();
    processBlockTraced(mth, container, curRegion);
  }
View Full Code Here


      Usage u = entry.getValue();

      // find region which contain all usage regions
      Set<IRegion> set = u.getUseRegions();
      for (Iterator<IRegion> it = set.iterator(); it.hasNext(); ) {
        IRegion r = it.next();
        IRegion parent = r.getParent();
        if (parent != null && set.contains(parent)) {
          it.remove();
        }
      }
      IRegion region = null;
      if (!set.isEmpty()) {
        region = set.iterator().next();
      } else if (!u.getAssigns().isEmpty()) {
        region = u.getAssigns().iterator().next();
      }
      if (region == null) {
        continue;
      }
      IRegion parent = region;
      boolean declare = false;
      while (parent != null) {
        if (canDeclareInRegion(u, region, regionsOrder)) {
          declareVar(region, u.getArg());
          declare = true;
View Full Code Here

  private static int calculateOrder(IContainer container, Map<IContainer, Integer> regionsOrder,
      int id, boolean inc) {
    if (!(container instanceof IRegion)) {
      return id;
    }
    IRegion region = (IRegion) container;
    Integer previous = regionsOrder.put(region, id);
    if (previous != null) {
      return id;
    }
    for (IContainer c : region.getSubBlocks()) {
      if (c instanceof IfRegion
          || c instanceof SwitchRegion) {
        // on branch set for all inner regions same order id
        id = calculateOrder(c, regionsOrder, inc ? id + 1 : id, false);
      } else {
View Full Code Here

  private static void traverseInternal(MethodNode mth, IRegionVisitor visitor, IContainer container) {
    if (container instanceof IBlock) {
      visitor.processBlock(mth, (IBlock) container);
    } else if (container instanceof IRegion) {
      IRegion region = (IRegion) container;
      visitor.enterRegion(mth, region);
      for (IContainer subCont : region.getSubBlocks()) {
        traverseInternal(mth, visitor, subCont);
      }
      visitor.leaveRegion(mth, region);
    }
  }
View Full Code Here

    return false;
  }

  private static boolean traverseIterativeInternal(MethodNode mth, IRegionIterativeVisitor visitor, IContainer container) {
    if (container instanceof IRegion) {
      IRegion region = (IRegion) container;
      if (visitor.visitRegion(mth, region)) {
        return true;
      }
      for (IContainer subCont : region.getSubBlocks()) {
        if (traverseIterativeInternal(mth, visitor, subCont)) {
          return true;
        }
      }
    }
View Full Code Here

  /**
   * Extract all block dominated by 'dominator' to separate region and mark as try/catch block
   */
  private static boolean wrapBlocks(IRegion replaceRegion, TryCatchBlock tb, BlockNode dominator) {
    IRegion region = replaceRegion;
    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
View Full Code Here

    private static boolean isEmpty(IContainer container) {
      if (container instanceof BlockNode) {
        BlockNode block = (BlockNode) container;
        return block.getInstructions().isEmpty() || block.contains(AFlag.RETURN);
      } else if (container instanceof IRegion) {
        IRegion region = (IRegion) container;
        for (IContainer block : region.getSubBlocks()) {
          if (!isEmpty(block)) {
            return false;
          }
        }
        return true;
View Full Code Here

      BlockNode exit = makeEndlessLoop(curRegion, stack, loop, loopStart);
      insertContinue(loop);
      return exit;
    }
    curRegion.getSubBlocks().add(loopRegion);
    IRegion outerRegion = stack.peekRegion();
    stack.push(loopRegion);

    IfInfo condInfo = makeIfInfo(loopRegion.getHeader());
    condInfo = searchNestedIf(condInfo);
    confirmMerge(condInfo);
View Full Code Here

      }
    }

    private void processRegion(MethodNode mth, IContainer region) {
      if (region instanceof IRegion) {
        IRegion r = (IRegion) region;
        dot.startLine("subgraph " + makeName(region) + " {");
        dot.startLine("label = \"").add(r.toString());
        String attrs = attributesString(r);
        if (attrs.length() != 0) {
          dot.add(" | ").add(attrs);
        }
        dot.add("\";");
        dot.startLine("node [shape=record,color=blue];");

        for (IContainer c : r.getSubBlocks()) {
          processRegion(mth, c);
        }

        dot.startLine('}');
      } else if (region instanceof BlockNode) {
View Full Code Here

    if (mth.getReturnType() == ArgType.VOID
        && 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;
    }
View Full Code Here

TOP

Related Classes of jadx.core.dex.nodes.IRegion

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.