[poincare] Fix Ghost, AllocationF an Uninitilized nodes staticNode methods

This commit is contained in:
Léa Saviot
2018-08-17 10:46:05 +02:00
parent 466dafa2fa
commit c627b5067a
8 changed files with 17 additions and 31 deletions

View File

@@ -16,8 +16,11 @@ public:
// TreeNode
bool isAllocationFailure() const override { return true; }
size_t size() const override { return sizeof(AllocationFailureEvaluationNode<T, U>); }
#if TREE_LOG
const char * description() const override { return "AllocationFailureEvaluation"; }
TreeNode * uninitializedStaticNode() const override { assert(false); return nullptr; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "AllocationFailureEvaluation";
}
#endif
};

View File

@@ -13,6 +13,7 @@ public:
// TreeNode
size_t size() const override { return sizeof(AllocationFailureExpressionNode<T>); }
bool isAllocationFailure() const override { return true; }
TreeNode * uninitializedStaticNode() const override { assert(false); return nullptr; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "AllocationFailureExpression[";

View File

@@ -10,6 +10,7 @@ class AllocationFailureLayoutNode : public ExceptionLayoutNode<T> {
public:
size_t size() const override { return sizeof(AllocationFailureLayoutNode<T>); }
bool isAllocationFailure() const override { return true; }
TreeNode * uninitializedStaticNode() const override { assert(false); return nullptr; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "AllocationFailureLayout";

View File

@@ -22,22 +22,7 @@ public:
static GhostNode * FailedAllocationStaticNode();
TreeNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
// Uninitialized
TreeNode * uninitializedStaticNode() const override;
};
class UninitializedGhostNode : public GhostNode {
public:
static UninitializedGhostNode * UninitializedGhostStaticNode();
size_t size() const override { return sizeof(UninitializedGhostNode); }
bool isUninitialized() const override { return true; }
GhostNode * failedAllocationStaticNode() override { assert(false); return nullptr; } //TODO ?
int numberOfChildren() const override { return 0; }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {
stream << "UninitializedGhost";
}
#endif
TreeNode * uninitializedStaticNode() const override { assert(false); return nullptr; }
};
class AllocationFailedGhostNode : public GhostNode {

View File

@@ -16,7 +16,9 @@ public:
static UninitializedEvaluationNode<T> * UninitializedEvaluationStaticNode();
// TreeNode
bool isUninitialized() const override { return true; }
TreeNode * failedAllocationStaticNode() override { /*TODO*/ assert(false); return nullptr; /* Or call parent method ?*/ }
/* There is only one static node, that should never be inserted in the pool,
* so no need for an allocation failure. */
TreeNode * failedAllocationStaticNode() override { assert(false); return nullptr; }
size_t size() const override { return sizeof(UninitializedEvaluationNode); }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {

View File

@@ -26,7 +26,9 @@ public:
// TreeNode
bool isUninitialized() const override { return true; }
TreeNode * failedAllocationStaticNode() override { /*TODO*/ assert(false); return nullptr; /* Or call parent method ?*/ }
/* There is only one static node, that should never be inserted in the pool,
* so no need for an allocation failure. */
TreeNode * failedAllocationStaticNode() override { assert(false); return nullptr; }
size_t size() const override { return sizeof(UninitializedExpressionNode); }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {

View File

@@ -61,7 +61,9 @@ public:
// TreeNode
bool isUninitialized() const override { return true; }
TreeNode * failedAllocationStaticNode() override { /*TODO*/ assert(false); return nullptr; /* Or call parent method ?*/ }
/* There is only one static node, that should never be inserted in the pool,
* so no need for an allocation failure. */
TreeNode * failedAllocationStaticNode() override { assert(false); return nullptr; }
size_t size() const override { return sizeof(UninitializedLayoutNode); }
#if POINCARE_TREE_LOG
virtual void logNodeName(std::ostream & stream) const override {

View File

@@ -3,20 +3,10 @@
namespace Poincare {
TreeNode * GhostNode::uninitializedStaticNode() const {
return UninitializedGhostNode::UninitializedGhostStaticNode();
}
GhostNode * GhostNode::FailedAllocationStaticNode() {
static AllocationFailedGhostNode failure;
TreePool::sharedPool()->registerStaticNodeIfRequired(&failure);
return &failure;
}
UninitializedGhostNode * UninitializedGhostNode::UninitializedGhostStaticNode() {
static UninitializedGhostNode exception;
TreePool::sharedPool()->registerStaticNodeIfRequired(&exception);
return &exception;
}
}