* @param parent The parent node to attempt to rewrite.
* @return The rewritten node, if it was rewritten.
*/
private ProgramNode tryPlusNeg(ProgramNode parent) {
if (parent.getName().equals("+") && parent.getChildNodes().size() == 2) {
final ProgramNode child1 = parent.getChildNode(0);
final ProgramNode child2 = parent.getChildNode(1);
if (child2.getName().equals("-")
&& child2.getChildNodes().size() == 1) {
parent = parent
.getOwner()
.getContext()
.getFunctions()
.factorProgramNode(
"-",
parent.getOwner(),
new ProgramNode[] { child1,
child2.getChildNode(0) });
} else if (child2.getName().equals("#const")) {
final ExpressionValue v = child2.getData()[0];
if (v.isFloat()) {
final double v2 = v.toFloatValue();
if (v2 < 0) {
child2.getData()[0] = new ExpressionValue(-v2);
parent = parent
.getOwner()
.getContext()
.getFunctions()
.factorProgramNode("-", parent.getOwner(),
new ProgramNode[] { child1, child2 });
}
} else if (v.isInt()) {
final long v2 = v.toIntValue();
if (v2 < 0) {
child2.getData()[0] = new ExpressionValue(-v2);
parent = parent
.getOwner()
.getContext()
.getFunctions()
.factorProgramNode("-", parent.getOwner(),