public class ExpressionTreeElement
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private ExpressionTreeElement[] |
childElements
The array contains links to the tree element children
|
private static ExpressionTreeElement[] |
EMPTY
Empty array to avoid unnecessary operations
|
private FilePositionInfo[] |
includeStack
Current include stack of the preprocessor to the source string.
|
private int |
nextChildSlot
Because I fill children sequentially, the variable contains the index of
the first empty child slot
|
private static OperatorSUB |
OPERATOR_SUB
Inside constant to be used for speed up some operations
|
private ExpressionTreeElement |
parentTreeElement
The link to the parent element, if it is the tree root then it contains
null
|
private int |
priority
The priority of the tree element, it is very strongly used during tree
sorting
|
private ExpressionItem |
savedItem
The variable contains the wrapped expression item
|
private java.lang.String |
sourceString
Contains the source string for the expression.
|
Constructor and Description |
---|
ExpressionTreeElement(ExpressionItem item,
FilePositionInfo[] callStack,
java.lang.String sourceString)
The constructor
|
Modifier and Type | Method and Description |
---|---|
private void |
addElementToNextFreeSlot(ExpressionTreeElement element)
Add an expression element into the next free child slot
|
ExpressionTreeElement |
addSubTree(ExpressionTree tree)
Add a tree as new child and make the maximum priority for it
|
ExpressionTreeElement |
addTreeElement(ExpressionTreeElement element)
Add tree element with sorting operation depends on priority of the elements
|
void |
fillArguments(java.util.List<ExpressionTree> arguments)
It fills children slots from a list containing expression trees
|
int |
getArity()
Get arity for the element (I mean possible children number)
|
ExpressionTreeElement |
getChildForIndex(int index)
Get the child element for its index (the first is 0)
|
ExpressionItem |
getItem()
Get the wrapped item
|
ExpressionTreeElement |
getParent()
Get the parent for the element
|
int |
getPriority()
Get the current priority of the element
|
boolean |
isFull()
It allows to check that all children slots have been filled
|
(package private) void |
makeMaxPriority()
Inside auxiliary function to set the maximum priority the the element
|
void |
postProcess()
Post-processing after the tree is formed, the unary minus operation will be
optimized
|
boolean |
replaceElement(ExpressionTreeElement oldOne,
ExpressionTreeElement newOne)
It replaces a child element
|
private static final OperatorSUB OPERATOR_SUB
private static final ExpressionTreeElement[] EMPTY
private ExpressionItem savedItem
private ExpressionTreeElement[] childElements
private ExpressionTreeElement parentTreeElement
private int priority
private int nextChildSlot
private final java.lang.String sourceString
private final FilePositionInfo[] includeStack
ExpressionTreeElement(ExpressionItem item, FilePositionInfo[] callStack, java.lang.String sourceString)
item
- an expression item to be wrapped, must not be nullvoid makeMaxPriority()
public ExpressionItem getItem()
public int getArity()
public ExpressionTreeElement getParent()
public int getPriority()
public ExpressionTreeElement addSubTree(ExpressionTree tree)
tree
- a tree to be added as a child, must not be nullpublic boolean replaceElement(ExpressionTreeElement oldOne, ExpressionTreeElement newOne)
oldOne
- the old expression element to be replaced (must not be null)newOne
- the new expression element to be used instead the old one
(must not be null)public ExpressionTreeElement getChildForIndex(int index)
index
- the index of the needed childjava.lang.ArrayIndexOutOfBoundsException
- it will be thrown if an impossible
index is being usedpublic ExpressionTreeElement addTreeElement(ExpressionTreeElement element)
element
- the element to be added, must not be nullpublic boolean isFull()
public void fillArguments(java.util.List<ExpressionTree> arguments)
arguments
- the list containing trees to be used as childrenprivate void addElementToNextFreeSlot(ExpressionTreeElement element)
element
- an element to be added, must not be nullpublic void postProcess()