@Override protected void visitExprNode(ExprNode node) {
if (! (node instanceof ParentExprNode)) {
return;
}
ParentExprNode nodeAsParent = (ParentExprNode) node;
// Recurse.
visitChildren(nodeAsParent);
// If all children are constants, we attempt to preevaluate this node and replace it with a
// constant.
for (ExprNode child : nodeAsParent.getChildren()) {
if (! (child instanceof ConstantNode)) {
return; // cannot preevaluate
}
}
attemptPreeval(nodeAsParent);