コード例 #1
0
 private static boolean conditionalExpressionsAreEquivalent(
     @NotNull GrConditionalExpression condExp1, @NotNull GrConditionalExpression condExp2) {
   final GrExpression condition1 = condExp1.getCondition();
   final GrExpression condition2 = condExp2.getCondition();
   final GrExpression thenExpression1 = condExp1.getThenBranch();
   final GrExpression thenExpression2 = condExp2.getThenBranch();
   final GrExpression elseExpression1 = condExp1.getElseBranch();
   final GrExpression elseExpression2 = condExp2.getElseBranch();
   return expressionsAreEquivalent(condition1, condition2)
       && expressionsAreEquivalent(thenExpression1, thenExpression2)
       && expressionsAreEquivalent(elseExpression1, elseExpression2);
 }
コード例 #2
0
  @Override
  public void visitConditionalExpression(GrConditionalExpression expression) {
    GrExpression condition = expression.getCondition();
    GrExpression thenBranch = expression.getThenBranch();
    GrExpression elseBranch = expression.getElseBranch();

    condition.accept(this);
    InstructionImpl conditionEnd = myHead;
    List<GotoInstruction> negations = collectAndRemoveAllPendingNegations(expression);

    if (thenBranch != null) {
      thenBranch.accept(this);
      handlePossibleReturn(thenBranch);
      addPendingEdge(expression, myHead);
    }

    if (elseBranch != null) {
      InstructionImpl head = reduceAllNegationsIntoInstruction(expression, negations);
      myHead = head != null ? head : conditionEnd;
      elseBranch.accept(this);
      handlePossibleReturn(elseBranch);
    }
  }