Examples of IfCondition


Examples of jadx.core.dex.regions.conditions.IfCondition

  /**
   * Simplify condition in ternary operation
   */
  private static void simplifyTernary(TernaryInsn insn) {
    IfCondition condition = insn.getCondition();
    if (condition.isCompare()) {
      simplifyIf(condition.getCompare().getInsn());
    } else {
      insn.simplifyCondition();
    }
  }
View Full Code Here

Examples of jadx.core.dex.regions.conditions.IfCondition

  private IfMakerHelper() {
  }

  static IfInfo makeIfInfo(BlockNode ifBlock) {
    IfNode ifNode = (IfNode) ifBlock.getInstructions().get(0);
    IfCondition condition = IfCondition.fromIfNode(ifNode);
    IfInfo info = new IfInfo(condition, ifNode.getThenBlock(), ifNode.getElseBlock());
    info.setIfBlock(ifBlock);
    info.getMergedBlocks().add(ifBlock);
    return info;
  }
View Full Code Here

Examples of jadx.core.dex.regions.conditions.IfCondition

    }
    return null;
  }

  private static IfInfo mergeTernaryConditions(IfInfo currentIf, IfInfo nextThen, IfInfo nextElse) {
    IfCondition newCondition = IfCondition.ternary(currentIf.getCondition(),
        nextThen.getCondition(), nextElse.getCondition());
    IfInfo result = new IfInfo(newCondition, nextThen.getThenBlock(), nextThen.getElseBlock());
    result.setIfBlock(currentIf.getIfBlock());
    result.merge(currentIf, nextThen, nextElse);
    confirmMerge(result);
View Full Code Here

Examples of jadx.core.dex.regions.conditions.IfCondition

  }

  private static IfInfo mergeIfInfo(IfInfo first, IfInfo second, boolean followThenBranch) {
    Mode mergeOperation = followThenBranch ? Mode.AND : Mode.OR;

    IfCondition condition = IfCondition.merge(mergeOperation, first.getCondition(), second.getCondition());
    IfInfo result = new IfInfo(condition, second);
    result.setIfBlock(first.getIfBlock());
    result.merge(first, second);

    BlockNode otherPathBlock = followThenBranch ? first.getElseBlock() : first.getThenBlock();
View Full Code Here

Examples of jadx.core.dex.regions.conditions.IfCondition

  private static void processLoopRegion(MethodNode mth, LoopRegion loopRegion) {
    if (loopRegion.isConditionAtEnd()) {
      return;
    }
    IfCondition condition = loopRegion.getCondition();
    if (condition == null) {
      return;
    }
    if (checkForIndexedLoop(mth, loopRegion, condition)) {
      return;
View Full Code Here

Examples of jadx.core.dex.regions.conditions.IfCondition

    markElseIfChains(ifRegion);
  }

  private static void simplifyIfCondition(IfRegion ifRegion) {
    if (ifRegion.simplifyCondition()) {
      IfCondition condition = ifRegion.getCondition();
      if (condition.getMode() == Mode.NOT) {
        invertIfRegion(ifRegion);
      }
    }
    IContainer elseRegion = ifRegion.getElseRegion();
    if (elseRegion == null || RegionUtils.isEmpty(elseRegion)) {
View Full Code Here

Examples of jadx.core.dex.regions.conditions.IfCondition

  @Test
  public void testNormalize() {
    // 'a != false' => 'a == true'
    InsnArg a = mockArg();
    IfCondition c = makeCondition(IfOp.NE, a, LiteralArg.FALSE);
    IfCondition simp = simplify(c);

    assertEquals(simp.getMode(), Mode.COMPARE);
    Compare compare = simp.getCompare();
    assertEquals(compare.getA(), a);
    assertEquals(compare.getB(), LiteralArg.TRUE);
  }
View Full Code Here

Examples of jadx.core.dex.regions.conditions.IfCondition

    assertEquals(compare.getB(), LiteralArg.TRUE);
  }

  @Test
  public void testMerge() {
    IfCondition a = makeSimpleCondition();
    IfCondition b = makeSimpleCondition();
    IfCondition c = merge(Mode.OR, a, b);

    assertEquals(c.getMode(), Mode.OR);
    assertEquals(c.first(), a);
    assertEquals(c.second(), b);
  }
View Full Code Here

Examples of jadx.core.dex.regions.conditions.IfCondition

  }

  @Test
  public void testSimplifyNot() {
    // !(!a) => a
    IfCondition a = not(not(makeSimpleCondition()));
    assertEquals(simplify(a), a);
  }
View Full Code Here

Examples of jadx.core.dex.regions.conditions.IfCondition

  }

  @Test
  public void testSimplifyNot2() {
    // !(!a) => a
    IfCondition a = not(makeNegCondition());
    assertEquals(simplify(a), a);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.