Class CombinedBinaryExpression

java.lang.Object
All Implemented Interfaces:
OperatorIds, TypeConstants, TypeIds

public class CombinedBinaryExpression extends BinaryExpression
CombinedBinaryExpression is an implementation of BinaryExpression that specifically attempts to mitigate the issues raised by expressions which have a very deep leftmost branch. It does so by maintaining a table of direct references to its subexpressions, and implementing non-recursive variants of the most significant recursive algorithms of its ancestors. The subexpressions table only holds intermediate binary expressions. Its role is to provide the reversed navigation through the left relationship of BinaryExpression to Expression. To cope with potentially very deep left branches, an instance of CombinedBinaryExpression is created once in a while, using variable thresholds held by arityMax. As a specific case, the topmost node of all binary expressions that are deeper than one is a CombinedBinaryExpression, but it has no references table.
Notes:
  • CombinedBinaryExpression is not meant to behave in other ways than BinaryExpression in any observable respect;
  • visitors that implement their own traversal upon binary expressions should consider taking advantage of combined binary expressions, or else face a risk of StackOverflowError upon deep instances;
  • callers that need to change the operator should rebuild the expression from scratch, or else amend the references table as needed to cope with the resulting, separated expressions.