@Override public void visit(Division node) { resultValue = new Multiplication(node.getLeft(), new MathFunctionCall(node.getRight(), MathFunction.INVERT)); } };
@Override public void visit(Division node) { if (node.getRight() instanceof FloatConstant) { FloatConstant newLeft = new FloatConstant(1/((FloatConstant) node.getRight()).getValue()); replaceWith = new Multiplication(newLeft, node.getLeft()); } }
@Override public void visit(Negation node) { node.getOperand().accept(this); if (result != zero) result = new Negation(result); }
@Override public void visit(Negation node) { node.getOperand().accept(this); result = -result; }
@Override public void visit(LogicalNegation node) { result = null; node.getOperand().accept(this); if (result != null) result = new LogicalNegation(result); }
@Override public void visit(LogicalAnd node) { result = null; node.getLeft().accept(this); Expression leftResult = result; node.getRight().accept(this); Expression rightResult = result; if (leftResult != null || rightResult != null) result = new LogicalAnd(leftResult, rightResult); }
/** * Returns if the exponentiation has an exponent which is equal to 2 * @param exponentiation The exponentiation * @return <value>true</value> if the exponent is equal to 2, <value>false</value> otherwise */ protected boolean isSquare(Exponentiation exponentiation) { final FloatConstant two = new FloatConstant(2.0f); return two.equals(exponentiation.getRight()); }
/** * Visits a UnaryOperation instance * @param unaryOperation The UnaryOperation */ private void visitUnaryOperation(UnaryOperation unaryOperation) { unaryOperation.getOperand().accept(this); if (replace) { unaryOperation.setOperand(toReplace); replace = false; } }
@Override public void visit(MacroCall node) { for (Expression arg : node.getArguments()) { arg.accept(this); } }
/** * Converts this node into a human readable string. * * @return The string "<code>left</code> + <code>right</code>", where left and right are the results of the toString * methods of the left and right operand. */ public String toString() { return bracketComposite(getLeft()) + " + " + bracketComposite(getRight()); }
@Override public void visit(MultivectorComponent node) { result = (node.equals(diffVar)) ? new FloatConstant(1) : zero; }