[poincare] Fix Infinity

This commit is contained in:
Émilie Feral
2018-08-08 11:57:45 +02:00
parent a8a5c41d66
commit 987c758adc
3 changed files with 4 additions and 17 deletions

View File

@@ -43,7 +43,7 @@ template<typename T>
class Evaluation : public TreeByValue {
public:
EvaluationNode<T> * node() const override {
assert(!TreeByValue::node().isGhost());
assert(!TreeByValue::node()->isGhost());
return static_cast<EvaluationNode<T> *>(TreeByValue::node());
}
typename Poincare::EvaluationNode<T>::Type type() const { return node()->type(); }

View File

@@ -2,7 +2,6 @@
#define POINCARE_INFINITY_H
#include <poincare/number.h>
#include <poincare/allocation_failed_expression_node.h>
namespace Poincare {
@@ -40,26 +39,13 @@ private:
bool m_negative;
};
class AllocationFailureInfinityNode : public InfinityNode, public AllocationFailedExpressionNode {
using AllocationFailedExpressionNode::type;
using AllocationFailedExpressionNode::approximate;
using AllocationFailedExpressionNode::writeTextInBuffer;
using AllocationFailedExpressionNode::createLayout;
using AllocationFailedExpressionNode::numberOfChildren;
using AllocationFailedExpressionNode::isAllocationFailure;
size_t size() const override { return sizeof(AllocationFailureInfinityNode); }
#if TREE_LOG
const char * description() const override { return "AllocationFailureInfinityNode"; }
#endif
};
class Infinity : public Number {
public:
Infinity(bool negative) : Number(TreePool::sharedPool()->createTreeNode<InfinityNode>()) {
node()->setNegative(negative);
}
private:
InfinityNode * node() { return static_cast<InfinityNode *>(Number::node()); }
InfinityNode * node() const override { return static_cast<InfinityNode *>(Number::node()); }
};
}

View File

@@ -1,4 +1,5 @@
#include <poincare/infinity.h>
#include <poincare/allocation_failure_expression_node.h>
#include <poincare/complex.h>
#include <poincare/layout_engine.h>
@@ -10,7 +11,7 @@ extern "C" {
namespace Poincare {
InfinityNode * InfinityNode::FailedAllocationStaticNode() {
static AllocationFailureInfinityNode failure;
static AllocationFailureExpressionNode<InfinityNode> failure;
return &failure;
}