Clean TreeNode

This commit is contained in:
Léa Saviot
2018-06-22 10:39:40 +02:00
parent edce759ae5
commit ac182b04d1
2 changed files with 37 additions and 46 deletions

View File

@@ -2,7 +2,7 @@
#include "tree_pool.h"
#include "expression_node.h"
TreeNode * TreeNode::parent() const {
TreeNode * TreeNode::treeParent() const {
int cursor = -1;
TreeNode * parentsHistory[TreePool::MaxNumberOfNodes];
int numberOfChildrenHistory[TreePool::MaxNumberOfNodes];
@@ -31,6 +31,19 @@ TreeNode * TreeNode::parent() const {
return nullptr;
}
TreeNode * TreeNode::treeChildAtIndex(int i) const {
assert(i >= 0);
assert(i < numberOfChildren());
TreeNode * child = next();
while (i > 0) {
child = child->nextSibling();
assert(child != nullptr);
i--;
}
return child;
}
void TreeNode::release() {
printf("Release %d(%p)\n", m_identifier, this);
m_referenceCounter--;