#ifndef EXPRESSION_REFERENCE_H #define EXPRESSION_REFERENCE_H #include "tree_reference.h" #include "expression_node.h" #include template class ExpressionReference : public TreeReference { public: using TreeReference::TreeReference; // Allow every ExpressionReference to be transformed into an ExpressionReference, i.e. Expression operator ExpressionReference() const { return ExpressionReference(this->node()); } static ExpressionReference staticFailedAllocationStaticRef(); static TreeNode * staticFailedAllocationStaticNode(); void addChild(ExpressionReference e) { if (!this->node()->isAllocationFailure()) { TreeReference::addTreeChild(e); } } void addChildAtIndex(ExpressionReference e, int index) { if (!this->node()->isAllocationFailure()) { TreeReference::addTreeChildAtIndex(e, index); } } ExpressionReference childAtIndex(int i) { return ExpressionReference(TreeReference::treeChildAtIndex(i).node()); } void replaceChildAtIndex(int oldChildIndex, ExpressionReference newChild) { TreeReference::replaceChildAtIndex(oldChildIndex, newChild); } float approximate() const { return this->castedNode()->approximate(); } /* ExpressionReference simplify() { return node()->simplify(); } */ }; typedef ExpressionReference ExpressionRef; #endif