From ea948117a4146aff2f28dede24a688d43608e17c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Wed, 5 Sep 2018 17:54:08 +0200 Subject: [PATCH] [poincare] Remove ExceptionNodes and UninitializedNodes --- poincare/Makefile | 5 - poincare/include/poincare/evaluation.h | 7 +- .../poincare/exception_evaluation_node.h | 30 ------ .../poincare/exception_expression_node.h | 39 -------- .../include/poincare/exception_layout_node.h | 96 ------------------- poincare/include/poincare/exception_node.h | 20 ---- poincare/include/poincare/expression.h | 2 +- poincare/include/poincare/expression_node.h | 2 - poincare/include/poincare/ghost_node.h | 2 - .../include/poincare/integral_layout_node.h | 5 +- poincare/include/poincare/layout_node.h | 5 +- poincare/include/poincare/layout_reference.h | 3 +- .../include/poincare/nth_root_layout_node.h | 2 +- .../include/poincare/sequence_layout_node.h | 5 +- poincare/include/poincare/tree_by_reference.h | 6 +- poincare/include/poincare/tree_node.h | 4 - .../poincare/uninitialized_evaluation_node.h | 29 ------ .../poincare/uninitialized_expression_node.h | 42 -------- .../poincare/uninitialized_ghost_node.h | 26 ----- .../poincare/uninitialized_layout_node.h | 85 ---------------- .../src/binomial_coefficient_layout_node.cpp | 6 +- poincare/src/bracket_layout_node.cpp | 8 +- poincare/src/bracket_pair_layout_node.cpp | 12 +-- poincare/src/char_layout_node.cpp | 4 +- poincare/src/condensed_sum_layout_node.cpp | 8 +- poincare/src/conjugate_layout_node.cpp | 12 +-- poincare/src/empty_layout_node.cpp | 8 +- poincare/src/evaluation.cpp | 13 --- poincare/src/expression.cpp | 2 - poincare/src/expression_node.cpp | 4 - poincare/src/fraction_layout_node.cpp | 24 ++--- poincare/src/ghost_node.cpp | 11 --- poincare/src/grid_layout_node.cpp | 4 +- poincare/src/horizontal_layout_node.cpp | 19 ++-- poincare/src/init.cpp | 6 -- poincare/src/integral_layout_node.cpp | 38 +++----- poincare/src/layout_node.cpp | 20 ++-- poincare/src/layout_reference.cpp | 3 - poincare/src/matrix_layout_node.cpp | 1 - poincare/src/nth_root_layout_node.cpp | 39 ++++---- poincare/src/sequence_layout_node.cpp | 34 ++----- poincare/src/tree_node.cpp | 8 +- poincare/src/tree_pool.cpp | 4 +- .../src/uninitialized_evaluation_node.cpp | 15 --- .../src/uninitialized_expression_node.cpp | 10 -- poincare/src/uninitialized_ghost_node.cpp | 10 -- poincare/src/uninitialized_layout_node.cpp | 11 --- poincare/src/vertical_offset_layout_node.cpp | 26 ++--- poincare/test/tree/blob_node.cpp | 15 --- poincare/test/tree/blob_node.h | 15 --- poincare/test/tree/pair_node.cpp | 15 --- poincare/test/tree/pair_node.h | 15 --- 52 files changed, 115 insertions(+), 720 deletions(-) delete mode 100644 poincare/include/poincare/exception_evaluation_node.h delete mode 100644 poincare/include/poincare/exception_expression_node.h delete mode 100644 poincare/include/poincare/exception_layout_node.h delete mode 100644 poincare/include/poincare/exception_node.h delete mode 100644 poincare/include/poincare/uninitialized_evaluation_node.h delete mode 100644 poincare/include/poincare/uninitialized_expression_node.h delete mode 100644 poincare/include/poincare/uninitialized_ghost_node.h delete mode 100644 poincare/include/poincare/uninitialized_layout_node.h delete mode 100644 poincare/src/ghost_node.cpp delete mode 100644 poincare/src/uninitialized_evaluation_node.cpp delete mode 100644 poincare/src/uninitialized_expression_node.cpp delete mode 100644 poincare/src/uninitialized_ghost_node.cpp delete mode 100644 poincare/src/uninitialized_layout_node.cpp delete mode 100644 poincare/test/tree/blob_node.cpp delete mode 100644 poincare/test/tree/pair_node.cpp diff --git a/poincare/Makefile b/poincare/Makefile index 55e0b7a9c..284fd91d2 100644 --- a/poincare/Makefile +++ b/poincare/Makefile @@ -69,7 +69,6 @@ objs += $(addprefix poincare/src/,\ float.o\ floor.o\ frac_part.o\ - ghost_node.o\ global_context.o\ great_common_divisor.o\ hyperbolic_arc_cosine.o\ @@ -125,10 +124,6 @@ objs += $(addprefix poincare/src/,\ tree_by_reference.o\ trigonometry.o\ undefined.o\ - uninitialized_evaluation_node.o\ - uninitialized_expression_node.o\ - uninitialized_ghost_node.o\ - uninitialized_layout_node.o\ variable_context.o\ ) diff --git a/poincare/include/poincare/evaluation.h b/poincare/include/poincare/evaluation.h index 1c4aa3107..a884c802b 100644 --- a/poincare/include/poincare/evaluation.h +++ b/poincare/include/poincare/evaluation.h @@ -31,15 +31,12 @@ public: virtual Expression complexToExpression(Preferences::ComplexFormat complexFormat) const = 0; virtual std::complex trace() const = 0; virtual std::complex determinant() const = 0; - - // TreeNode - TreeNode * uninitializedStaticNode() const override; }; template class Evaluation : public TreeByReference { public: - Evaluation(); + Evaluation() : TreeByReference() {} template explicit operator U() const { // See Expression::operator T() for explanations on this operator // TODO add assertions to ensure that we cast only to evaluation subclasses @@ -47,7 +44,7 @@ public: return *reinterpret_cast(const_cast *>(this)); } EvaluationNode * node() const { - assert(TreeByReference::node() == nullptr || !TreeByReference::node()->isGhost()); + assert(!TreeByReference::node()->isGhost()); return static_cast *>(TreeByReference::node()); } diff --git a/poincare/include/poincare/exception_evaluation_node.h b/poincare/include/poincare/exception_evaluation_node.h deleted file mode 100644 index 0b52c9b8d..000000000 --- a/poincare/include/poincare/exception_evaluation_node.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef POINCARE_EXCEPTION_EVALUATION_NODE_H -#define POINCARE_EXCEPTION_EVALUATION_NODE_H - -#include -#include -#include -#include - -namespace Poincare { - -template class T, class U> -class ExceptionEvaluationNode : public ExceptionNode > { -public: - // EvaluationNode - typename EvaluationNode::Type type() const override { return EvaluationNode::Type::Exception; } - bool isUndefined() const override { return true; } - U toScalar() const override { return NAN; } - Expression complexToExpression(Preferences::Preferences::ComplexFormat complexFormat) const override { return Undefined(); } - std::complex trace() const override { return std::complex(NAN); } - std::complex determinant() const override { return std::complex(NAN); } - // TreeNode - size_t size() const override { return sizeof(ExceptionEvaluationNode); } -#if TREE_LOG - const char * description() const override { return "ExceptionEvaluation"; } -#endif -}; - -} - -#endif diff --git a/poincare/include/poincare/exception_expression_node.h b/poincare/include/poincare/exception_expression_node.h deleted file mode 100644 index e764a0b09..000000000 --- a/poincare/include/poincare/exception_expression_node.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef POINCARE_EXCEPTION_EXPRESSION_NODE_H -#define POINCARE_EXCEPTION_EXPRESSION_NODE_H - -#include -#include -#include -#include -#include -#include - -namespace Poincare { - -template -class ExceptionExpressionNode : public ExceptionNode { -public: - // ExpressionNode - void setChildrenInPlace(Expression other) override {} - ExpressionNode::Sign sign() const override { return ExpressionNode::Sign::Unknown; } - Expression setSign(ExpressionNode::Sign s, Context & context, Preferences::AngleUnit angleUnit) override { return Expression(this).clone(); } - int polynomialDegree(char symbolName) const override { return -1; } - - Evaluation approximate(ExpressionNode::SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override { return Complex::Undefined(); } - Evaluation approximate(ExpressionNode::DoublePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override { return Complex::Undefined(); } - - int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode = Preferences::PrintFloatMode::Decimal, int numberOfSignificantDigits = 0) const override { - if (bufferSize == 0) { - return -1; - } - return PrintFloat::convertFloatToText(NAN, buffer, bufferSize, numberOfSignificantDigits, floatDisplayMode); - } - - LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override { assert(false); return CharLayoutRef('a'); } //TODO ? - - Expression denominator(Context & context, Preferences::AngleUnit angleUnit) const override { return Expression(this).clone(); } -}; - -} - -#endif diff --git a/poincare/include/poincare/exception_layout_node.h b/poincare/include/poincare/exception_layout_node.h deleted file mode 100644 index f90649b0c..000000000 --- a/poincare/include/poincare/exception_layout_node.h +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef POINCARE_EXCEPTION_LAYOUT_NODE_H -#define POINCARE_EXCEPTION_LAYOUT_NODE_H - -#include -#include -#include -#include - -namespace Poincare { - -template -class ExceptionLayoutNode : public ExceptionNode { -public: - // LayoutNode - int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override { - assert(false); - return 0; - /* - int descriptionLength = strlen(description()) + 1; - return strlcpy(buffer, description(), bufferSize < descriptionLength ? bufferSize : descriptionLength); - */ - } - - // Rendering - void invalidAllSizesPositionsAndBaselines() override {} - - // Tree navigation - void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override {} - void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override {} - void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override {} - void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override {} - LayoutCursor equivalentCursor(LayoutCursor * cursor) override { return LayoutCursor(); } - - // Tree modification - - // Collapse - bool shouldCollapseSiblingsOnLeft() const override { return false; } - bool shouldCollapseSiblingsOnRight() const override { return false; } - int leftCollapsingAbsorbingChildIndex() const override { assert(false); return 0; } - int rightCollapsingAbsorbingChildIndex() const override { assert(false); return 0; } - void didCollapseSiblings(LayoutCursor * cursor) override {} - - //User input - void deleteBeforeCursor(LayoutCursor * cursor) override {} - - // Other - LayoutNode * layoutToPointWhenInserting() override { return this; } - bool hasText() const override { return false; } - bool isCollapsable(int * numberOfOpenParenthesis, bool goingLeft) const override { return false; } - bool canBeOmittedMultiplicationLeftFactor() const override { return false; } - bool canBeOmittedMultiplicationRightFactor() const override { return false; } - bool mustHaveLeftSibling() const override { return false; } - bool isVerticalOffset() const override { return false; } - bool isHorizontal() const override { return false; } - bool isLeftParenthesis() const override { return false; } - bool isRightParenthesis() const override { return false; } - bool isLeftBracket() const override { return false; } - bool isRightBracket() const override { return false; } - bool isEmpty() const override { return false; } - bool isMatrix() const override { return false; } - bool hasUpperLeftIndex() const override { return false; } - - bool willAddChildAtIndex(LayoutNode * l, int * index, int * currentNumberOfChildren, LayoutCursor * cursor) override { return false; } - bool willAddSibling(LayoutCursor * cursor, LayoutNode * sibling, bool moveCursor) override { return false; } - void willAddSiblingToEmptyChildAtIndex(int childIndex) override {} - bool willReplaceChild(LayoutNode * oldChild, LayoutNode * newChild, LayoutCursor * cursor, bool force) override { return false; } - void didReplaceChildAtIndex(int index, LayoutCursor * cursor, bool force) override {} - bool willRemoveChild(LayoutNode * l, LayoutCursor * cursor, bool force) override { return false; } - void didRemoveChildAtIndex(int index, LayoutCursor * cursor, bool force) override {} - - // TreeNode - void incrementNumberOfChildren(int increment = 1) override {} - void decrementNumberOfChildren(int decrement = 1) override {} - void eraseNumberOfChildren() override {} - size_t size() const override { return sizeof(ExceptionLayoutNode); } -#if POINCARE_TREE_LOG - virtual void logNodeName(std::ostream & stream) const override { - stream << "ExceptionLayout"; - } -#endif - -protected: - // LayoutNode - void moveCursorVertically(LayoutNode::VerticalDirection direction, LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) override {} - KDSize computeSize() override { return KDSizeZero; } - KDCoordinate computeBaseline() override { return 0; } - KDPoint positionOfChild(LayoutNode * child) override { - assert(false); - return KDPointZero; - } - void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override {} -}; - -} - -#endif diff --git a/poincare/include/poincare/exception_node.h b/poincare/include/poincare/exception_node.h deleted file mode 100644 index b0ab8e436..000000000 --- a/poincare/include/poincare/exception_node.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef POINCARE_EXCEPTION_NODE_H -#define POINCARE_EXCEPTION_NODE_H - -#include - -namespace Poincare { - -template -class ExceptionNode : public T { -public: - using T::T; - - // TreeNode - size_t size() const override { return sizeof(ExceptionNode); } - int numberOfChildren() const override { return 0; } -}; - -} - -#endif diff --git a/poincare/include/poincare/expression.h b/poincare/include/poincare/expression.h index f43374188..d32a0c6fe 100644 --- a/poincare/include/poincare/expression.h +++ b/poincare/include/poincare/expression.h @@ -86,7 +86,7 @@ template public: static bool isExpression() { return true; } /* Constructor & Destructor */ - Expression(); + Expression() : TreeByReference() {} virtual ~Expression() = default; Expression clone() const { TreeByReference c = TreeByReference::clone(); return static_cast(c); } static Expression parse(char const * string); diff --git a/poincare/include/poincare/expression_node.h b/poincare/include/poincare/expression_node.h index b3dd53953..157a9a281 100644 --- a/poincare/include/poincare/expression_node.h +++ b/poincare/include/poincare/expression_node.h @@ -155,8 +155,6 @@ public: ExpressionNode * childAtIndex(int i) const override { return static_cast(TreeNode::childAtIndex(i)); } virtual void setChildrenInPlace(Expression other); - // TreeNode - TreeNode * uninitializedStaticNode() const override; protected: /* Hierarchy */ ExpressionNode * parent() const override { return static_cast(TreeNode::parent()); } diff --git a/poincare/include/poincare/ghost_node.h b/poincare/include/poincare/ghost_node.h index 604bbb146..6abafcf02 100644 --- a/poincare/include/poincare/ghost_node.h +++ b/poincare/include/poincare/ghost_node.h @@ -18,8 +18,6 @@ public: // Ghost bool isGhost() const override { return true; } - // Uninitialized - TreeNode * uninitializedStaticNode() const override; }; } diff --git a/poincare/include/poincare/integral_layout_node.h b/poincare/include/poincare/integral_layout_node.h index e76bd15e4..95223e2e8 100644 --- a/poincare/include/poincare/integral_layout_node.h +++ b/poincare/include/poincare/integral_layout_node.h @@ -22,10 +22,7 @@ public: void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override; void deleteBeforeCursor(LayoutCursor * cursor) override; int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override; - LayoutNode * layoutToPointWhenInserting() override { - assert(!lowerBoundLayout()->isUninitialized()); - return lowerBoundLayout(); - } + LayoutNode * layoutToPointWhenInserting() override { return lowerBoundLayout(); } char XNTChar() const override { return 'x'; } // TreeNode diff --git a/poincare/include/poincare/layout_node.h b/poincare/include/poincare/layout_node.h index 14e27c614..39dd8af79 100644 --- a/poincare/include/poincare/layout_node.h +++ b/poincare/include/poincare/layout_node.h @@ -102,7 +102,7 @@ public: virtual bool hasUpperLeftIndex() const { return false; } virtual char XNTChar() const { LayoutNode * p = parent(); - return p->isUninitialized() ? Ion::Charset::Empty : p->XNTChar(); + return p == nullptr ? Ion::Charset::Empty : p->XNTChar(); } // TODO: put private @@ -114,9 +114,6 @@ public: virtual bool willRemoveChild(LayoutNode * l, LayoutCursor * cursor, bool force); virtual void didRemoveChildAtIndex(int index, LayoutCursor * cursor, bool force) {} - // TreeNode - TreeNode * uninitializedStaticNode() const override; - protected: // Tree navigation virtual void moveCursorVertically(VerticalDirection direction, LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited); diff --git a/poincare/include/poincare/layout_reference.h b/poincare/include/poincare/layout_reference.h index 00806c030..bb2b28053 100644 --- a/poincare/include/poincare/layout_reference.h +++ b/poincare/include/poincare/layout_reference.h @@ -18,8 +18,7 @@ public: using TreeByReference::operator==; using TreeByReference::operator!=; - LayoutReference(); - + LayoutReference() : TreeByReference() {} LayoutReference(const LayoutNode * node) : TreeByReference(node) {} diff --git a/poincare/include/poincare/nth_root_layout_node.h b/poincare/include/poincare/nth_root_layout_node.h index 8ee8e2457..ddb547069 100644 --- a/poincare/include/poincare/nth_root_layout_node.h +++ b/poincare/include/poincare/nth_root_layout_node.h @@ -62,7 +62,7 @@ private: KDSize adjustedIndexSize(); void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override; LayoutNode * radicandLayout() { return childAtIndex(0); } - LayoutNode * indexLayout() { return m_hasIndex ? childAtIndex(1) : static_cast(uninitializedStaticNode()); } + LayoutNode * indexLayout() { return m_hasIndex ? childAtIndex(1) : nullptr; } bool m_hasIndex; }; diff --git a/poincare/include/poincare/sequence_layout_node.h b/poincare/include/poincare/sequence_layout_node.h index 1d38ff9f7..80376bead 100644 --- a/poincare/include/poincare/sequence_layout_node.h +++ b/poincare/include/poincare/sequence_layout_node.h @@ -20,10 +20,7 @@ public: void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override; void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override; void deleteBeforeCursor(LayoutCursor * cursor) override; - LayoutNode * layoutToPointWhenInserting() override { - assert(!lowerBoundLayout()->isUninitialized()); - return lowerBoundLayout(); - } + LayoutNode * layoutToPointWhenInserting() override { return lowerBoundLayout(); } char XNTChar() const override { return 'n'; } // TreeNode diff --git a/poincare/include/poincare/tree_by_reference.h b/poincare/include/poincare/tree_by_reference.h index beabcd2b7..62b147490 100644 --- a/poincare/include/poincare/tree_by_reference.h +++ b/poincare/include/poincare/tree_by_reference.h @@ -41,11 +41,11 @@ public: TreeByReference clone() const; int identifier() const { return m_identifier; } - TreeNode * node() const { return TreePool::sharedPool()->node(m_identifier); } + TreeNode * node() const { assert(m_identifier != TreePool::NoNodeIdentifier); return TreePool::sharedPool()->node(m_identifier); } int nodeRetainCount() const { return node()->retainCount(); } bool isGhost() const { return node()->isGhost(); } - bool isUninitialized() const { return node()->isUninitialized(); } + bool isUninitialized() const { return m_identifier == TreePool::NoNodeIdentifier; } bool isStatic() const { return node()->isStatic(); } @@ -90,7 +90,7 @@ protected: assert(node != nullptr); setIdentifierAndRetain(node->identifier()); } - TreeByReference(int nodeIndentifier = -1) : m_identifier(nodeIndentifier) {} + TreeByReference(int nodeIndentifier = TreePool::NoNodeIdentifier) : m_identifier(nodeIndentifier) {} void setIdentifierAndRetain(int newId) { m_identifier = newId; assert(node() != nullptr); diff --git a/poincare/include/poincare/tree_node.h b/poincare/include/poincare/tree_node.h index ee692cea1..32f1fff45 100644 --- a/poincare/include/poincare/tree_node.h +++ b/poincare/include/poincare/tree_node.h @@ -32,10 +32,6 @@ public: int identifier() const { return m_identifier; } int retainCount() const { return m_referenceCounter; } - // Uninitialized node - virtual bool isUninitialized() const { return false; } - virtual TreeNode * uninitializedStaticNode() const = 0; - // Ghost virtual bool isGhost() const { return false; } diff --git a/poincare/include/poincare/uninitialized_evaluation_node.h b/poincare/include/poincare/uninitialized_evaluation_node.h deleted file mode 100644 index 344665601..000000000 --- a/poincare/include/poincare/uninitialized_evaluation_node.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef POINCARE_UNINITIALIZED_EVALUATION_NODE_H -#define POINCARE_UNINITIALIZED_EVALUATION_NODE_H - -#include -#include -#include - -namespace Poincare { - -/* All UninitializedExpressions should be caught so its node methods are - * asserted false. */ - -template -class UninitializedEvaluationNode : public ExceptionEvaluationNode { -public: - static UninitializedEvaluationNode * UninitializedEvaluationStaticNode(); - // TreeNode - bool isUninitialized() const override { return true; } - size_t size() const override { return sizeof(UninitializedEvaluationNode); } -#if POINCARE_TREE_LOG - virtual void logNodeName(std::ostream & stream) const override { - stream << "UninitializedEvaluation"; - } -#endif -}; - -} - -#endif diff --git a/poincare/include/poincare/uninitialized_expression_node.h b/poincare/include/poincare/uninitialized_expression_node.h deleted file mode 100644 index 8e7684851..000000000 --- a/poincare/include/poincare/uninitialized_expression_node.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef POINCARE_UNINITIALIZED_EXPRESSION_NODE_H -#define POINCARE_UNINITIALIZED_EXPRESSION_NODE_H - -#include -#include - -namespace Poincare { - -/* All UninitializedExpressions should be caught so its node methods are - * asserted false. */ - -class UninitializedExpressionNode : public ExceptionExpressionNode { -public: - static UninitializedExpressionNode * UninitializedExpressionStaticNode(); - static int UninitializedExpressionStaticNodeIdentifier() { return UninitializedExpressionStaticNode()->identifier(); } - - // ExpressionNode - void setChildrenInPlace(Expression other) override { assert(false); return ExceptionExpressionNode::setChildrenInPlace(other); } - ExpressionNode::Sign sign() const override { assert(false); return ExceptionExpressionNode::sign(); } - Expression setSign(Sign s, Context & context, Preferences::AngleUnit angleUnit) override { assert(false); return ExceptionExpressionNode::setSign(s, context, angleUnit); } - - ExpressionNode::Type type() const override { assert(false); return ExpressionNode::Type::Uninitialized; } - int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode = Preferences::PrintFloatMode::Decimal, int numberOfSignificantDigits = 0) const override { - assert(false); - return ExceptionExpressionNode::serialize(buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits); - } - LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override { assert(false); return ExceptionExpressionNode::createLayout(floatDisplayMode, numberOfSignificantDigits); } - - // TreeNode - bool isUninitialized() const override { return true; } - size_t size() const override { return sizeof(UninitializedExpressionNode); } - Expression denominator(Context & context, Preferences::AngleUnit angleUnit) const override { assert(false); return ExceptionExpressionNode::denominator(context, angleUnit); } -#if POINCARE_TREE_LOG - virtual void logNodeName(std::ostream & stream) const override { - stream << "UninitializedExpression"; - } -#endif -}; - -} - -#endif diff --git a/poincare/include/poincare/uninitialized_ghost_node.h b/poincare/include/poincare/uninitialized_ghost_node.h deleted file mode 100644 index 7b03e1902..000000000 --- a/poincare/include/poincare/uninitialized_ghost_node.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef POINCARE_UNINITIALIZED_GHOST_NODE_H -#define POINCARE_UNINITIALIZED_GHOST_NODE_H - -#include -#include -#include - -namespace Poincare { - -class UninitializedGhostNode : public ExceptionNode { -public: - static UninitializedGhostNode * UninitializedGhostStaticNode(); - - // TreeNode - bool isUninitialized() const override { return true; } - size_t size() const override { return sizeof(UninitializedGhostNode); } -#if POINCARE_TREE_LOG - virtual void logNodeName(std::ostream & stream) const override { - stream << "UninitializedGhost"; - } -#endif -}; - -} - -#endif diff --git a/poincare/include/poincare/uninitialized_layout_node.h b/poincare/include/poincare/uninitialized_layout_node.h deleted file mode 100644 index 9de7308f4..000000000 --- a/poincare/include/poincare/uninitialized_layout_node.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef POINCARE_UNINITIALIZED_LAYOUT_NODE_H -#define POINCARE_UNINITIALIZED_LAYOUT_NODE_H - -#include -#include - -namespace Poincare { - -/* All UninitializedExpressions should be caught so its node methods are - * asserted false. */ - -class UninitializedLayoutNode : public ExceptionLayoutNode { -public: - static UninitializedLayoutNode * UninitializedLayoutStaticNode(); - - // LayoutNode - // Rendering - void invalidAllSizesPositionsAndBaselines() override { assert(false); ExceptionLayoutNode::invalidAllSizesPositionsAndBaselines(); } - - // Tree navigation - void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override { assert(false); ExceptionLayoutNode::moveCursorLeft(cursor, shouldRecomputeLayout); } - void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override { assert(false); ExceptionLayoutNode::moveCursorRight(cursor, shouldRecomputeLayout); } - void moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override { assert(false); ExceptionLayoutNode::moveCursorUp(cursor, shouldRecomputeLayout, equivalentPositionVisited); } - void moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override { assert(false); ExceptionLayoutNode::moveCursorDown(cursor, shouldRecomputeLayout, equivalentPositionVisited); } - LayoutCursor equivalentCursor(LayoutCursor * cursor) override { assert(false); return ExceptionLayoutNode::equivalentCursor(cursor); } - - // Tree modification - - // Collapse - bool shouldCollapseSiblingsOnLeft() const override { assert(false); return ExceptionLayoutNode::shouldCollapseSiblingsOnLeft(); } - bool shouldCollapseSiblingsOnRight() const override { assert(false); return ExceptionLayoutNode::shouldCollapseSiblingsOnRight(); } - void didCollapseSiblings(LayoutCursor * cursor) override { assert(false); ExceptionLayoutNode::didCollapseSiblings(cursor);} - - //User input - void deleteBeforeCursor(LayoutCursor * cursor) override { assert(false); ExceptionLayoutNode::deleteBeforeCursor(cursor);} - - // Other - LayoutNode * layoutToPointWhenInserting() override { assert(false); return ExceptionLayoutNode::layoutToPointWhenInserting(); } - bool hasText() const override { assert(false); return ExceptionLayoutNode::hasText(); } - bool isCollapsable(int * numberOfOpenParenthesis, bool goingLeft) const override { assert(false); return ExceptionLayoutNode::isCollapsable(numberOfOpenParenthesis, goingLeft); } - bool canBeOmittedMultiplicationLeftFactor() const override { assert(false); return ExceptionLayoutNode::canBeOmittedMultiplicationLeftFactor(); } - bool canBeOmittedMultiplicationRightFactor() const override { assert(false); return ExceptionLayoutNode::canBeOmittedMultiplicationRightFactor(); } - bool mustHaveLeftSibling() const override { assert(false); return ExceptionLayoutNode::mustHaveLeftSibling(); } - bool isVerticalOffset() const override { assert(false); return ExceptionLayoutNode::isVerticalOffset(); } - bool isHorizontal() const override { assert(false); return ExceptionLayoutNode::isHorizontal(); } - bool isLeftParenthesis() const override { assert(false); return ExceptionLayoutNode::isLeftParenthesis(); } - bool isRightParenthesis() const override { assert(false); return ExceptionLayoutNode::isRightParenthesis(); } - bool isLeftBracket() const override { assert(false); return ExceptionLayoutNode::isLeftBracket(); } - bool isRightBracket() const override { assert(false); return ExceptionLayoutNode::isRightBracket(); } - bool isEmpty() const override { assert(false); return ExceptionLayoutNode::isEmpty(); } - bool isMatrix() const override { assert(false); return ExceptionLayoutNode::isMatrix(); } - bool hasUpperLeftIndex() const override { assert(false); return ExceptionLayoutNode::hasUpperLeftIndex(); } - - bool willAddChildAtIndex(LayoutNode * l, int * index, int * currentNumberOfChildren, LayoutCursor * cursor) override { assert(false); return ExceptionLayoutNode::willAddChildAtIndex(l, index, currentNumberOfChildren, cursor); } - bool willAddSibling(LayoutCursor * cursor, LayoutNode * sibling, bool moveCursor) override { assert(false); return ExceptionLayoutNode::willAddSibling(cursor, sibling, moveCursor); } - void willAddSiblingToEmptyChildAtIndex(int childIndex) override { assert(false); return ExceptionLayoutNode::willAddSiblingToEmptyChildAtIndex(childIndex); } - bool willReplaceChild(LayoutNode * oldChild, LayoutNode * newChild, LayoutCursor * cursor, bool force) override { assert(false); return ExceptionLayoutNode::willReplaceChild(oldChild, newChild, cursor, force); } - void didReplaceChildAtIndex(int index, LayoutCursor * cursor, bool force) override { assert(false); return ExceptionLayoutNode::didReplaceChildAtIndex(index, cursor, force); } - bool willRemoveChild(LayoutNode * l, LayoutCursor * cursor, bool force) override { assert(false); return ExceptionLayoutNode::willRemoveChild(l, cursor, force); } - void didRemoveChildAtIndex(int index, LayoutCursor * cursor, bool force) override { assert(false); return ExceptionLayoutNode::didRemoveChildAtIndex(index, cursor, force); } - - // TreeNode - bool isUninitialized() const override { return true; } - size_t size() const override { return sizeof(UninitializedLayoutNode); } -#if POINCARE_TREE_LOG - virtual void logNodeName(std::ostream & stream) const override { - stream << "UninitializedLayout"; - } -#endif - -protected: - // LayoutNode - void moveCursorVertically(LayoutNode::VerticalDirection direction, LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) override { - assert(false); - return ExceptionLayoutNode::moveCursorVertically(direction, cursor, shouldRecomputeLayout, equivalentPositionVisited); - } - KDCoordinate computeBaseline() override { assert(false); return ExceptionLayoutNode::computeBaseline(); } - -private: - void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override { assert(false); ExceptionLayoutNode::render(ctx, p, expressionColor, backgroundColor); } -}; - -} - -#endif diff --git a/poincare/src/binomial_coefficient_layout_node.cpp b/poincare/src/binomial_coefficient_layout_node.cpp index 8723635cf..ebeb4b0b8 100644 --- a/poincare/src/binomial_coefficient_layout_node.cpp +++ b/poincare/src/binomial_coefficient_layout_node.cpp @@ -21,14 +21,13 @@ void BinomialCoefficientLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * assert(cursor->layoutNode() == this); if (cursor->position() == LayoutCursor::Position::Right) { // Case: Right. Go to the kLayout. - assert(!kLayout()->isUninitialized()); cursor->setLayoutNode(kLayout()); return; } // Case: Left. Ask the parent. assert(cursor->position() == LayoutCursor::Position::Left); LayoutNode * parentNode = parent(); - if (!parentNode->isUninitialized()) { + if (parentNode != nullptr) { parentNode->moveCursorLeft(cursor, shouldRecomputeLayout); } } @@ -46,14 +45,13 @@ void BinomialCoefficientLayoutNode::moveCursorRight(LayoutCursor * cursor, bool assert(cursor->layoutNode() == this); if (cursor->position() == LayoutCursor::Position::Left) { // Case: Left. Go Left of the nLayout. - assert(!nLayout()->isUninitialized()); cursor->setLayoutNode(nLayout()); return; } // Case: Right. Ask the parent. assert(cursor->position() == LayoutCursor::Position::Right); LayoutNode * parentNode = parent(); - if (!parentNode->isUninitialized()) { + if (parentNode != nullptr) { parentNode->moveCursorRight(cursor, shouldRecomputeLayout); } } diff --git a/poincare/src/bracket_layout_node.cpp b/poincare/src/bracket_layout_node.cpp index fcd43a79f..586d3a135 100644 --- a/poincare/src/bracket_layout_node.cpp +++ b/poincare/src/bracket_layout_node.cpp @@ -17,7 +17,7 @@ void BracketLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecom assert(cursor->position() == LayoutCursor::Position::Left); // Case: Left. Ask the parent. LayoutNode * parentLayout = parent(); - if (!parentLayout->isUninitialized()) { + if (parentLayout != nullptr) { parentLayout->moveCursorLeft(cursor, shouldRecomputeLayout); } } @@ -32,7 +32,7 @@ void BracketLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldReco assert(cursor->position() == LayoutCursor::Position::Right); // Case: Right. Ask the parent. LayoutNode * parentLayout = parent(); - if (!parentLayout->isUninitialized()) { + if (parentLayout != nullptr) { parentLayout->moveCursorRight(cursor, shouldRecomputeLayout); } } @@ -44,7 +44,7 @@ void BracketLayoutNode::invalidAllSizesPositionsAndBaselines() { KDCoordinate BracketLayoutNode::computeBaseline() { LayoutNode * parentLayout = parent(); - assert(!parentLayout->isUninitialized()); + assert(parentLayout != nullptr); int idxInParent = parentLayout->indexOfChild(this); int numberOfSiblings = parentLayout->numberOfChildren(); if (((isLeftParenthesis() || isLeftBracket()) && idxInParent == numberOfSiblings - 1) @@ -99,7 +99,7 @@ KDCoordinate BracketLayoutNode::childHeight() { KDCoordinate BracketLayoutNode::computeChildHeight() { LayoutNode * parentLayout = parent(); - assert(!parentLayout->isUninitialized()); + assert(parentLayout != nullptr); KDCoordinate result = Metric::MinimalBracketAndParenthesisHeight; int idxInParent = parentLayout->indexOfChild(this); int numberOfSiblings = parentLayout->numberOfChildren(); diff --git a/poincare/src/bracket_pair_layout_node.cpp b/poincare/src/bracket_pair_layout_node.cpp index 3b8755b69..ba1b3e5f7 100644 --- a/poincare/src/bracket_pair_layout_node.cpp +++ b/poincare/src/bracket_pair_layout_node.cpp @@ -23,8 +23,7 @@ void BracketPairLayoutNode::RenderWithChildSize(KDSize childSize, KDContext * ct } void BracketPairLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) { - if (!childLayout()->isUninitialized() - && cursor->layoutNode() == childLayout() + if (cursor->layoutNode() == childLayout() && cursor->position() == LayoutCursor::Position::Left) { // Case: Left of the operand. Go Left of the brackets. @@ -34,21 +33,19 @@ void BracketPairLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldR assert(cursor->layoutNode() == this); if (cursor->position() == LayoutCursor::Position::Right) { // Case: Right of the brackets. Go Right of the operand. - assert(!childLayout()->isUninitialized()); cursor->setLayoutNode(childLayout()); return; } assert(cursor->position() == LayoutCursor::Position::Left); // Case: Left of the brackets. Ask the parent. LayoutNode * parentNode = parent(); - if (!parentNode->isUninitialized()) { + if (parentNode != nullptr) { parentNode->moveCursorLeft(cursor, shouldRecomputeLayout); } } void BracketPairLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) { - if (!childLayout()->isUninitialized() - && cursor->layoutNode() == childLayout() + if (cursor->layoutNode() == childLayout() && cursor->position() == LayoutCursor::Position::Right) { // Case: Right of the operand. Go Right of the brackets. @@ -58,14 +55,13 @@ void BracketPairLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * should assert(cursor->layoutNode() == this); if (cursor->position() == LayoutCursor::Position::Left) { // Case: Left of the brackets. Go Left of the operand. - assert(!childLayout()->isUninitialized()); cursor->setLayoutNode(childLayout()); return; } assert(cursor->position() == LayoutCursor::Position::Right); // Case: Right of the brackets. Ask the parent. LayoutNode * parentNode = parent(); - if (!parentNode->isUninitialized()) { + if (parentNode != nullptr) { parentNode->moveCursorRight(cursor, shouldRecomputeLayout); } } diff --git a/poincare/src/char_layout_node.cpp b/poincare/src/char_layout_node.cpp index 521a90822..efb80b6b5 100644 --- a/poincare/src/char_layout_node.cpp +++ b/poincare/src/char_layout_node.cpp @@ -11,7 +11,7 @@ void CharLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomput return; } LayoutNode * parentNode = parent(); - if (!parentNode->isUninitialized()) { + if (parentNode != nullptr) { parentNode->moveCursorLeft(cursor, shouldRecomputeLayout); } } @@ -22,7 +22,7 @@ void CharLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecompu return; } LayoutNode * parentNode = parent(); - if (!parentNode->isUninitialized()) { + if (parentNode != nullptr) { parentNode->moveCursorRight(cursor, shouldRecomputeLayout); } } diff --git a/poincare/src/condensed_sum_layout_node.cpp b/poincare/src/condensed_sum_layout_node.cpp index e8a86b8eb..2c2f55d0d 100644 --- a/poincare/src/condensed_sum_layout_node.cpp +++ b/poincare/src/condensed_sum_layout_node.cpp @@ -6,15 +6,17 @@ namespace Poincare { static inline KDCoordinate max(KDCoordinate x, KDCoordinate y) { return x > y ? x : y; } + +// TODO remove nullptr in the code? KDCoordinate CondensedSumLayoutNode::computeBaseline() { - KDSize superscriptSize = superscriptLayout()->isUninitialized() ? KDSizeZero : superscriptLayout()->layoutSize(); + KDSize superscriptSize = superscriptLayout() == nullptr ? KDSizeZero : superscriptLayout()->layoutSize(); return baseLayout()->baseline() + max(0, superscriptSize.height() - baseLayout()->layoutSize().height()/2); } KDSize CondensedSumLayoutNode::computeSize() { KDSize baseSize = baseLayout()->layoutSize(); KDSize subscriptSize = subscriptLayout()->layoutSize(); - KDSize superscriptSize = superscriptLayout()->isUninitialized() ? KDSizeZero : superscriptLayout()->layoutSize(); + KDSize superscriptSize = superscriptLayout() == nullptr ? KDSizeZero : superscriptLayout()->layoutSize(); KDCoordinate sizeWidth = baseSize.width() + max(subscriptSize.width(), superscriptSize.width()); KDCoordinate sizeHeight = max(baseSize.height()/2, subscriptSize.height()) + max(baseSize.height()/2, superscriptSize.height()); return KDSize(sizeWidth, sizeHeight); @@ -24,7 +26,7 @@ KDPoint CondensedSumLayoutNode::positionOfChild(LayoutNode * child) { KDCoordinate x = 0; KDCoordinate y = 0; KDSize baseSize = baseLayout()->layoutSize(); - KDSize superscriptSize = superscriptLayout()->isUninitialized() ? KDSizeZero : superscriptLayout()->layoutSize(); + KDSize superscriptSize = superscriptLayout() == nullptr ? KDSizeZero : superscriptLayout()->layoutSize(); if (child == baseLayout()) { y = max(0, superscriptSize.height() - baseSize.height()/2); } diff --git a/poincare/src/conjugate_layout_node.cpp b/poincare/src/conjugate_layout_node.cpp index c81d8600c..f6dea67a5 100644 --- a/poincare/src/conjugate_layout_node.cpp +++ b/poincare/src/conjugate_layout_node.cpp @@ -7,8 +7,7 @@ namespace Poincare { void ConjugateLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) { - if (!childLayout()->isUninitialized() - && cursor->layoutNode() == childLayout() + if (cursor->layoutNode() == childLayout() && cursor->position() == LayoutCursor::Position::Left) { // Case: Left of the operand. Move Left. @@ -18,22 +17,20 @@ void ConjugateLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRec assert(cursor->layoutNode() == this); if (cursor->position() == LayoutCursor::Position::Right) { // Case: Right. Go to the operand. - assert(!childLayout()->isUninitialized()); cursor->setLayoutNode(childLayout()); return; } assert(cursor->position() == LayoutCursor::Position::Left); // Case: Left. Ask the parent. LayoutNode * parentNode = parent(); - if (!parentNode->isUninitialized()) { + if (parentNode != nullptr) { parentNode->moveCursorLeft(cursor, shouldRecomputeLayout); } } void ConjugateLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) { // Case: Right of the operand. Move Right. - if (!childLayout()->isUninitialized() - && cursor->layoutNode() == childLayout() + if (cursor->layoutNode() == childLayout() && cursor->position() == LayoutCursor::Position::Right) { cursor->setLayoutNode(this); @@ -42,14 +39,13 @@ void ConjugateLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRe assert(cursor->layoutNode() == this); // Case: Left. Go to the operand. if (cursor->position() == LayoutCursor::Position::Left) { - assert(!childLayout()->isUninitialized()); cursor->setLayoutNode(childLayout()); return; } // Case: Right. Ask the parent. assert(cursor->position() == LayoutCursor::Position::Right); LayoutNode * parentNode = parent(); - if (!parentNode->isUninitialized()) { + if (parentNode != nullptr) { parentNode->moveCursorRight(cursor, shouldRecomputeLayout); } } diff --git a/poincare/src/empty_layout_node.cpp b/poincare/src/empty_layout_node.cpp index d95b4e4db..141591577 100644 --- a/poincare/src/empty_layout_node.cpp +++ b/poincare/src/empty_layout_node.cpp @@ -8,7 +8,7 @@ namespace Poincare { void EmptyLayoutNode::deleteBeforeCursor(LayoutCursor * cursor) { cursor->setPosition(LayoutCursor::Position::Left); LayoutNode * p = parent(); - if (!p->isUninitialized()) { + if (p != nullptr) { return p->deleteBeforeCursor(cursor); } } @@ -17,7 +17,7 @@ void EmptyLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecompu assert(cursor->layoutNode() == this); // Ask the parent. LayoutNode * p = parent(); - if (!p->isUninitialized()) { + if (p != nullptr) { cursor->setPosition(LayoutCursor::Position::Left); p->moveCursorLeft(cursor, shouldRecomputeLayout); } @@ -27,7 +27,7 @@ void EmptyLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomp assert(cursor->layoutNode() == this); // Ask the parent. LayoutNode * p = parent(); - if (!p->isUninitialized()) { + if (p != nullptr) { cursor->setPosition(LayoutCursor::Position::Right); p->moveCursorRight(cursor, shouldRecomputeLayout); } @@ -72,7 +72,7 @@ bool EmptyLayoutNode::willAddSibling(LayoutCursor * cursor, LayoutNode * sibling /* The parent is a MatrixLayout, and the current empty row or column is * being filled in, so add a new empty row or column. */ LayoutNode * parentNode = parent(); - assert(!parentNode->isUninitialized()); + assert(parentNode != nullptr); parentNode->willAddSiblingToEmptyChildAtIndex(parentNode->indexOfChild(this)); // WARNING: Do not use previous node pointers afterwards. } diff --git a/poincare/src/evaluation.cpp b/poincare/src/evaluation.cpp index c415259a6..6f5a5809b 100644 --- a/poincare/src/evaluation.cpp +++ b/poincare/src/evaluation.cpp @@ -1,26 +1,13 @@ #include #include -#include namespace Poincare { -template -TreeNode * EvaluationNode::uninitializedStaticNode() const { - return Evaluation().node(); -} - -template -Evaluation::Evaluation() : Evaluation(UninitializedEvaluationNode::UninitializedEvaluationStaticNode()) {} - template Expression Evaluation::complexToExpression(Preferences::ComplexFormat complexFormat) const { return node()->complexToExpression(complexFormat); } -template TreeNode * EvaluationNode::uninitializedStaticNode() const; -template TreeNode * EvaluationNode::uninitializedStaticNode() const; -template Evaluation::Evaluation(); -template Evaluation::Evaluation(); template Expression Evaluation::complexToExpression(Preferences::ComplexFormat) const; template Expression Evaluation::complexToExpression(Preferences::ComplexFormat) const; diff --git a/poincare/src/expression.cpp b/poincare/src/expression.cpp index 7a8f6d5a6..5b31091e1 100644 --- a/poincare/src/expression.cpp +++ b/poincare/src/expression.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -21,7 +20,6 @@ namespace Poincare { #include /* Constructor & Destructor */ -Expression::Expression() : Expression(UninitializedExpressionNode::UninitializedExpressionStaticNodeIdentifier()) {} Expression Expression::parse(char const * string) { if (string[0] == 0) { diff --git a/poincare/src/expression_node.cpp b/poincare/src/expression_node.cpp index 8e73a479a..c4138a2e0 100644 --- a/poincare/src/expression_node.cpp +++ b/poincare/src/expression_node.cpp @@ -109,10 +109,6 @@ void ExpressionNode::setChildrenInPlace(Expression other) { Expression(this).defaultSetChildrenInPlace(other); } -TreeNode * ExpressionNode::uninitializedStaticNode() const { - return Expression().node(); -} - Expression ExpressionNode::denominator(Context & context, Preferences::AngleUnit angleUnit) const { return Expression(); } diff --git a/poincare/src/fraction_layout_node.cpp b/poincare/src/fraction_layout_node.cpp index 509ea6435..0a638f14c 100644 --- a/poincare/src/fraction_layout_node.cpp +++ b/poincare/src/fraction_layout_node.cpp @@ -13,8 +13,8 @@ static inline KDCoordinate max(KDCoordinate x, KDCoordinate y) { return x > y ? void FractionLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) { if (cursor->position() == LayoutCursor::Position::Left - && ((!numeratorLayout()->isUninitialized() && cursor->layoutNode() == numeratorLayout()) - || (!denominatorLayout()->isUninitialized() && cursor->layoutNode() == denominatorLayout()))) + && (cursor->layoutNode() == numeratorLayout() + || cursor->layoutNode() == denominatorLayout())) { // Case: Left of the numerator or the denominator. Go Left of the fraction. cursor->setLayoutNode(this); @@ -23,7 +23,6 @@ void FractionLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldReco assert(cursor->layoutNode() == this); // Case: Right. Go to the denominator. if (cursor->position() == LayoutCursor::Position::Right) { - assert(!denominatorLayout()->isUninitialized()); cursor->setLayoutNode(denominatorLayout()); cursor->setPosition(LayoutCursor::Position::Right); return; @@ -31,15 +30,15 @@ void FractionLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldReco // Case: Left. Ask the parent. assert(cursor->position() == LayoutCursor::Position::Left); LayoutNode * parentNode = parent(); - if (!parentNode->isUninitialized()) { + if (parentNode != nullptr) { parentNode->moveCursorLeft(cursor, shouldRecomputeLayout); } } void FractionLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) { if (cursor->position() == LayoutCursor::Position::Right - && ((!numeratorLayout()->isUninitialized() && cursor->layoutNode() == numeratorLayout()) - || (!denominatorLayout()->isUninitialized() && cursor->layoutNode() == denominatorLayout()))) + && (cursor->layoutNode() == numeratorLayout() + || cursor->layoutNode() == denominatorLayout())) { // Case: Right of the numerator or the denominator. Go Right of the fraction. cursor->setLayoutNode(this); @@ -48,28 +47,25 @@ void FractionLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRec assert(cursor->layoutNode() == this); if (cursor->position() == LayoutCursor::Position::Left) { // Case: Left. Go to the numerator. - assert(!numeratorLayout()->isUninitialized()); cursor->setLayoutNode(numeratorLayout()); return; } // Case: Right. Ask the parent. assert(cursor->position() == LayoutCursor::Position::Right); LayoutNode * parentNode = parent(); - if (!parentNode->isUninitialized()) { + if (parentNode != nullptr) { parentNode->moveCursorRight(cursor, shouldRecomputeLayout); } } void FractionLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) { - if (!denominatorLayout()->isUninitialized() && cursor->layoutNode()->hasAncestor(denominatorLayout(), true)) { + if (cursor->layoutNode()->hasAncestor(denominatorLayout(), true)) { // If the cursor is inside denominator, move it to the numerator. - assert(!numeratorLayout()->isUninitialized()); numeratorLayout()->moveCursorUpInDescendants(cursor, shouldRecomputeLayout); return; } if (cursor->layoutNode() == this) { // If the cursor is Left or Right, move it to the numerator. - assert(!numeratorLayout()->isUninitialized()); cursor->setLayoutNode(numeratorLayout()); return; } @@ -77,15 +73,13 @@ void FractionLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomp } void FractionLayoutNode::moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) { - if (!numeratorLayout()->isUninitialized() && cursor->layoutNode()->hasAncestor(numeratorLayout(), true)) { + if (cursor->layoutNode()->hasAncestor(numeratorLayout(), true)) { // If the cursor is inside numerator, move it to the denominator. - assert(!denominatorLayout()->isUninitialized()); denominatorLayout()->moveCursorDownInDescendants(cursor, shouldRecomputeLayout); return; } if (cursor->layoutNode() == this){ // If the cursor is Left or Right, move it to the denominator. - assert(!denominatorLayout()->isUninitialized()); cursor->setLayoutNode(denominatorLayout()); return; } @@ -135,7 +129,7 @@ int FractionLayoutNode::serialize(char * buffer, int bufferSize, Preferences::Pr int idxInParent = -1; LayoutNode * p = parent(); - if (!p->isUninitialized()) { + if (p != nullptr) { idxInParent = p->indexOfChild(this); } diff --git a/poincare/src/ghost_node.cpp b/poincare/src/ghost_node.cpp deleted file mode 100644 index 8c1c5f123..000000000 --- a/poincare/src/ghost_node.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include -#include - -namespace Poincare { - -TreeNode * GhostNode::uninitializedStaticNode() const { - return UninitializedGhostNode::UninitializedGhostStaticNode(); -} - -} diff --git a/poincare/src/grid_layout_node.cpp b/poincare/src/grid_layout_node.cpp index 24f6345f1..b9d2763f8 100644 --- a/poincare/src/grid_layout_node.cpp +++ b/poincare/src/grid_layout_node.cpp @@ -31,7 +31,7 @@ void GridLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomput // Case: Left. Ask the parent. assert(cursor->layoutNode() == this); LayoutNode * parentNode = parent(); - if (!parentNode->isUninitialized()) { + if (parentNode != nullptr) { parentNode->moveCursorLeft(cursor, shouldRecomputeLayout); } } @@ -59,7 +59,7 @@ void GridLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecompu // Case: Right. Ask the parent. assert(cursor->layoutNode() == this); LayoutNode * parentNode = parent(); - if (!parentNode->isUninitialized()) { + if (parentNode != nullptr) { parentNode->moveCursorRight(cursor, shouldRecomputeLayout); } } diff --git a/poincare/src/horizontal_layout_node.cpp b/poincare/src/horizontal_layout_node.cpp index 0194076f5..12c2f607d 100644 --- a/poincare/src/horizontal_layout_node.cpp +++ b/poincare/src/horizontal_layout_node.cpp @@ -14,7 +14,7 @@ void HorizontalLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRe if (cursor->position() == LayoutCursor::Position::Left) { // Case: Left. Ask the parent. LayoutNode * parentNode = parent(); - if (!parentNode->isUninitialized()) { + if (parentNode != nullptr) { parentNode->moveCursorLeft(cursor, shouldRecomputeLayout); } return; @@ -37,7 +37,7 @@ void HorizontalLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRe assert(childIndex >= 0); if (childIndex == 0) { // Case: the child is the leftmost. Ask the parent. - if (!parent()->isUninitialized()) { + if (parent() != nullptr) { cursor->setLayoutNode(this); return cursor->moveLeft(shouldRecomputeLayout); } @@ -54,7 +54,7 @@ void HorizontalLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldR if (cursor->position() == LayoutCursor::Position::Right) { // Case: Right. Ask the parent. LayoutNode * parentNode = parent(); - if (!parentNode->isUninitialized()) { + if (parentNode != nullptr) { parentNode->moveCursorRight(cursor, shouldRecomputeLayout); } return; @@ -66,7 +66,7 @@ void HorizontalLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldR if (childrenCount == 0) { // If there are no children, go Right and ask the parent cursor->setPosition(LayoutCursor::Position::Right); - if (!parentNode->isUninitialized()) { + if (parentNode != nullptr) { parentNode->moveCursorRight(cursor, shouldRecomputeLayout); } return; @@ -74,7 +74,6 @@ void HorizontalLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldR /* If there is at least one child, set the cursor to the first child and * move it Right */ LayoutNode * firstChild = childAtIndex(0); - assert(!firstChild->isUninitialized()); cursor->setLayoutNode(firstChild); return firstChild->moveCursorRight(cursor, shouldRecomputeLayout); } @@ -86,7 +85,7 @@ void HorizontalLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldR if (childIndex == numberOfChildren() - 1) { // Case: the child is the rightmost. Ask the parent. LayoutNode * parentNode = parent(); - if (!parentNode->isUninitialized()) { + if (parentNode != nullptr) { cursor->setLayoutNode(this); parentNode->moveCursorRight(cursor, shouldRecomputeLayout); } @@ -129,7 +128,7 @@ LayoutCursor HorizontalLayoutNode::equivalentCursor(LayoutCursor * cursor) { void HorizontalLayoutNode::deleteBeforeCursor(LayoutCursor * cursor) { LayoutNode * p = parent(); - if (p->isUninitialized() + if (p == nullptr && cursor->layoutNode() == this && (cursor->position() == LayoutCursor::Position::Left || numberOfChildren() == 0)) @@ -242,7 +241,7 @@ bool HorizontalLayoutNode::willRemoveChild(LayoutNode * l, LayoutCursor * cursor if (!force && numberOfChildren() == 1) { assert(childAtIndex(0) == l); LayoutNode * p = parent(); - if (!p->isUninitialized()) { + if (p != nullptr) { LayoutRef(p).removeChild(HorizontalLayoutRef(this), cursor); // WARNING: Do not call "this" afterwards return false; @@ -288,14 +287,14 @@ bool HorizontalLayoutNode::willReplaceChild(LayoutNode * oldChild, LayoutNode * /* The old layout was the only horizontal layout child, so if this has a * a parent, replace this with the new empty layout. */ LayoutNode * p = parent(); - if (!p->isUninitialized()) { + if (p != nullptr) { thisRef.replaceWith(newChild, cursor); // WARNING: do not call "this" afterwards return false; } /* This is the main horizontal layout, the old child is its only child and * the new child is Empty: remove the old child and delete the new child. */ - assert(p->isUninitialized()); + assert(p == nullptr); thisRef.removeChild(oldChild, nullptr); // WARNING: do not call "this" afterwards if (cursor != nullptr) { diff --git a/poincare/src/init.cpp b/poincare/src/init.cpp index c4949185a..607caebbf 100644 --- a/poincare/src/init.cpp +++ b/poincare/src/init.cpp @@ -1,7 +1,5 @@ #include #include -#include -#include namespace Poincare { @@ -9,10 +7,6 @@ void init() { // Create and register the shared static pool static TreePool pool; TreePool::RegisterPool(&pool); - - // Register static nodes - pool.registerStaticNode(UninitializedExpressionNode::UninitializedExpressionStaticNode()); - pool.registerStaticNode(UninitializedGhostNode::UninitializedGhostStaticNode()); } } diff --git a/poincare/src/integral_layout_node.cpp b/poincare/src/integral_layout_node.cpp index d1ca72edd..04ec7d404 100644 --- a/poincare/src/integral_layout_node.cpp +++ b/poincare/src/integral_layout_node.cpp @@ -25,19 +25,17 @@ const uint8_t bottomSymbolPixel[IntegralLayoutNode::k_symbolHeight][IntegralLayo void IntegralLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) { if (cursor->position() == LayoutCursor::Position::Left - && ((!upperBoundLayout()->isUninitialized() && cursor->layoutNode() == upperBoundLayout()) - || (!lowerBoundLayout()->isUninitialized() && cursor->layoutNode() == lowerBoundLayout()))) + && (cursor->layoutNode() == upperBoundLayout() + || cursor->layoutNode() == lowerBoundLayout())) { // Case: Left the upper or lower bound. Go Left of the integral. cursor->setLayoutNode(this); return; } - if (!integrandLayout()->isUninitialized() - && cursor->layoutNode() == integrandLayout() + if (cursor->layoutNode() == integrandLayout() && cursor->position() == LayoutCursor::Position::Left) { // Case: Left the integrand. Go Right of the lower bound. - assert(!lowerBoundLayout()->isUninitialized()); cursor->setLayoutNode(lowerBoundLayout()); cursor->setPosition(LayoutCursor::Position::Right); return; @@ -45,7 +43,6 @@ void IntegralLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldReco assert(cursor->layoutNode() == this); if (cursor->position() == LayoutCursor::Position::Right) { // Case: Right of the integral. Go to the integrand. - assert(!integrandLayout()->isUninitialized()); cursor->setLayoutNode(integrandLayout()); cursor->setPosition(LayoutCursor::Position::Right); return; @@ -53,24 +50,22 @@ void IntegralLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldReco // Case: Left of the brackets. Ask the parent. assert(cursor->position() == LayoutCursor::Position::Left); LayoutNode * parentNode = parent(); - if (!parentNode->isUninitialized()) { + if (parentNode != nullptr) { parentNode->moveCursorLeft(cursor, shouldRecomputeLayout); } } void IntegralLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) { if (cursor->position() == LayoutCursor::Position::Right && - ((!upperBoundLayout()->isUninitialized() && cursor->layoutNode() == upperBoundLayout()) - || (!lowerBoundLayout()->isUninitialized() && cursor->layoutNode() == lowerBoundLayout()))) + (cursor->layoutNode() == upperBoundLayout() + || cursor->layoutNode() == lowerBoundLayout())) { // Case: Right the upper or lower bound. Go Left of the integrand. - assert(!integrandLayout()->isUninitialized()); cursor->setLayoutNode(integrandLayout()); cursor->setPosition(LayoutCursor::Position::Left); return; } - if (!integrandLayout()->isUninitialized() - && cursor->layoutNode() == integrandLayout() + if (cursor->layoutNode() == integrandLayout() && cursor->position() == LayoutCursor::Position::Right) { // Case: Right the integrand. Go Right. @@ -81,7 +76,6 @@ void IntegralLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRec assert(cursor->layoutNode() == this); if (cursor->position() == LayoutCursor::Position::Left) { // Case: Left of the integral. Go to the upper bound. - assert(!upperBoundLayout()->isUninitialized()); cursor->setLayoutNode(upperBoundLayout()); cursor->setPosition(LayoutCursor::Position::Left); return; @@ -89,23 +83,19 @@ void IntegralLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRec // Case: Right. Ask the parent. assert(cursor->position() == LayoutCursor::Position::Right); LayoutNode * parentNode = parent(); - if (!parentNode->isUninitialized()) { + if (parentNode != nullptr) { parentNode->moveCursorRight(cursor, shouldRecomputeLayout); } } void IntegralLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) { - if (!lowerBoundLayout()->isUninitialized() && cursor->layoutNode()->hasAncestor(lowerBoundLayout(), true)) { + if (cursor->layoutNode()->hasAncestor(lowerBoundLayout(), true)) { // If the cursor is inside the lower bound, move it to the upper bound. - assert(!upperBoundLayout()->isUninitialized()); upperBoundLayout()->moveCursorUpInDescendants(cursor, shouldRecomputeLayout); return; } - if (!integrandLayout()->isUninitialized() - && cursor->isEquivalentTo(LayoutCursor(integrandLayout(), LayoutCursor::Position::Left))) - { + if (cursor->isEquivalentTo(LayoutCursor(integrandLayout(), LayoutCursor::Position::Left))) { // If the cursor is Left of the integrand, move it to the upper bound. - assert(!upperBoundLayout()->isUninitialized()); upperBoundLayout()->moveCursorUpInDescendants(cursor, shouldRecomputeLayout); return; } @@ -113,17 +103,13 @@ void IntegralLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomp } void IntegralLayoutNode::moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) { - if (!upperBoundLayout()->isUninitialized() && cursor->layoutNode()->hasAncestor(upperBoundLayout(), true)) { + if (cursor->layoutNode()->hasAncestor(upperBoundLayout(), true)) { // If the cursor is inside the upper bound, move it to the lower bound. - assert(!lowerBoundLayout()->isUninitialized()); lowerBoundLayout()->moveCursorDownInDescendants(cursor, shouldRecomputeLayout); return; } // If the cursor is Left of the integrand, move it to the lower bound. - if (!integrandLayout()->isUninitialized() - && cursor->isEquivalentTo(LayoutCursor(integrandLayout(), LayoutCursor::Position::Left))) - { - assert(!lowerBoundLayout()->isUninitialized()); + if (cursor->isEquivalentTo(LayoutCursor(integrandLayout(), LayoutCursor::Position::Left))) { lowerBoundLayout()->moveCursorDownInDescendants(cursor, shouldRecomputeLayout); return; } diff --git a/poincare/src/layout_node.cpp b/poincare/src/layout_node.cpp index a4709c9c3..5d5dddcca 100644 --- a/poincare/src/layout_node.cpp +++ b/poincare/src/layout_node.cpp @@ -18,7 +18,7 @@ void LayoutNode::draw(KDContext * ctx, KDPoint p, KDColor expressionColor, KDCol KDPoint LayoutNode::origin() { LayoutNode * p = parent(); - if (p->isUninitialized()) { + if (p == nullptr) { return absoluteOrigin(); } else { return KDPoint(absoluteOrigin().x() - p->absoluteOrigin().x(), @@ -29,7 +29,7 @@ KDPoint LayoutNode::origin() { KDPoint LayoutNode::absoluteOrigin() { LayoutNode * p = parent(); if (!m_positioned) { - if (!p->isUninitialized()) { + if (p != nullptr) { m_frame.setOrigin(p->absoluteOrigin().translatedBy(p->positionOfChild(this))); } else { m_frame.setOrigin(KDPointZero); @@ -83,7 +83,7 @@ void LayoutNode::moveCursorDownInDescendants(LayoutCursor * cursor, bool * shoul LayoutCursor LayoutNode::equivalentCursor(LayoutCursor * cursor) { // Only HorizontalLayout may have no parent, and it overloads this method - assert(!parent()->isUninitialized()); + assert(parent() != nullptr); return (cursor->layoutReference().node() == this) ? parent()->equivalentCursor(cursor) : LayoutCursor(); } @@ -101,7 +101,7 @@ void LayoutNode::deleteBeforeCursor(LayoutCursor * cursor) { assert(cursor->layoutNode() == this); LayoutNode * p = parent(); // Case: this is the pointed layout. - if (p->isUninitialized()) { + if (p == nullptr) { // Case: No parent. Return. return; } @@ -142,12 +142,6 @@ bool LayoutNode::canBeOmittedMultiplicationRightFactor() const { return isCollapsable(&numberOfOpenParentheses, false) && !isVerticalOffset(); } -// TreeNode - -TreeNode * LayoutNode::uninitializedStaticNode() const { - return LayoutReference().node(); -} - // Private void LayoutNode::moveCursorVertically(VerticalDirection direction, LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) { @@ -165,7 +159,7 @@ void LayoutNode::moveCursorVertically(VerticalDirection direction, LayoutCursor } } LayoutNode * p = parent(); - if (p->isUninitialized()) { + if (p == nullptr) { cursor->setLayoutReference(LayoutReference()); return; } @@ -177,7 +171,7 @@ void LayoutNode::moveCursorVertically(VerticalDirection direction, LayoutCursor } void LayoutNode::moveCursorInDescendantsVertically(VerticalDirection direction, LayoutCursor * cursor, bool * shouldRecomputeLayout) { - LayoutNode * childResult = static_cast(uninitializedStaticNode()); + LayoutNode * childResult = nullptr; LayoutNode ** childResultPtr = &childResult; LayoutCursor::Position resultPosition = LayoutCursor::Position::Left; /* The distance between the cursor and its next position cannot be greater @@ -188,7 +182,7 @@ void LayoutNode::moveCursorInDescendantsVertically(VerticalDirection direction, // If there is a valid result LayoutRef resultRef(childResult); - if (!(*childResultPtr)->isUninitialized()) { + if ((*childResultPtr) != nullptr) { *shouldRecomputeLayout = childResult->addGreySquaresToAllMatrixAncestors(); // WARNING: Do not use "this" afterwards } diff --git a/poincare/src/layout_reference.cpp b/poincare/src/layout_reference.cpp index 5a607e621..aa02aa8eb 100644 --- a/poincare/src/layout_reference.cpp +++ b/poincare/src/layout_reference.cpp @@ -5,12 +5,9 @@ #include #include #include -#include namespace Poincare { -LayoutReference::LayoutReference() : LayoutReference(UninitializedLayoutNode::UninitializedLayoutStaticNode()) {} - // Cursor LayoutCursor LayoutReference::cursor() const { return LayoutCursor(const_cast(this)->node()); diff --git a/poincare/src/matrix_layout_node.cpp b/poincare/src/matrix_layout_node.cpp index 2239f612f..bbb27177d 100644 --- a/poincare/src/matrix_layout_node.cpp +++ b/poincare/src/matrix_layout_node.cpp @@ -49,7 +49,6 @@ void MatrixLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomp addGreySquares(); *shouldRecomputeLayout = true; LayoutNode * lastChild = childAtIndex((m_numberOfColumns-1)*(m_numberOfRows-1)); - assert(!lastChild->isUninitialized()); cursor->setLayoutNode(lastChild); return; } diff --git a/poincare/src/nth_root_layout_node.cpp b/poincare/src/nth_root_layout_node.cpp index ef0a327cc..b87cbd059 100644 --- a/poincare/src/nth_root_layout_node.cpp +++ b/poincare/src/nth_root_layout_node.cpp @@ -20,12 +20,11 @@ const uint8_t radixPixel[NthRootLayoutNode::k_leftRadixHeight][NthRootLayoutNode }; void NthRootLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) { - if (!radicandLayout()->isUninitialized() - && cursor->layoutNode() == radicandLayout() + if (cursor->layoutNode() == radicandLayout() && cursor->position() == LayoutCursor::Position::Left) { // Case: Left of the radicand. Go the index if any, ir go Left of the root. - if (!indexLayout()->isUninitialized()) { + if (indexLayout() != nullptr) { cursor->setLayoutNode(indexLayout()); cursor->setPosition(LayoutCursor::Position::Right); } else { @@ -33,7 +32,7 @@ void NthRootLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecom } return; } - if (!indexLayout()->isUninitialized() + if (indexLayout() != nullptr && cursor->layoutNode() == indexLayout() && cursor->position() == LayoutCursor::Position::Left) { @@ -44,33 +43,30 @@ void NthRootLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecom assert(cursor->layoutNode() == this); if (cursor->position() == LayoutCursor::Position::Right) { // Case: Right. Go Right of the radicand. - assert(!radicandLayout()->isUninitialized()); cursor->setLayoutNode(radicandLayout()); return; } assert(cursor->position() == LayoutCursor::Position::Left); // Case: Left. Ask the parent. LayoutNode * parentNode = parent(); - if (!parentNode->isUninitialized()) { + if (parentNode != nullptr) { parentNode->moveCursorLeft(cursor, shouldRecomputeLayout); } } void NthRootLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) { - if (!radicandLayout()->isUninitialized() - && cursor->layoutNode() == radicandLayout() - && cursor->position() == LayoutCursor::Position::Right) + if (cursor->layoutNode() == radicandLayout() + && cursor->position() == LayoutCursor::Position::Right) { // Case: Right of the radicand. Go the Right of the root. cursor->setLayoutNode(this); return; } - if (!indexLayout()->isUninitialized() + if (indexLayout() != nullptr && cursor->layoutNode() == indexLayout() && cursor->position() == LayoutCursor::Position::Right) { - // Case: Right of the index. Go Left of the integrand. - assert(!radicandLayout()->isUninitialized()); + assert(radicandLayout() != nullptr); cursor->setLayoutNode(radicandLayout()); cursor->setPosition(LayoutCursor::Position::Left); return; @@ -78,10 +74,9 @@ void NthRootLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldReco assert(cursor->layoutNode() == this); if (cursor->position() == LayoutCursor::Position::Left) { // Case: Left. Go to the index if there is one, else go to the radicand. - if (!indexLayout()->isUninitialized()) { + if (indexLayout() != nullptr) { cursor->setLayoutNode(indexLayout()); } else { - assert(!radicandLayout()->isUninitialized()); cursor->setLayoutNode(radicandLayout()); } return; @@ -89,14 +84,13 @@ void NthRootLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldReco assert(cursor->position() == LayoutCursor::Position::Right); // Case: Right. Ask the parent. LayoutNode * parentNode = parent(); - if (!parentNode->isUninitialized()) { + if (parentNode != nullptr) { parentNode->moveCursorRight(cursor, shouldRecomputeLayout); } } void NthRootLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) { - if (!indexLayout()->isUninitialized() - && !radicandLayout()->isUninitialized() + if (indexLayout() != nullptr && cursor->isEquivalentTo(LayoutCursor(radicandLayout(), LayoutCursor::Position::Left))) { // If the cursor is Left of the radicand, move it to the index. @@ -104,7 +98,7 @@ void NthRootLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecompu cursor->setPosition(LayoutCursor::Position::Right); return; } - if (!indexLayout()->isUninitialized() + if (indexLayout() != nullptr && cursor->layoutNode() == this && cursor->position() == LayoutCursor::Position::Left) { @@ -117,12 +111,11 @@ void NthRootLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecompu } void NthRootLayoutNode::moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) { - if (!indexLayout()->isUninitialized() + if (indexLayout() != nullptr && cursor->layoutNode()->hasAncestor(indexLayout(), true)) { if (cursor->isEquivalentTo(LayoutCursor(indexLayout(), LayoutCursor::Position::Right))) { // If the cursor is Right of the index, move it to the radicand. - assert(!radicandLayout()->isUninitialized()); cursor->setLayoutNode(radicandLayout()); cursor->setPosition(LayoutCursor::Position::Left); return; @@ -204,7 +197,7 @@ KDSize NthRootLayoutNode::computeSize() { } KDCoordinate NthRootLayoutNode::computeBaseline() { - if (!indexLayout()->isUninitialized()) { + if (indexLayout() != nullptr) { return max( radicandLayout()->baseline() + k_radixLineThickness + k_heightMargin, indexLayout()->layoutSize().height() + k_indexHeight); @@ -220,7 +213,7 @@ KDPoint NthRootLayoutNode::positionOfChild(LayoutNode * child) { if (child == radicandLayout()) { x = indexSize.width() + 2*k_widthMargin + k_radixLineThickness; y = baseline() - radicandLayout()->baseline(); - } else if (!indexLayout()->isUninitialized() && child == indexLayout()) { + } else if (indexLayout() != nullptr && child == indexLayout()) { x = 0; y = baseline() - indexSize.height() - k_indexHeight; } else { @@ -230,7 +223,7 @@ KDPoint NthRootLayoutNode::positionOfChild(LayoutNode * child) { } KDSize NthRootLayoutNode::adjustedIndexSize() { - return indexLayout()->isUninitialized() ? + return indexLayout() == nullptr ? KDSize(k_leftRadixWidth, 0) : KDSize(max(k_leftRadixWidth, indexLayout()->layoutSize().width()), indexLayout()->layoutSize().height()); } diff --git a/poincare/src/sequence_layout_node.cpp b/poincare/src/sequence_layout_node.cpp index 0c3dfbe8b..70ea23315 100644 --- a/poincare/src/sequence_layout_node.cpp +++ b/poincare/src/sequence_layout_node.cpp @@ -13,19 +13,17 @@ constexpr char SequenceLayoutNode::k_nEquals[]; void SequenceLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) { if (cursor->position() == LayoutCursor::Position::Left - && ((!lowerBoundLayout()->isUninitialized() && cursor->layoutNode() == lowerBoundLayout()) - || (!upperBoundLayout()->isUninitialized() && cursor->layoutNode() == upperBoundLayout()))) + && (cursor->layoutNode() == lowerBoundLayout() + || cursor->layoutNode() == upperBoundLayout())) { // Case: Left of the bounds. Go Left of the sequence. cursor->setLayoutNode(this); return; } if (cursor->position() == LayoutCursor::Position::Left - && !argumentLayout()->isUninitialized() && cursor->layoutNode() == argumentLayout()) { // Case: Left of the argument. Go Right of the lower bound. - assert(!lowerBoundLayout()->isUninitialized()); cursor->setLayoutNode(lowerBoundLayout()); cursor->setPosition(LayoutCursor::Position::Right); return; @@ -33,7 +31,6 @@ void SequenceLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldReco assert(cursor->layoutNode() == this); if (cursor->position() == LayoutCursor::Position::Right) { // Case: Right. Go to the argument and move Left. - assert(!argumentLayout()->isUninitialized()); cursor->setLayoutNode(argumentLayout()); cursor->setPosition(LayoutCursor::Position::Right); return; @@ -41,24 +38,22 @@ void SequenceLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldReco assert(cursor->position() == LayoutCursor::Position::Left); // Case: Left. Ask the parent. LayoutNode * parentLayout = parent(); - if (!parentLayout->isUninitialized()) { + if (parentLayout != nullptr) { parentLayout->moveCursorLeft(cursor, shouldRecomputeLayout); } } void SequenceLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) { if (cursor->position() == LayoutCursor::Position::Right - && ((!lowerBoundLayout()->isUninitialized() && cursor->layoutNode() == lowerBoundLayout()) - || (!upperBoundLayout()->isUninitialized() && cursor->layoutNode() == upperBoundLayout()))) + && (cursor->layoutNode() == lowerBoundLayout() + || cursor->layoutNode() == upperBoundLayout())) { // Case: Right of the bounds. Go Left of the argument. - assert(!argumentLayout()->isUninitialized()); cursor->setLayoutNode(argumentLayout()); cursor->setPosition(LayoutCursor::Position::Left); return; } if (cursor->position() == LayoutCursor::Position::Right - && !argumentLayout()->isUninitialized() && cursor->layoutNode() == argumentLayout()) { // Case: Right of the argument. Go Right. @@ -68,30 +63,25 @@ void SequenceLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRec assert(cursor->layoutNode() == this); if (cursor->position() == LayoutCursor::Position::Left) { // Case: Left. Go to the upper bound - assert(!upperBoundLayout()->isUninitialized()); cursor->setLayoutNode(upperBoundLayout()); return; } assert(cursor->position() == LayoutCursor::Position::Right); // Case: Right. Ask the parent LayoutNode * parentLayout = parent(); - if (!parentLayout->isUninitialized()) { + if (parentLayout != nullptr) { parentLayout->moveCursorRight(cursor, shouldRecomputeLayout); } } void SequenceLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) { - if (!lowerBoundLayout()->isUninitialized() && cursor->layoutNode()->hasAncestor(lowerBoundLayout(), true)) { + if (cursor->layoutNode()->hasAncestor(lowerBoundLayout(), true)) { // If the cursor is inside the lower bound, move it to the upper bound - assert(!upperBoundLayout()->isUninitialized()); upperBoundLayout()->moveCursorUpInDescendants(cursor, shouldRecomputeLayout); return; } - if (!argumentLayout()->isUninitialized() - && cursor->isEquivalentTo(LayoutCursor(argumentLayout(), LayoutCursor::Position::Left))) - { + if (cursor->isEquivalentTo(LayoutCursor(argumentLayout(), LayoutCursor::Position::Left))) { // If the cursor is Left of the argument, move it to the upper bound - assert(!upperBoundLayout()->isUninitialized()); upperBoundLayout()->moveCursorUpInDescendants(cursor, shouldRecomputeLayout); return; } @@ -99,17 +89,13 @@ void SequenceLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * shouldRecomp } void SequenceLayoutNode::moveCursorDown(LayoutCursor * cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited) { - if (!upperBoundLayout()->isUninitialized() && cursor->layoutNode()->hasAncestor(upperBoundLayout(), true)) { + if (cursor->layoutNode()->hasAncestor(upperBoundLayout(), true)) { // If the cursor is inside the upper bound, move it to the lower bound - assert(!lowerBoundLayout()->isUninitialized()); lowerBoundLayout()->moveCursorDownInDescendants(cursor, shouldRecomputeLayout); return; } // If the cursor is Left of the argument, move it to the lower bound - if (!argumentLayout()->isUninitialized() - && cursor->isEquivalentTo(LayoutCursor(argumentLayout(), LayoutCursor::Position::Left))) - { - assert(!lowerBoundLayout()->isUninitialized()); + if (cursor->isEquivalentTo(LayoutCursor(argumentLayout(), LayoutCursor::Position::Left))) { lowerBoundLayout()->moveCursorDownInDescendants(cursor, shouldRecomputeLayout); return; } diff --git a/poincare/src/tree_node.cpp b/poincare/src/tree_node.cpp index b48b0fa92..238b3f1b6 100644 --- a/poincare/src/tree_node.cpp +++ b/poincare/src/tree_node.cpp @@ -40,7 +40,7 @@ void TreeNode::rename(int identifier, bool unregisterPreviousIdentifier) { TreeNode * TreeNode::parent() const { if (m_parentIdentifier == TreePool::NoNodeIdentifier) { - return uninitializedStaticNode(); + return nullptr; } return TreePool::sharedPool()->node(m_parentIdentifier); } @@ -48,7 +48,7 @@ TreeNode * TreeNode::parent() const { TreeNode * TreeNode::root() { TreeNode * result = this; TreeNode * resultParent = result->parent(); - while(!resultParent->isUninitialized()) { + while(resultParent != nullptr) { result = resultParent; resultParent = result->parent(); } @@ -93,7 +93,7 @@ int TreeNode::indexOfChild(const TreeNode * child) const { int TreeNode::indexInParent() const { TreeNode * p = parent(); - if (p->isUninitialized()) { + if (p == nullptr) { return -1; } return p->indexOfChild(this); @@ -122,7 +122,7 @@ bool TreeNode::hasAncestor(const TreeNode * node, bool includeSelf) const { bool TreeNode::hasSibling(const TreeNode * e) const { TreeNode * p = parent(); - if (p->isUninitialized()) { + if (p == nullptr) { return false; } for (TreeNode * childNode : p->directChildren()) { diff --git a/poincare/src/tree_pool.cpp b/poincare/src/tree_pool.cpp index 07c94bdeb..cc5ab0d07 100644 --- a/poincare/src/tree_pool.cpp +++ b/poincare/src/tree_pool.cpp @@ -205,11 +205,11 @@ void TreePool::freePoolFromNode(TreeNode * firstNodeToDiscard) { if (firstNodeToDiscard < last()) { // There should be no tree that continues into the pool zone to discard #if POINCARE_TREE_LOG - if (!firstNodeToDiscard->parent()->isUninitialized()) { + if (!firstNodeToDiscard->parent() == nullptr) { log(); } #endif - assert(firstNodeToDiscard->parent()->isUninitialized()); + assert(firstNodeToDiscard->parent() == nullptr); } TreeNode * currentNode = firstNodeToDiscard; TreeNode * lastNode = last(); diff --git a/poincare/src/uninitialized_evaluation_node.cpp b/poincare/src/uninitialized_evaluation_node.cpp deleted file mode 100644 index ec80cd687..000000000 --- a/poincare/src/uninitialized_evaluation_node.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include - -namespace Poincare { - -template -UninitializedEvaluationNode * UninitializedEvaluationNode::UninitializedEvaluationStaticNode() { - static UninitializedEvaluationNode exception; - TreePool::sharedPool()->registerStaticNodeIfRequired(&exception); - return &exception; -} - -template UninitializedEvaluationNode * UninitializedEvaluationNode::UninitializedEvaluationStaticNode(); -template UninitializedEvaluationNode * UninitializedEvaluationNode::UninitializedEvaluationStaticNode(); - -} diff --git a/poincare/src/uninitialized_expression_node.cpp b/poincare/src/uninitialized_expression_node.cpp deleted file mode 100644 index 90aa64e51..000000000 --- a/poincare/src/uninitialized_expression_node.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include - -namespace Poincare { - -UninitializedExpressionNode * UninitializedExpressionNode::UninitializedExpressionStaticNode() { - static UninitializedExpressionNode exception; - return &exception; -} - -} diff --git a/poincare/src/uninitialized_ghost_node.cpp b/poincare/src/uninitialized_ghost_node.cpp deleted file mode 100644 index 65fa893fd..000000000 --- a/poincare/src/uninitialized_ghost_node.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include - -namespace Poincare { - -UninitializedGhostNode * UninitializedGhostNode::UninitializedGhostStaticNode() { - static UninitializedGhostNode exception; - return &exception; -} - -} diff --git a/poincare/src/uninitialized_layout_node.cpp b/poincare/src/uninitialized_layout_node.cpp deleted file mode 100644 index 409308412..000000000 --- a/poincare/src/uninitialized_layout_node.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include - -namespace Poincare { - -UninitializedLayoutNode * UninitializedLayoutNode::UninitializedLayoutStaticNode() { - static UninitializedLayoutNode exception; - TreePool::sharedPool()->registerStaticNodeIfRequired(&exception); - return &exception; -} - -} diff --git a/poincare/src/vertical_offset_layout_node.cpp b/poincare/src/vertical_offset_layout_node.cpp index e1fb19abd..874230005 100644 --- a/poincare/src/vertical_offset_layout_node.cpp +++ b/poincare/src/vertical_offset_layout_node.cpp @@ -10,8 +10,7 @@ namespace Poincare { void VerticalOffsetLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) { - if (!indiceLayout()->isUninitialized() - && cursor->layoutNode() == indiceLayout() + if (cursor->layoutNode() == indiceLayout() && cursor->position() == LayoutCursor::Position::Left) { // Case: Left of the indice. Go Left. @@ -21,21 +20,20 @@ void VerticalOffsetLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shou assert(cursor->layoutNode() == this); if (cursor->position() == LayoutCursor::Position::Right) { // Case: Right. Go to the indice. - assert(!indiceLayout()->isUninitialized()); + assert(indiceLayout() != nullptr); cursor->setLayoutNode(indiceLayout()); return; } // Case: Left. Ask the parent. assert(cursor->position() == LayoutCursor::Position::Left); LayoutNode * parentNode = parent(); - if (!parentNode->isUninitialized()) { + if (parentNode != nullptr) { parentNode->moveCursorLeft(cursor, shouldRecomputeLayout); } } void VerticalOffsetLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) { - if (!indiceLayout()->isUninitialized() - && cursor->layoutNode() == indiceLayout() + if (cursor->layoutNode() == indiceLayout() && cursor->position() == LayoutCursor::Position::Right) { // Case: Right of the indice. Go Right. @@ -45,14 +43,13 @@ void VerticalOffsetLayoutNode::moveCursorRight(LayoutCursor * cursor, bool * sho assert(cursor->layoutNode() == this); if (cursor->position() == LayoutCursor::Position::Left) { // Case: Left. Go to the indice. - assert(!indiceLayout()->isUninitialized()); cursor->setLayoutNode(indiceLayout()); return; } // Case: Right. Ask the parent. assert(cursor->position() == LayoutCursor::Position::Right); LayoutNode * parentNode = parent(); - if (!parentNode->isUninitialized()) { + if (parentNode != nullptr) { parentNode->moveCursorRight(cursor, shouldRecomputeLayout); } } @@ -62,14 +59,12 @@ void VerticalOffsetLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * should // Case: Superscript. if (cursor->isEquivalentTo(LayoutCursor(this, LayoutCursor::Position::Right))) { // Case: Right. Move to the indice. - assert(!indiceLayout()->isUninitialized()); cursor->setLayoutNode(indiceLayout()); cursor->setPosition(LayoutCursor::Position::Right); return; } if (cursor->isEquivalentTo(LayoutCursor(this, LayoutCursor::Position::Left))) { // Case: Left. Move to the indice. - assert(!indiceLayout()->isUninitialized()); cursor->setLayoutNode(indiceLayout()); cursor->setPosition(LayoutCursor::Position::Left); return; @@ -78,7 +73,6 @@ void VerticalOffsetLayoutNode::moveCursorUp(LayoutCursor * cursor, bool * should /* Case: Subscript, Left or Right of the indice. Put the cursor at the same * position, pointing this. */ if (m_type == Type::Subscript - && !indiceLayout()->isUninitialized() && (cursor->isEquivalentTo(LayoutCursor(indiceLayout(), LayoutCursor::Position::Left)) || cursor->isEquivalentTo(LayoutCursor(indiceLayout(), LayoutCursor::Position::Right)))) { @@ -93,14 +87,12 @@ void VerticalOffsetLayoutNode::moveCursorDown(LayoutCursor * cursor, bool * shou // Case: Subscript. if (cursor->isEquivalentTo(LayoutCursor(this, LayoutCursor::Position::Right))) { // Case: Right. Move to the indice. - assert(!indiceLayout()->isUninitialized()); cursor->setLayoutNode(indiceLayout()); cursor->setPosition(LayoutCursor::Position::Right); return; } // Case: Left. Move to the indice. if (cursor->isEquivalentTo(LayoutCursor(this, LayoutCursor::Position::Left))) { - assert(!indiceLayout()->isUninitialized()); cursor->setLayoutNode(indiceLayout()); cursor->setPosition(LayoutCursor::Position::Left); return; @@ -109,7 +101,6 @@ void VerticalOffsetLayoutNode::moveCursorDown(LayoutCursor * cursor, bool * shou /* Case: Superscript, Left or Right of the indice. Put the cursor at the same * position, pointing this. */ if (m_type == Type::Superscript - && !indiceLayout()->isUninitialized() && cursor->layoutNode() == indiceLayout()) { cursor->setLayoutNode(this); @@ -190,7 +181,7 @@ int VerticalOffsetLayoutNode::serialize(char * buffer, int bufferSize, Preferenc // Add a multiplication if omitted. int indexInParent = -1; LayoutNode * parentNode = parent(); - if (!parentNode->isUninitialized()) { + if (parentNode != nullptr) { indexInParent = parentNode->indexOfChild(this); } if (indexInParent >= 0 && indexInParent < (parentNode->numberOfChildren() - 1) && parentNode->isHorizontal() && parentNode->childAtIndex(indexInParent + 1)->canBeOmittedMultiplicationRightFactor()) { @@ -206,7 +197,7 @@ KDSize VerticalOffsetLayoutNode::computeSize() { KDCoordinate width = indiceSize.width(); if (m_type == Type::Superscript) { LayoutNode * parentNode = parent(); - assert(!parentNode->isUninitialized()); + assert(parentNode != nullptr); assert(parentNode->isHorizontal()); int idxInParent = parentNode->indexOfChild(this); if (idxInParent < parentNode->numberOfChildren() - 1 && parentNode->childAtIndex(idxInParent + 1)->hasUpperLeftIndex()) { @@ -231,7 +222,6 @@ KDPoint VerticalOffsetLayoutNode::positionOfChild(LayoutNode * child) { return KDPointZero; } assert(m_type == Type::Subscript); - assert(!baseLayout()->isUninitialized()); return KDPoint(0, baseLayout()->layoutSize().height() - k_indiceHeight); } @@ -274,7 +264,7 @@ bool VerticalOffsetLayoutNode::willAddSibling(LayoutCursor * cursor, LayoutNode LayoutNode * VerticalOffsetLayoutNode::baseLayout() { LayoutNode * parentNode = parent(); - assert(!parentNode->isUninitialized()); + assert(parentNode != nullptr); assert(parentNode->isHorizontal()); int idxInParent = parentNode->indexOfChild(this); assert(idxInParent > 0); diff --git a/poincare/test/tree/blob_node.cpp b/poincare/test/tree/blob_node.cpp deleted file mode 100644 index d4abeaddb..000000000 --- a/poincare/test/tree/blob_node.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "blob_node.h" - -namespace Poincare { - -TreeNode * BlobNode::uninitializedStaticNode() const { - return UninitializedBlobNode::UninitializedBlobStaticNode(); -} - -UninitializedBlobNode * UninitializedBlobNode::UninitializedBlobStaticNode() { - static UninitializedBlobNode exception; - TreePool::sharedPool()->registerStaticNodeIfRequired(&exception); - return &exception; -} - -} diff --git a/poincare/test/tree/blob_node.h b/poincare/test/tree/blob_node.h index 982d03645..fd95237b3 100644 --- a/poincare/test/tree/blob_node.h +++ b/poincare/test/tree/blob_node.h @@ -8,7 +8,6 @@ namespace Poincare { class BlobNode : public TreeNode { public: - TreeNode * uninitializedStaticNode() const override; virtual size_t size() const override { return sizeof(BlobNode); } int data() { return m_data; } void setData(int data) { m_data = data; } @@ -22,20 +21,6 @@ private: int m_data; }; -class UninitializedBlobNode : public BlobNode { -public: - static UninitializedBlobNode * UninitializedBlobStaticNode(); - - size_t size() const override { return sizeof(UninitializedBlobNode); } - bool isUninitialized() const override { return true; } - int numberOfChildren() const override { return 0; } -#if POINCARE_TREE_LOG - virtual void logNodeName(std::ostream & stream) const override { - stream << "UninitializedBlob"; - } -#endif -}; - class BlobByReference : public TreeByReference { public: BlobByReference(int data = 0) : TreeByReference(TreePool::sharedPool()->createTreeNode()) { diff --git a/poincare/test/tree/pair_node.cpp b/poincare/test/tree/pair_node.cpp deleted file mode 100644 index e4d00080d..000000000 --- a/poincare/test/tree/pair_node.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "pair_node.h" - -namespace Poincare { - -TreeNode * PairNode::uninitializedStaticNode() const { - return UninitializedPairNode::UninitializedPairStaticNode(); -} - -UninitializedPairNode * UninitializedPairNode::UninitializedPairStaticNode() { - static UninitializedPairNode exception; - TreePool::sharedPool()->registerStaticNodeIfRequired(&exception); - return &exception; -} - -} diff --git a/poincare/test/tree/pair_node.h b/poincare/test/tree/pair_node.h index a8ee4565d..2e551f7f2 100644 --- a/poincare/test/tree/pair_node.h +++ b/poincare/test/tree/pair_node.h @@ -8,7 +8,6 @@ namespace Poincare { class PairNode : public TreeNode { public: - TreeNode * uninitializedStaticNode() const override; virtual size_t size() const override { return sizeof(PairNode); } virtual int numberOfChildren() const override { return 2; } #if POINCARE_TREE_LOG @@ -18,20 +17,6 @@ public: #endif }; -class UninitializedPairNode : public PairNode { -public: - static UninitializedPairNode * UninitializedPairStaticNode(); - - size_t size() const override { return sizeof(UninitializedPairNode); } - bool isUninitialized() const override { return true; } - int numberOfChildren() const override { return 0; } -#if POINCARE_TREE_LOG - virtual void logNodeName(std::ostream & stream) const override { - stream << "UninitializedPairNode"; - } -#endif -}; - class PairByReference : public TreeByReference { public: PairByReference(TreeByReference t1, TreeByReference t2) : TreeByReference(TreePool::sharedPool()->createTreeNode()) {