/** * Split the left term and transform it into the right deep expression. * * @param binary - notice the left term of this expr will be eliminated * after done. * @return the separated expression changed into the right deep expression. * For example, the expr 'x * y' is transformed into '* x'. * */ public static PartialBinaryExpr splitLeftTerm(BinaryEval binary) { if (!(EvalType.isArithmeticOperator(binary.getType()))) { throw new AlgebraicException("Invalid algebraic operation: " + binary); } if (binary.getLeftExpr() instanceof BinaryEval) { return splitLeftTerm((BinaryEval) binary.getLeftExpr()); } PartialBinaryExpr splitted = new PartialBinaryExpr(binary.getType(), null, binary.getLeftExpr()); binary.setLeftExpr(null); return splitted; }
/** * Split the left term and transform it into the right deep expression. * * @param binary - notice the left term of this expr will be eliminated * after done. * @return the separated expression changed into the right deep expression. * For example, the expr 'x * y' is transformed into '* x'. * */ public static PartialBinaryExpr splitLeftTerm(BinaryEval binary) { if (!(EvalType.isArithmeticOperator(binary.getType()))) { throw new AlgebraicException("Invalid algebraic operation: " + binary); } if (binary.getLeftExpr() instanceof BinaryEval) { return splitLeftTerm((BinaryEval) binary.getLeftExpr()); } PartialBinaryExpr splitted = new PartialBinaryExpr(binary.getType(), null, binary.getLeftExpr()); binary.setLeftExpr(null); return splitted; }
} else { PartialBinaryExpr tmpTerm = splitLeftTerm((BinaryEval) left); tmpTerm.type = inverseOperator(tmpTerm.type); tmpTerm.setLeftExpr(((BinaryEval)expr).getRightExpr());
} else { PartialBinaryExpr tmpTerm = splitLeftTerm((BinaryEval) left); tmpTerm.type = inverseOperator(tmpTerm.type); tmpTerm.setLeftExpr(((BinaryEval)expr).getRightExpr());