Examples of IfCondition


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

  }

  @Test
  public void testSimplify() {
    // '!(!a || !b)' => 'a && b'
    IfCondition a = makeSimpleCondition();
    IfCondition b = makeSimpleCondition();
    IfCondition c = not(merge(Mode.OR, not(a), not(b)));
    IfCondition simp = simplify(c);

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

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

  }

  @Test
  public void testSimplify2() {
    // '(!a || !b) && !c' => '!((a && b) || c)'
    IfCondition a = makeSimpleCondition();
    IfCondition b = makeSimpleCondition();
    IfCondition c = makeSimpleCondition();
    IfCondition cond = merge(Mode.AND, merge(Mode.OR, not(a), not(b)), not(c));
    IfCondition simp = simplify(cond);

    assertEquals(simp.getMode(), Mode.NOT);
    IfCondition f = simp.first();
    assertEquals(f.getMode(), Mode.OR);
    assertEquals(f.first().getMode(), Mode.AND);
    assertEquals(f.first().first(), a);
    assertEquals(f.first().second(), b);
    assertEquals(f.second(), c);
  }
View Full Code Here

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

    LoopLabelAttr labelAttr = region.getInfo().getStart().get(AType.LOOP_LABEL);
    if (labelAttr != null) {
      code.startLine(mgen.getNameGen().getLoopLabel(labelAttr)).add(':');
    }

    IfCondition condition = region.getCondition();
    if (condition == null) {
      // infinite loop
      code.startLine("while (true) {");
      makeRegionIndent(code, region.getBody());
      code.startLine('}');
View Full Code Here

Examples of org.apache.drill.common.expression.IfExpression.IfCondition

  @Override
  public Void visitIfExpression(IfExpression ifExpr, StringBuilder sb) throws RuntimeException {
    ImmutableList<IfCondition> conditions = ifExpr.conditions;
    sb.append(" ( ");
    for(int i =0; i < conditions.size(); i++){
      IfCondition c = conditions.get(i);
      if(i !=0) sb.append(" else ");
      sb.append("if (");
      c.condition.accept(this, sb);
      sb.append(" ) then (");
      c.expression.accept(this, sb);
View Full Code Here

Examples of org.apache.drill.common.expression.IfExpression.IfCondition

      HoldingContainer output = generator.declare(ifExpr.getMajorType());

      JConditional jc = null;
      JBlock conditionalBlock = new JBlock(false, false);
      IfCondition c = ifExpr.ifCondition;

      HoldingContainer holdingContainer = c.condition.accept(this, generator);
      if (jc == null) {
        if (holdingContainer.isOptional()) {
          jc = conditionalBlock._if(holdingContainer.getIsSet().eq(JExpr.lit(1)).cand(holdingContainer.getValue().eq(JExpr.lit(1))));
View Full Code Here

Examples of org.apache.drill.common.expression.IfExpression.IfCondition

          assert caseArgs.size()%2 == 1;
          LogicalExpression elseExpression = caseArgs.get(0);
          for (int i=1; i<caseArgs.size(); i=i+2) {
            elseExpression = IfExpression.newBuilder()
              .setElse(elseExpression)
              .setIfCondition(new IfCondition(caseArgs.get(i + 1), caseArgs.get(i))).build();
          }
          return elseExpression;
        }

        if (call.getOperator() == SqlStdOperatorTable.ITEM) {
View Full Code Here

Examples of org.apache.drill.common.expression.IfExpression.IfCondition

  @Override
  public Void visitIfExpression(IfExpression ifExpr, StringBuilder sb) throws RuntimeException {

    // serialize the if expression
    sb.append(" ( ");
    IfCondition c = ifExpr.ifCondition;
    sb.append("if (");
    c.condition.accept(this, sb);
    sb.append(" ) then (");
    c.expression.accept(this, sb);
    sb.append(" ) ");
View Full Code Here

Examples of org.apache.drill.common.expression.IfExpression.IfCondition

    return false;
  }

  @Override
  public Boolean visitIfExpression(IfExpression ifExpr, ErrorCollector errors) {
    IfCondition c = ifExpr.ifCondition;
    if (c.condition.accept(this, errors) || c.expression.accept(this, errors)) {
      return true;
    }
    return ifExpr.elseExpression.accept(this, errors);
  }
View Full Code Here

Examples of org.apache.drill.common.expression.IfExpression.IfCondition

    return true;
  }

  @Override
  public Boolean visitIfExpression(IfExpression ifExpr, ErrorCollector errors) {
    IfCondition c = ifExpr.ifCondition;
    if (!c.condition.accept(this, errors) || !c.expression.accept(this, errors)) {
      return false;
    }

    if (!ifExpr.elseExpression.accept(this, errors)) {
View Full Code Here

Examples of org.apache.drill.common.expression.IfExpression.IfCondition


  @Override
  public LogicalExpression visitIfExpression(IfExpression ifExpr, Void value) throws RuntimeException{
    LogicalExpression newElseExpr = ifExpr.elseExpression.accept(this, value);
    IfCondition conditions = ifExpr.ifCondition;

    LogicalExpression newCondition = conditions.condition.accept(this, value);
    LogicalExpression newExpr = conditions.expression.accept(this, value);
    conditions = new IfExpression.IfCondition(newCondition, newExpr);
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.