mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-23 07:40:42 +01:00
[poincare] Fix Infinity
This commit is contained in:
@@ -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(); }
|
||||
|
||||
@@ -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()); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user