/** * Return a MeasuredNode of the given condition node, without minimizing * the result. * <p> * Since a MinimizedCondition necessarily must contain two trees, * this method sets the negative side to a invalid node * with an unreasonably high length so that it will * never be chosen by {@link #getMinimized}. * * @param n the conditional expression tree * @return a MinimizedCondition object representing that tree. */ static MinimizedCondition unoptimized(Node n) { checkNotNull(n.getParent()); MeasuredNode pos = new MeasuredNode(n, null, 0, false); MeasuredNode neg = new MeasuredNode(null, null, Integer.MAX_VALUE, true); return new MinimizedCondition(pos, neg); }
/** * Return a MeasuredNode of the given condition node, without minimizing * the result. * <p> * Since a MinimizedCondition necessarily must contain two trees, this * method sets the negative side to a {@link Token#SCRIPT} node (never valid * inside an expression) with an unreasonably high length so that it will * never be chosen by {@link #getMinimized}. * * @param n the conditional expression tree to minimize. * This must be connected to the AST, and will be swapped * with a placeholder node during minimization. * @return a MinimizedCondition object representing that tree. */ static MinimizedCondition unoptimized(Node n) { Preconditions.checkNotNull(n.getParent()); Node placeholder = swapWithPlaceholderNode(n); MeasuredNode pos = new MeasuredNode(n, 0, false); MeasuredNode neg = new MeasuredNode(IR.script(), Integer.MAX_VALUE, true); return new MinimizedCondition(pos, neg).setPlaceholder(placeholder); }
subtree.negative.negate(), subtree.positive); return new MinimizedCondition(positive, negative); leftSubtree.negative, rightSubtree.negative).change()); return new MinimizedCondition(positive, negative); thenSubtree.negative, elseSubtree.negative); return new MinimizedCondition(positive, negative); MeasuredNode.forNode(lhs), rhsSubtree.negative); return new MinimizedCondition(positive, negative); return new MinimizedCondition(pos, neg);
subtree.negative.negate(), subtree.positive); return new MinimizedCondition( Collections.min(positiveAsts, AST_LENGTH_COMPARATOR), Collections.min(negativeAsts, AST_LENGTH_COMPARATOR)); leftSubtree.negative, rightSubtree.negative)); return new MinimizedCondition( Collections.min(positiveAsts, AST_LENGTH_COMPARATOR), Collections.min(negativeAsts, AST_LENGTH_COMPARATOR)); thenSubtree.negative, elseSubtree.negative); return new MinimizedCondition(posTree, negTree); new Node(Token.COMMA, lhs.cloneTree()).srcref(n), rhsSubtree.negative); return new MinimizedCondition(posTree, negTree); return new MinimizedCondition(pos, neg);