mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare] Remove AllocationFailures
This commit is contained in:
@@ -54,31 +54,13 @@ void Calculation::setContent(const char * c, Context * context, Expression ansEx
|
||||
KDCoordinate Calculation::height(Context * context) {
|
||||
if (m_height < 0) {
|
||||
LayoutRef inputLayout = createInputLayout();
|
||||
if (inputLayout.isAllocationFailure()) {
|
||||
/* If there is not enough tree pool space to create the layout, return a
|
||||
* default height. Do not store it in m_height in case some memory gets
|
||||
* freed afterwards. */
|
||||
return k_heightComputationFailureHeight;
|
||||
}
|
||||
KDCoordinate inputHeight = inputLayout.layoutSize().height();
|
||||
LayoutRef approximateLayout = createApproximateOutputLayout(context);
|
||||
if (approximateLayout.isAllocationFailure()) {
|
||||
/* If there is not enough tree pool space to create the layout, return a
|
||||
* default height. Do not store it in m_height in case some memory gets
|
||||
* freed afterwards. */
|
||||
return k_heightComputationFailureHeight;
|
||||
}
|
||||
KDCoordinate approximateOutputHeight = approximateLayout.layoutSize().height();
|
||||
if (shouldOnlyDisplayApproximateOutput(context)) {
|
||||
m_height = inputHeight+approximateOutputHeight;
|
||||
} else {
|
||||
LayoutRef exactLayout = createExactOutputLayout(context);
|
||||
if (exactLayout.isAllocationFailure()) {
|
||||
/* If there is not enough tree pool space to create the layout, return a
|
||||
* default height. Do not store it in m_height in case some memory gets
|
||||
* freed afterwards. */
|
||||
return k_heightComputationFailureHeight;
|
||||
}
|
||||
KDCoordinate exactOutputHeight = exactLayout.layoutSize().height();
|
||||
KDCoordinate outputHeight = max(exactLayout.baseline(), approximateLayout.baseline()) + max(exactOutputHeight-exactLayout.baseline(), approximateOutputHeight-approximateLayout.baseline());
|
||||
m_height = inputHeight + outputHeight;
|
||||
|
||||
@@ -43,10 +43,6 @@ void LayoutField::reload() {
|
||||
}
|
||||
|
||||
bool LayoutField::handleEventWithText(const char * text, bool indentation, bool forceCursorRightOfText) {
|
||||
if (m_contentView.cursor()->layoutReference().isAllocationFailure()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (text[0] == 0) {
|
||||
// The text is empty
|
||||
return true;
|
||||
@@ -60,8 +56,6 @@ bool LayoutField::handleEventWithText(const char * text, bool indentation, bool
|
||||
return true;
|
||||
}
|
||||
|
||||
LayoutRef rootRef = m_contentView.expressionView()->layoutRef();
|
||||
|
||||
// Handle special cases
|
||||
if (strcmp(text, Ion::Events::Division.text()) == 0) {
|
||||
m_contentView.cursor()->addFractionLayoutAndCollapseSiblings();
|
||||
@@ -108,17 +102,10 @@ bool LayoutField::handleEventWithText(const char * text, bool indentation, bool
|
||||
insertLayoutAtCursor(resultLayoutRef, pointedLayoutRef, forceCursorRightOfText);
|
||||
}
|
||||
}
|
||||
if (rootRef.isAllocationFailure()) {
|
||||
m_contentView.cursor()->setLayoutReference(rootRef);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LayoutField::handleEvent(Ion::Events::Event event) {
|
||||
if (m_contentView.cursor()->layoutReference().isAllocationFailure()) {
|
||||
return false;
|
||||
}
|
||||
LayoutRef rootRef = m_contentView.expressionView()->layoutRef();
|
||||
bool didHandleEvent = false;
|
||||
bool shouldRecomputeLayout = m_contentView.cursor()->showEmptyLayoutIfNeeded();
|
||||
bool moveEventChangedLayout = false;
|
||||
@@ -133,9 +120,6 @@ bool LayoutField::handleEvent(Ion::Events::Event event) {
|
||||
didHandleEvent = true;
|
||||
}
|
||||
if (didHandleEvent) {
|
||||
if (rootRef.isAllocationFailure()) {
|
||||
m_contentView.cursor()->setLayoutReference(rootRef);
|
||||
}
|
||||
shouldRecomputeLayout = m_contentView.cursor()->hideEmptyLayoutIfNeeded() || shouldRecomputeLayout;
|
||||
if (!shouldRecomputeLayout) {
|
||||
m_contentView.cursorPositionChanged();
|
||||
@@ -248,7 +232,7 @@ void LayoutField::scrollToBaselinedRect(KDRect rect, KDCoordinate baseline) {
|
||||
}
|
||||
|
||||
void LayoutField::insertLayoutAtCursor(LayoutRef layoutR, LayoutRef pointedLayoutR, bool forceCursorRightOfLayout) {
|
||||
if (layoutR.isUninitialized() || layoutRef().isAllocationFailure()) {
|
||||
if (layoutR.isUninitialized()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -262,9 +246,7 @@ void LayoutField::insertLayoutAtCursor(LayoutRef layoutR, LayoutRef pointedLayou
|
||||
m_contentView.cursor()->addLayoutAndMoveCursor(layoutR);
|
||||
|
||||
// Move the cursor if needed
|
||||
if (layoutRef().isAllocationFailure()) {
|
||||
m_contentView.cursor()->setLayoutReference(layoutRef());
|
||||
} else if(!forceCursorRightOfLayout) {
|
||||
if(!forceCursorRightOfLayout) {
|
||||
if (!pointedLayoutR.isUninitialized() && (!layoutWillBeMerged || pointedLayoutR != layoutR)) {
|
||||
// Make sure the layout was inserted (its parent is not uninitialized)
|
||||
m_contentView.cursor()->setLayoutReference(pointedLayoutR);
|
||||
@@ -280,9 +262,6 @@ void LayoutField::insertLayoutAtCursor(LayoutRef layoutR, LayoutRef pointedLayou
|
||||
|
||||
// Handle matrices
|
||||
m_contentView.cursor()->layoutReference().addGreySquaresToAllMatrixAncestors();
|
||||
if (layoutRef().isAllocationFailure()) {
|
||||
m_contentView.cursor()->setLayoutReference(layoutRef());
|
||||
}
|
||||
|
||||
// Handle empty layouts
|
||||
m_contentView.cursor()->hideEmptyLayoutIfNeeded();
|
||||
|
||||
@@ -129,7 +129,7 @@ bool SelectableTableView::handleEvent(Ion::Events::Event event) {
|
||||
return true;
|
||||
}
|
||||
Poincare::LayoutRef layoutR = cell->layoutRef();
|
||||
if (!layoutR.isUninitialized() && !layoutR.isAllocationFailure()) {
|
||||
if (!layoutR.isUninitialized()) {
|
||||
Clipboard::sharedClipboard()->store(layoutR);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ SFLAGS += -Ipoincare/include
|
||||
#include poincare/src/simplify/Makefile
|
||||
#include poincare/src/simplification/Makefile
|
||||
objs += $(addprefix poincare/src/,\
|
||||
absolute_value_layout_node.o\
|
||||
binomial_coefficient_layout_node.o\
|
||||
bracket_layout_node.o\
|
||||
bracket_pair_layout_node.o\
|
||||
|
||||
@@ -10,9 +10,6 @@ namespace Poincare {
|
||||
|
||||
class AbsoluteValueNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static AbsoluteValueNode * FailedAllocationStaticNode();
|
||||
AbsoluteValueNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(AbsoluteValueNode); }
|
||||
int numberOfChildren() const override { return 1; }
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#ifndef POINCARE_ABSOLUTE_VALUE_LAYOUT_NODE_H
|
||||
#define POINCARE_ABSOLUTE_VALUE_LAYOUT_NODE_H
|
||||
|
||||
#include <poincare/allocation_failure_layout_node.h>
|
||||
#include <poincare/bracket_pair_layout_node.h>
|
||||
#include <poincare/serialization_helper.h>
|
||||
|
||||
@@ -17,8 +16,6 @@ public:
|
||||
}
|
||||
|
||||
// TreeNode
|
||||
static AbsoluteValueLayoutNode * FailedAllocationStaticNode();
|
||||
AbsoluteValueLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
size_t size() const override { return sizeof(AbsoluteValueLayoutNode); }
|
||||
#if POINCARE_TREE_LOG
|
||||
virtual void logNodeName(std::ostream & stream) const override {
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define POINCARE_ADDITION_H
|
||||
|
||||
#include <poincare/approximation_helper.h>
|
||||
#include <poincare/allocation_failure_layout_node.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/n_ary_expression_node.h>
|
||||
#include <poincare/rational.h>
|
||||
@@ -16,8 +15,6 @@ public:
|
||||
using NAryExpressionNode::NAryExpressionNode;
|
||||
|
||||
// Tree
|
||||
static AdditionNode * FailedAllocationStaticNode();
|
||||
AdditionNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
size_t size() const override { return sizeof(AdditionNode); }
|
||||
#if POINCARE_TREE_LOG
|
||||
virtual void logNodeName(std::ostream & stream) const override {
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
#ifndef POINCARE_ALLOCATION_FAILURE_EVALUATION_NODE_H
|
||||
#define POINCARE_ALLOCATION_FAILURE_EVALUATION_NODE_H
|
||||
|
||||
#include <poincare/exception_evaluation_node.h>
|
||||
#include <poincare/complex.h>
|
||||
#include <poincare/undefined.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
template <template<typename> class T, class U>
|
||||
class AllocationFailureEvaluationNode : public ExceptionEvaluationNode<T, U> {
|
||||
public:
|
||||
// EvaluationNode
|
||||
typename EvaluationNode<U>::Type type() const override { return EvaluationNode<U>::Type::AllocationFailure; }
|
||||
|
||||
// TreeNode
|
||||
bool isAllocationFailure() const override { return true; }
|
||||
size_t size() const override { return sizeof(AllocationFailureEvaluationNode<T, U>); }
|
||||
TreeNode * uninitializedStaticNode() const override { assert(false); return nullptr; }
|
||||
#if POINCARE_TREE_LOG
|
||||
virtual void logNodeName(std::ostream & stream) const override {
|
||||
stream << "AllocationFailureEvaluation";
|
||||
T<U>::logNodeName(stream);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,29 +0,0 @@
|
||||
#ifndef POINCARE_ALLOCATION_FAILURE_EXPRESSION_NODE_H
|
||||
#define POINCARE_ALLOCATION_FAILURE_EXPRESSION_NODE_H
|
||||
|
||||
#include <poincare/exception_expression_node.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
template <typename T>
|
||||
class AllocationFailureExpressionNode : public ExceptionExpressionNode<T> {
|
||||
public:
|
||||
// ExpressionNode
|
||||
ExpressionNode::Type type() const override { return ExpressionNode::Type::AllocationFailure; }
|
||||
// TreeNode
|
||||
void incrementNumberOfChildren(int increment = 1) override {}
|
||||
void decrementNumberOfChildren(int decrement = 1) override {}
|
||||
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";
|
||||
T::logNodeName(stream);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,32 +0,0 @@
|
||||
#ifndef POINCARE_ALLOCATION_FAILURE_LAYOUT_NODE_H
|
||||
#define POINCARE_ALLOCATION_FAILURE_LAYOUT_NODE_H
|
||||
|
||||
#include <poincare/exception_layout_node.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
template <typename T>
|
||||
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";
|
||||
T::logNodeName(stream);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
template <typename T>
|
||||
class AllocationFailureLayoutRef : public LayoutReference {
|
||||
public:
|
||||
AllocationFailedLayoutRef() : LayoutReference(TreePool::sharedPool()->createTreeNode<AllocationFailureLayoutNode<T>>()) {}
|
||||
};
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -10,9 +10,6 @@ namespace Poincare {
|
||||
|
||||
class ArcCosineNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static ArcCosineNode * FailedAllocationStaticNode();
|
||||
ArcCosineNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(ArcCosineNode); }
|
||||
|
||||
@@ -10,9 +10,6 @@ namespace Poincare {
|
||||
|
||||
class ArcSineNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static ArcSineNode * FailedAllocationStaticNode();
|
||||
ArcSineNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(ArcSineNode); }
|
||||
|
||||
@@ -10,9 +10,6 @@ namespace Poincare {
|
||||
|
||||
class ArcTangentNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static ArcTangentNode * FailedAllocationStaticNode();
|
||||
ArcTangentNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(ArcTangentNode); }
|
||||
|
||||
@@ -9,8 +9,6 @@ namespace Poincare {
|
||||
|
||||
class BinomialCoefficientNode : public ExpressionNode {
|
||||
public:
|
||||
static BinomialCoefficientNode * FailedAllocationStaticNode();
|
||||
BinomialCoefficientNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(BinomialCoefficientNode); }
|
||||
|
||||
@@ -22,8 +22,6 @@ public:
|
||||
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
|
||||
// TreeNode
|
||||
static BinomialCoefficientLayoutNode * FailedAllocationStaticNode();
|
||||
BinomialCoefficientLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
size_t size() const override { return sizeof(BinomialCoefficientLayoutNode); }
|
||||
int numberOfChildren() const override { return 2; }
|
||||
#if POINCARE_TREE_LOG
|
||||
|
||||
@@ -8,9 +8,6 @@ namespace Poincare {
|
||||
|
||||
class CeilingNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static CeilingNode * FailedAllocationStaticNode();
|
||||
CeilingNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(CeilingNode); }
|
||||
|
||||
@@ -16,8 +16,6 @@ public:
|
||||
}
|
||||
|
||||
// TreeNode
|
||||
static CeilingLayoutNode * FailedAllocationStaticNode();
|
||||
CeilingLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
size_t size() const override { return sizeof(CeilingLayoutNode); }
|
||||
#if POINCARE_TREE_LOG
|
||||
virtual void logNodeName(std::ostream & stream) const override {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#ifndef POINCARE_CHAR_LAYOUT_NODE_H
|
||||
#define POINCARE_CHAR_LAYOUT_NODE_H
|
||||
|
||||
#include <poincare/allocation_failure_layout_node.h>
|
||||
#include <poincare/layout_cursor.h>
|
||||
#include <poincare/layout_node.h>
|
||||
#include <poincare/layout_reference.h>
|
||||
@@ -28,10 +27,6 @@ public:
|
||||
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
bool isCollapsable(int * numberOfOpenParenthesis, bool goingLeft) const override;
|
||||
|
||||
// AllocationFailure
|
||||
static CharLayoutNode * FailedAllocationStaticNode();
|
||||
CharLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(CharLayoutNode); }
|
||||
int numberOfChildren() const override { return 0; }
|
||||
@@ -59,11 +54,6 @@ private:
|
||||
KDText::FontSize m_fontSize;
|
||||
};
|
||||
|
||||
class AllocationFailureCharLayoutNode : public AllocationFailureLayoutNode<CharLayoutNode> {
|
||||
public:
|
||||
void setChar(char c) override {}
|
||||
};
|
||||
|
||||
class CharLayoutRef : public LayoutReference {
|
||||
public:
|
||||
CharLayoutRef(char c, KDText::FontSize fontSize = KDText::FontSize::Large) :
|
||||
|
||||
@@ -12,9 +12,6 @@ template<typename T>
|
||||
class ComplexNode : public std::complex<T>, public EvaluationNode<T> {
|
||||
public:
|
||||
ComplexNode() : std::complex<T>(NAN, NAN) {}
|
||||
// AllocationFailure
|
||||
static ComplexNode * FailedAllocationStaticNode();
|
||||
ComplexNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(ComplexNode<T>); }
|
||||
|
||||
@@ -8,9 +8,6 @@ namespace Poincare {
|
||||
|
||||
class ComplexArgumentNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static ComplexArgumentNode * FailedAllocationStaticNode();
|
||||
ComplexArgumentNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(ComplexArgumentNode); }
|
||||
|
||||
@@ -29,8 +29,6 @@ public:
|
||||
}
|
||||
|
||||
// TreeNode
|
||||
static CondensedSumLayoutNode * FailedAllocationStaticNode();
|
||||
CondensedSumLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
size_t size() const override { return sizeof(CondensedSumLayoutNode); }
|
||||
int numberOfChildren() const override { return 3; }
|
||||
#if POINCARE_TREE_LOG
|
||||
|
||||
@@ -7,8 +7,6 @@ namespace Poincare {
|
||||
|
||||
class ConfidenceIntervalNode : public ExpressionNode {
|
||||
public:
|
||||
static ConfidenceIntervalNode * FailedAllocationStaticNode();
|
||||
ConfidenceIntervalNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(ConfidenceIntervalNode); }
|
||||
@@ -39,8 +37,6 @@ private:
|
||||
|
||||
class SimplePredictionIntervalNode : public ConfidenceIntervalNode {
|
||||
public:
|
||||
static SimplePredictionIntervalNode * FailedAllocationStaticNode();
|
||||
SimplePredictionIntervalNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
private:
|
||||
const char * name() const override { return "prediction"; }
|
||||
};
|
||||
|
||||
@@ -8,9 +8,6 @@ namespace Poincare {
|
||||
|
||||
class ConjugateNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static ConjugateNode * FailedAllocationStaticNode();
|
||||
ConjugateNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(ConjugateNode); }
|
||||
|
||||
@@ -18,8 +18,6 @@ public:
|
||||
bool shouldCollapseSiblingsOnRight() const override { return true; }
|
||||
|
||||
// TreeNode
|
||||
static ConjugateLayoutNode * FailedAllocationStaticNode();
|
||||
ConjugateLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
size_t size() const override { return sizeof(ConjugateLayoutNode); }
|
||||
int numberOfChildren() const override { return 1; }
|
||||
#if POINCARE_TREE_LOG
|
||||
|
||||
@@ -10,9 +10,6 @@ namespace Poincare {
|
||||
|
||||
class CosineNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static CosineNode * FailedAllocationStaticNode();
|
||||
CosineNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(CosineNode); }
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <poincare/integer.h>
|
||||
#include <poincare/number.h>
|
||||
#include <poincare/allocation_failure_expression_node.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -26,10 +25,6 @@ public:
|
||||
|
||||
virtual void setValue(const native_uint_t * mantissaDigits, size_t mantissaSize, int exponent, bool negative);
|
||||
|
||||
// Allocation Failure
|
||||
static DecimalNode * FailedAllocationStaticNode();
|
||||
DecimalNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
Integer signedMantissa() const;
|
||||
Integer unsignedMantissa() const;
|
||||
int exponent() const { return m_exponent; }
|
||||
@@ -85,11 +80,6 @@ private:
|
||||
native_uint_t m_mantissa[0];
|
||||
};
|
||||
|
||||
class AllocationFailureDecimalNode : public AllocationFailureExpressionNode<DecimalNode> {
|
||||
public:
|
||||
void setValue(const native_uint_t * mantissaDigits, size_t mantissaSize, int exponent, bool negative) override {}
|
||||
};
|
||||
|
||||
class Decimal : public Number {
|
||||
friend class Number;
|
||||
friend class DecimalNode;
|
||||
|
||||
@@ -10,9 +10,6 @@ namespace Poincare {
|
||||
|
||||
class DerivativeNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static DerivativeNode * FailedAllocationStaticNode();
|
||||
DerivativeNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(DerivativeNode); }
|
||||
|
||||
@@ -8,9 +8,6 @@ namespace Poincare {
|
||||
|
||||
class DeterminantNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static DeterminantNode * FailedAllocationStaticNode();
|
||||
DeterminantNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(DeterminantNode); }
|
||||
|
||||
@@ -13,9 +13,6 @@ class DivisionNode : public ExpressionNode {
|
||||
template<int I>
|
||||
friend class LogarithmNode;
|
||||
public:
|
||||
// Allocation Failure
|
||||
static DivisionNode * FailedAllocationStaticNode();
|
||||
DivisionNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(DivisionNode); }
|
||||
|
||||
@@ -7,8 +7,6 @@ namespace Poincare {
|
||||
|
||||
class DivisionQuotientNode : public ExpressionNode {
|
||||
public:
|
||||
static DivisionQuotientNode * FailedAllocationStaticNode();
|
||||
DivisionQuotientNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(DivisionQuotientNode); }
|
||||
|
||||
@@ -8,8 +8,6 @@ namespace Poincare {
|
||||
|
||||
class DivisionRemainderNode : public ExpressionNode {
|
||||
public:
|
||||
static DivisionRemainderNode * FailedAllocationStaticNode();
|
||||
DivisionRemainderNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(DivisionRemainderNode); }
|
||||
|
||||
@@ -9,9 +9,6 @@ namespace Poincare {
|
||||
|
||||
class EmptyExpressionNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static EmptyExpressionNode * FailedAllocationStaticNode();
|
||||
EmptyExpressionNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(EmptyExpressionNode); }
|
||||
|
||||
@@ -39,8 +39,6 @@ public:
|
||||
bool hasText() const override { return false; }
|
||||
|
||||
// TreeNode
|
||||
static EmptyLayoutNode * FailedAllocationStaticNode();
|
||||
EmptyLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
size_t size() const override { return sizeof(EmptyLayoutNode); }
|
||||
int numberOfChildren() const override { return 0; }
|
||||
#if POINCARE_TREE_LOG
|
||||
|
||||
@@ -7,8 +7,6 @@ namespace Poincare {
|
||||
|
||||
class EqualNode : public ExpressionNode {
|
||||
public:
|
||||
static EqualNode * FailedAllocationStaticNode();
|
||||
EqualNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(EqualNode); }
|
||||
|
||||
@@ -20,7 +20,6 @@ class EvaluationNode : public TreeNode {
|
||||
public:
|
||||
enum class Type : uint8_t {
|
||||
Exception,
|
||||
AllocationFailure,
|
||||
Complex,
|
||||
MatrixComplex
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef POINCARE_EXCEPTION_EXPRESSION_NODE_H
|
||||
#define POINCARE_EXCEPTION_EXPRESSION_NODE_H
|
||||
|
||||
#include <poincare/exception_node.h>
|
||||
#include <poincare/expression_node.h>
|
||||
#include <poincare/expression.h>
|
||||
#include <poincare/complex.h>
|
||||
@@ -28,8 +29,7 @@ public:
|
||||
return PrintFloat::convertFloatToText<float>(NAN, buffer, bufferSize, numberOfSignificantDigits, floatDisplayMode);
|
||||
}
|
||||
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override { return LayoutRef(CharLayoutNode::FailedAllocationStaticNode()); } //TODO ?
|
||||
// OLD FIXME: Use EmptyLayoutNode here above, once EmptyLayout has been cleaned up
|
||||
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(); }
|
||||
};
|
||||
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
/* Properties */
|
||||
ExpressionNode::Type type() const { return node()->type(); }
|
||||
ExpressionNode::Sign sign() const { return node()->sign(); }
|
||||
bool isUndefinedOrAllocationFailure() const { return node()->type() == ExpressionNode::Type::Undefined || node()->type() == ExpressionNode::Type::AllocationFailure; }
|
||||
bool isUndefined() const { return node()->type() == ExpressionNode::Type::Undefined; }
|
||||
bool isNumber() const { return node()->isNumber(); }
|
||||
bool isRationalZero() const;
|
||||
bool isRationalOne() const;
|
||||
|
||||
@@ -21,10 +21,9 @@ class ExpressionNode : public TreeNode, public SerializationHelperInterface {
|
||||
friend class SymbolNode;
|
||||
public:
|
||||
enum class Type : uint8_t {
|
||||
AllocationFailure = 0,
|
||||
Uninitialized = 1,
|
||||
Undefined = 2,
|
||||
Integer = 3,
|
||||
Uninitialized = 0,
|
||||
Undefined = 1,
|
||||
Integer = 2,
|
||||
Rational,
|
||||
Decimal,
|
||||
Float,
|
||||
|
||||
@@ -12,9 +12,6 @@ namespace Poincare {
|
||||
|
||||
class FactorNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static FactorNode * FailedAllocationStaticNode();
|
||||
FactorNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(FactorNode); }
|
||||
int numberOfChildren() const override { return 1; }
|
||||
|
||||
@@ -9,9 +9,6 @@ namespace Poincare {
|
||||
|
||||
class FactorialNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static FactorialNode * FailedAllocationStaticNode();
|
||||
FactorialNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(FactorialNode); }
|
||||
|
||||
@@ -22,8 +22,6 @@ class FloatNode : public NumberNode {
|
||||
public:
|
||||
FloatNode() : m_value(0.0) {}
|
||||
|
||||
static FloatNode * FailedAllocationStaticNode();
|
||||
FloatNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
void setFloat(T a) { m_value = a; }
|
||||
T value() const { return m_value; }
|
||||
|
||||
@@ -8,9 +8,6 @@ namespace Poincare {
|
||||
|
||||
class FloorNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static FloorNode * FailedAllocationStaticNode();
|
||||
FloorNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(FloorNode); }
|
||||
|
||||
@@ -15,8 +15,6 @@ public:
|
||||
}
|
||||
|
||||
// TreeNode
|
||||
static FloorLayoutNode * FailedAllocationStaticNode();
|
||||
FloorLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
size_t size() const override { return sizeof(FloorLayoutNode); }
|
||||
#if POINCARE_TREE_LOG
|
||||
virtual void logNodeName(std::ostream & stream) const override {
|
||||
|
||||
@@ -8,9 +8,6 @@ namespace Poincare {
|
||||
|
||||
class FracPartNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static FracPartNode * FailedAllocationStaticNode();
|
||||
FracPartNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(FracPartNode); }
|
||||
|
||||
@@ -11,10 +11,6 @@ class FractionLayoutNode : public LayoutNode {
|
||||
public:
|
||||
using LayoutNode::LayoutNode;
|
||||
|
||||
// AllocationFailure
|
||||
static FractionLayoutNode * FailedAllocationStaticNode();
|
||||
FractionLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// LayoutNode
|
||||
void moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
void moveCursorRight(LayoutCursor * cursor, bool * shouldRecomputeLayout) override;
|
||||
|
||||
@@ -18,25 +18,10 @@ public:
|
||||
|
||||
// Ghost
|
||||
bool isGhost() const override { return true; }
|
||||
// Allocation Failure
|
||||
static GhostNode * FailedAllocationStaticNode();
|
||||
TreeNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
// Uninitialized
|
||||
TreeNode * uninitializedStaticNode() const override;
|
||||
};
|
||||
|
||||
class AllocationFailedGhostNode : public GhostNode {
|
||||
public:
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(AllocationFailedGhostNode); }
|
||||
#if POINCARE_TREE_LOG
|
||||
virtual void logNodeName(std::ostream & stream) const override {
|
||||
stream << "AllocationFailedGhost";
|
||||
}
|
||||
#endif
|
||||
bool isAllocationFailure() const override { return true; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,8 +7,6 @@ namespace Poincare {
|
||||
|
||||
class GreatCommonDivisorNode : public ExpressionNode {
|
||||
public:
|
||||
static GreatCommonDivisorNode * FailedAllocationStaticNode();
|
||||
GreatCommonDivisorNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(GreatCommonDivisorNode); }
|
||||
|
||||
@@ -40,8 +40,6 @@ public:
|
||||
}
|
||||
|
||||
// TreeNode
|
||||
static GridLayoutNode * FailedAllocationStaticNode();
|
||||
GridLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
size_t size() const override { return sizeof(GridLayoutNode); }
|
||||
void didAddChildAtIndex(int newNumberOfChildren) override;
|
||||
int numberOfChildren() const override { return m_numberOfRows * m_numberOfColumns; }
|
||||
|
||||
@@ -14,10 +14,6 @@ class HorizontalLayoutNode : public LayoutNode {
|
||||
friend class LayoutReference;
|
||||
public:
|
||||
|
||||
// AllocationFailure
|
||||
static HorizontalLayoutNode * FailedAllocationStaticNode();
|
||||
HorizontalLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
HorizontalLayoutNode() :
|
||||
LayoutNode(),
|
||||
m_numberOfChildren(0)
|
||||
|
||||
@@ -8,9 +8,6 @@ namespace Poincare {
|
||||
|
||||
class HyperbolicArcCosineNode : public HyperbolicTrigonometricFunctionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static HyperbolicArcCosineNode * FailedAllocationStaticNode();
|
||||
HyperbolicArcCosineNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(HyperbolicArcCosineNode); }
|
||||
|
||||
@@ -8,9 +8,6 @@ namespace Poincare {
|
||||
|
||||
class HyperbolicArcSineNode : public HyperbolicTrigonometricFunctionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static HyperbolicArcSineNode * FailedAllocationStaticNode();
|
||||
HyperbolicArcSineNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(HyperbolicArcSineNode); }
|
||||
|
||||
@@ -8,9 +8,6 @@ namespace Poincare {
|
||||
|
||||
class HyperbolicArcTangentNode : public HyperbolicTrigonometricFunctionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static HyperbolicArcTangentNode * FailedAllocationStaticNode();
|
||||
HyperbolicArcTangentNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(HyperbolicArcTangentNode); }
|
||||
|
||||
@@ -8,9 +8,6 @@ namespace Poincare {
|
||||
|
||||
class HyperbolicCosineNode : public HyperbolicTrigonometricFunctionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static HyperbolicCosineNode * FailedAllocationStaticNode();
|
||||
HyperbolicCosineNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(HyperbolicCosineNode); }
|
||||
|
||||
@@ -8,9 +8,6 @@ namespace Poincare {
|
||||
|
||||
class HyperbolicSineNode : public HyperbolicTrigonometricFunctionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static HyperbolicSineNode * FailedAllocationStaticNode();
|
||||
HyperbolicSineNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(HyperbolicSineNode); }
|
||||
|
||||
@@ -8,9 +8,6 @@ namespace Poincare {
|
||||
|
||||
class HyperbolicTangentNode : public HyperbolicTrigonometricFunctionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static HyperbolicTangentNode * FailedAllocationStaticNode();
|
||||
HyperbolicTangentNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(HyperbolicTangentNode); }
|
||||
|
||||
@@ -8,9 +8,6 @@ namespace Poincare {
|
||||
|
||||
class ImaginaryPartNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static ImaginaryPartNode * FailedAllocationStaticNode();
|
||||
ImaginaryPartNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(ImaginaryPartNode); }
|
||||
|
||||
@@ -5,12 +5,8 @@
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
class AllocationFailureInfinityNode;
|
||||
|
||||
class InfinityNode : public NumberNode {
|
||||
public:
|
||||
static InfinityNode * FailedAllocationStaticNode();
|
||||
InfinityNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
void setNegative(bool negative) { m_negative = negative; }
|
||||
Expression setSign(Sign s, Context & context, Preferences::AngleUnit angleUnit) override;
|
||||
|
||||
@@ -7,8 +7,6 @@ namespace Poincare {
|
||||
|
||||
class IntegralNode : public ExpressionNode {
|
||||
public:
|
||||
static IntegralNode * FailedAllocationStaticNode();
|
||||
IntegralNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(IntegralNode); }
|
||||
|
||||
@@ -29,8 +29,6 @@ public:
|
||||
char XNTChar() const override { return 'x'; }
|
||||
|
||||
// TreeNode
|
||||
static IntegralLayoutNode * FailedAllocationStaticNode();
|
||||
IntegralLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
size_t size() const override { return sizeof(IntegralLayoutNode); }
|
||||
int numberOfChildren() const override { return 3; }
|
||||
#if POINCARE_TREE_LOG
|
||||
|
||||
@@ -11,18 +11,6 @@ namespace Poincare {
|
||||
class LayoutCursor;
|
||||
class LayoutReference;
|
||||
|
||||
/* Some methods, such as FractionLayoutNode::didCollapseSiblings, move the
|
||||
* cursor without making sure that the layout is in the main layout, so they
|
||||
* might make the cursor "jump" to an independent layout.
|
||||
*
|
||||
* Example : the main layout is AllocationFailure, we add a FractionLayout,
|
||||
* which cannot be inserted in the main layout. Then FractionLayout collapses
|
||||
* its siblings and moves the cursor to its denominator: the cursor is no longer
|
||||
* on the main layout.
|
||||
*
|
||||
* We tackle this by not handling any event when the cursor points to an
|
||||
* AllocationFailure layout. */
|
||||
|
||||
class LayoutNode : public TreeNode, public SerializationHelperInterface {
|
||||
friend class LayoutReference;
|
||||
public:
|
||||
@@ -85,8 +73,8 @@ public:
|
||||
}
|
||||
bool removeGreySquaresFromAllMatrixAncestors() { return changeGreySquaresOfAllMatrixAncestors(false); }
|
||||
bool addGreySquaresToAllMatrixAncestors() { return changeGreySquaresOfAllMatrixAncestors(true); }
|
||||
/* A layout has text if it is not empty or an allocation failure and it is
|
||||
* not an horizontal layout with no child or with one child with no text. */
|
||||
/* A layout has text if it is not empty and it is not an horizontal layout
|
||||
* with no child or with one child with no text. */
|
||||
virtual bool hasText() const { return true; }
|
||||
virtual bool isCollapsable(int * numberOfOpenParenthesis, bool goingLeft) const { return true; }
|
||||
/* isCollapsable is used when adding a sibling fraction: should the layout be
|
||||
|
||||
@@ -8,8 +8,6 @@ namespace Poincare {
|
||||
|
||||
class LeastCommonMultipleNode : public ExpressionNode {
|
||||
public:
|
||||
static LeastCommonMultipleNode * FailedAllocationStaticNode();
|
||||
LeastCommonMultipleNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(LeastCommonMultipleNode); }
|
||||
|
||||
@@ -23,8 +23,6 @@ public:
|
||||
}
|
||||
|
||||
// TreeNode
|
||||
static LeftParenthesisLayoutNode * FailedAllocationStaticNode();
|
||||
LeftParenthesisLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
#if POINCARE_TREE_LOG
|
||||
virtual void logNodeName(std::ostream & stream) const override {
|
||||
stream << "LeftParenthesisLayout";
|
||||
|
||||
@@ -16,8 +16,6 @@ public:
|
||||
bool isLeftBracket() const override { return true; }
|
||||
|
||||
// TreeNode
|
||||
static LeftSquareBracketLayoutNode * FailedAllocationStaticNode();
|
||||
LeftSquareBracketLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
size_t size() const override { return sizeof(LeftSquareBracketLayoutNode); }
|
||||
#if POINCARE_TREE_LOG
|
||||
virtual void logNodeName(std::ostream & stream) const override {
|
||||
|
||||
@@ -12,10 +12,6 @@ namespace Poincare {
|
||||
template<int I>
|
||||
class LogarithmNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static LogarithmNode<I> * FailedAllocationStaticNode();
|
||||
LogarithmNode<I> * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(LogarithmNode); }
|
||||
int numberOfChildren() const override { assert(I == 1 || I == 2); return I; }
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <poincare/expression.h>
|
||||
#include <poincare/multiplication.h>
|
||||
#include <poincare/allocation_failure_expression_node.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -15,8 +14,6 @@ public:
|
||||
m_numberOfRows(0),
|
||||
m_numberOfColumns(0) {}
|
||||
|
||||
static MatrixNode * FailedAllocationStaticNode();
|
||||
MatrixNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
int numberOfRows() const { return m_numberOfRows; }
|
||||
int numberOfColumns() const { return m_numberOfColumns; }
|
||||
@@ -58,11 +55,6 @@ private:
|
||||
int m_numberOfColumns;
|
||||
};
|
||||
|
||||
class AllocationFailureMatrixNode : public AllocationFailureExpressionNode<MatrixNode> {
|
||||
void setNumberOfRows(int rows) override {}
|
||||
void setNumberOfColumns(int columns) override {}
|
||||
};
|
||||
|
||||
class Matrix : public Expression {
|
||||
template<typename T> friend class MatrixComplexNode;
|
||||
friend class GlobalContext;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define POINCARE_MATRIX_COMPLEX_H
|
||||
|
||||
#include <poincare/evaluation.h>
|
||||
#include <poincare/allocation_failure_evaluation_node.h>
|
||||
#include <poincare/complex.h>
|
||||
|
||||
namespace Poincare {
|
||||
@@ -13,9 +12,6 @@ class MatrixComplex;
|
||||
template<typename T>
|
||||
class MatrixComplexNode : public EvaluationNode<T> {
|
||||
public:
|
||||
static MatrixComplexNode<T> * FailedAllocationStaticNode();
|
||||
MatrixComplexNode<T> * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
MatrixComplexNode() :
|
||||
EvaluationNode<T>(),
|
||||
m_numberOfRows(0),
|
||||
@@ -55,12 +51,6 @@ private:
|
||||
int m_numberOfColumns;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class AllocationFailureMatrixComplexNode : public AllocationFailureEvaluationNode<MatrixComplexNode, T> {
|
||||
void setNumberOfRows(int rows) override {}
|
||||
void setNumberOfColumns(int columns) override {}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class MatrixComplex : public Evaluation<T> {
|
||||
friend class MatrixComplexNode<T>;
|
||||
|
||||
@@ -7,9 +7,6 @@ namespace Poincare {
|
||||
|
||||
class MatrixDimensionNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static MatrixDimensionNode * FailedAllocationStaticNode();
|
||||
MatrixDimensionNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(MatrixDimensionNode); }
|
||||
|
||||
@@ -7,9 +7,6 @@ namespace Poincare {
|
||||
|
||||
class MatrixInverseNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static MatrixInverseNode * FailedAllocationStaticNode();
|
||||
MatrixInverseNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(MatrixInverseNode); }
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#ifndef POINCARE_MATRIX_LAYOUT_NODE_H
|
||||
#define POINCARE_MATRIX_LAYOUT_NODE_H
|
||||
|
||||
#include <poincare/allocation_failure_layout_node.h>
|
||||
#include <poincare/grid_layout_node.h>
|
||||
#include <poincare/layout_cursor.h>
|
||||
#include <poincare/layout_reference.h>
|
||||
@@ -30,8 +29,6 @@ public:
|
||||
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
|
||||
// TreeNode
|
||||
static MatrixLayoutNode * FailedAllocationStaticNode();
|
||||
MatrixLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
size_t size() const override { return sizeof(MatrixLayoutNode); }
|
||||
#if POINCARE_TREE_LOG
|
||||
virtual void logNodeName(std::ostream & stream) const override {
|
||||
@@ -57,16 +54,6 @@ private:
|
||||
void didReplaceChildAtIndex(int index, LayoutCursor * cursor, bool force) override;
|
||||
};
|
||||
|
||||
class AllocationFailureMatrixLayoutNode : public AllocationFailureLayoutNode<MatrixLayoutNode> {
|
||||
void setNumberOfRows(int numberOfRows) override {}
|
||||
void setNumberOfColumns(int numberOfColumns) override {}
|
||||
protected:
|
||||
void addEmptyRow(EmptyLayoutNode::Color color) override {}
|
||||
void addEmptyColumn(EmptyLayoutNode::Color color) override {}
|
||||
void deleteRowAtIndex(int index) override {}
|
||||
void deleteColumnAtIndex(int index) override {}
|
||||
};
|
||||
|
||||
class MatrixLayoutRef : public GridLayoutRef {
|
||||
friend class MatrixLayoutNode;
|
||||
public:
|
||||
|
||||
@@ -7,9 +7,6 @@ namespace Poincare {
|
||||
|
||||
class MatrixTraceNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static MatrixTraceNode * FailedAllocationStaticNode();
|
||||
MatrixTraceNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(MatrixTraceNode); }
|
||||
|
||||
@@ -7,9 +7,6 @@ namespace Poincare {
|
||||
|
||||
class MatrixTransposeNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static MatrixTransposeNode * FailedAllocationStaticNode();
|
||||
MatrixTransposeNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(MatrixTransposeNode); }
|
||||
|
||||
@@ -12,8 +12,6 @@ public:
|
||||
using NAryExpressionNode::NAryExpressionNode;
|
||||
|
||||
// Tree
|
||||
static MultiplicationNode * FailedAllocationStaticNode();
|
||||
MultiplicationNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
size_t size() const override { return sizeof(MultiplicationNode); }
|
||||
#if POINCARE_TREE_LOG
|
||||
virtual void logNodeName(std::ostream & stream) const override {
|
||||
|
||||
@@ -10,10 +10,6 @@ namespace Poincare {
|
||||
|
||||
class NaperianLogarithmNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static NaperianLogarithmNode * FailedAllocationStaticNode();
|
||||
NaperianLogarithmNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(NaperianLogarithmNode); }
|
||||
int numberOfChildren() const override { return 1; }
|
||||
|
||||
@@ -13,8 +13,6 @@ public:
|
||||
Type type() const override { return Type::NthRoot; }
|
||||
|
||||
// TreeNode
|
||||
static NthRootNode * FailedAllocationStaticNode();
|
||||
NthRootNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
size_t size() const override { return sizeof(NthRootNode); }
|
||||
int numberOfChildren() const override { return 2; }
|
||||
#if POINCARE_TREE_LOG
|
||||
|
||||
@@ -31,8 +31,6 @@ public:
|
||||
bool hasUpperLeftIndex() const override { return m_hasIndex; }
|
||||
|
||||
// TreeNode
|
||||
static NthRootLayoutNode * FailedAllocationStaticNode();
|
||||
NthRootLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
size_t size() const override { return sizeof(NthRootLayoutNode); }
|
||||
int numberOfChildren() const override { return m_hasIndex ? 2 : 1; }
|
||||
#if POINCARE_TREE_LOG
|
||||
|
||||
@@ -12,9 +12,6 @@ class OppositeNode : public ExpressionNode {
|
||||
public:
|
||||
template<typename T> static Complex<T> compute(const std::complex<T> c, Preferences::AngleUnit angleUnit = Preferences::AngleUnit::Degree) { return Complex<T>(-c); }
|
||||
|
||||
// Allocation Failure
|
||||
static OppositeNode * FailedAllocationStaticNode();
|
||||
OppositeNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(OppositeNode); }
|
||||
|
||||
@@ -8,8 +8,6 @@ namespace Poincare {
|
||||
|
||||
class ParenthesisNode : public ExpressionNode {
|
||||
public:
|
||||
static ParenthesisNode * FailedAllocationStaticNode();
|
||||
ParenthesisNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(ParenthesisNode); }
|
||||
|
||||
@@ -10,8 +10,6 @@ namespace Poincare {
|
||||
|
||||
class PermuteCoefficientNode : public ExpressionNode {
|
||||
public:
|
||||
static PermuteCoefficientNode * FailedAllocationStaticNode();
|
||||
PermuteCoefficientNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(PermuteCoefficientNode); }
|
||||
|
||||
@@ -12,9 +12,6 @@ class Power;
|
||||
|
||||
class PowerNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static PowerNode * FailedAllocationStaticNode();
|
||||
PowerNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(PowerNode); }
|
||||
|
||||
@@ -9,8 +9,6 @@ namespace Poincare {
|
||||
|
||||
class PredictionIntervalNode : public ExpressionNode {
|
||||
public:
|
||||
static PredictionIntervalNode * FailedAllocationStaticNode();
|
||||
PredictionIntervalNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(PredictionIntervalNode); }
|
||||
|
||||
@@ -7,9 +7,6 @@ namespace Poincare {
|
||||
|
||||
class ProductNode : public SequenceNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static ProductNode * FailedAllocationStaticNode();
|
||||
ProductNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(ProductNode); }
|
||||
#if POINCARE_TREE_LOG
|
||||
|
||||
@@ -10,8 +10,6 @@ class ProductLayoutNode : public SequenceLayoutNode {
|
||||
public:
|
||||
using SequenceLayoutNode::SequenceLayoutNode;
|
||||
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
static ProductLayoutNode * FailedAllocationStaticNode();
|
||||
ProductLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
size_t size() const override { return sizeof(ProductLayoutNode); }
|
||||
#if POINCARE_TREE_LOG
|
||||
virtual void logNodeName(std::ostream & stream) const override {
|
||||
|
||||
@@ -9,9 +9,6 @@ namespace Poincare {
|
||||
|
||||
class RandintNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static RandintNode * FailedAllocationStaticNode();
|
||||
RandintNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(RandintNode); }
|
||||
|
||||
@@ -10,9 +10,6 @@ namespace Poincare {
|
||||
|
||||
class RandomNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static RandomNode * FailedAllocationStaticNode();
|
||||
RandomNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(RandomNode); }
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <poincare/integer.h>
|
||||
#include <poincare/number.h>
|
||||
#include <poincare/complex.h>
|
||||
#include <poincare/allocation_failure_expression_node.h>
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
@@ -16,10 +15,6 @@ public:
|
||||
m_numberOfDigitsDenominator(0) {}
|
||||
virtual void setDigits(const native_uint_t * i, size_t numeratorSize, const native_uint_t * j, size_t denominatorSize, bool negative);
|
||||
|
||||
// Allocation Failure
|
||||
static RationalNode * FailedAllocationStaticNode();
|
||||
RationalNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
Integer signedNumerator() const;
|
||||
Integer unsignedNumerator() const;
|
||||
Integer denominator() const;
|
||||
@@ -72,11 +67,6 @@ private:
|
||||
native_uint_t m_digits[0];
|
||||
};
|
||||
|
||||
class AllocationFailureRationalNode : public AllocationFailureExpressionNode<RationalNode> {
|
||||
public:
|
||||
void setDigits(const native_uint_t * i, size_t numeratorSize, const native_uint_t * j, size_t denominatorSize, bool negative) override {};
|
||||
};
|
||||
|
||||
class Rational : public Number {
|
||||
friend class RationalNode;
|
||||
friend class PowerNode;
|
||||
|
||||
@@ -10,9 +10,6 @@ namespace Poincare {
|
||||
|
||||
class RealPartNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static RealPartNode * FailedAllocationStaticNode();
|
||||
RealPartNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(RealPartNode); }
|
||||
|
||||
@@ -23,8 +23,6 @@ public:
|
||||
}
|
||||
|
||||
// TreeNode
|
||||
static RightParenthesisLayoutNode * FailedAllocationStaticNode();
|
||||
RightParenthesisLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
size_t size() const override { return sizeof(RightParenthesisLayoutNode); }
|
||||
#if POINCARE_TREE_LOG
|
||||
virtual void logNodeName(std::ostream & stream) const override {
|
||||
|
||||
@@ -16,8 +16,6 @@ public:
|
||||
bool isRightBracket() const override { return true; }
|
||||
|
||||
// TreeNode
|
||||
static RightSquareBracketLayoutNode * FailedAllocationStaticNode();
|
||||
RightSquareBracketLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
size_t size() const override { return sizeof(RightSquareBracketLayoutNode); }
|
||||
#if POINCARE_TREE_LOG
|
||||
virtual void logNodeName(std::ostream & stream) const override {
|
||||
|
||||
@@ -10,9 +10,6 @@ namespace Poincare {
|
||||
|
||||
class RoundNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static RoundNode * FailedAllocationStaticNode();
|
||||
RoundNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(RoundNode); }
|
||||
|
||||
@@ -10,9 +10,6 @@ namespace Poincare {
|
||||
|
||||
class SineNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static SineNode * FailedAllocationStaticNode();
|
||||
SineNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(SineNode); }
|
||||
|
||||
@@ -13,8 +13,6 @@ public:
|
||||
Type type() const override { return Type::SquareRoot; }
|
||||
|
||||
// TreeNode
|
||||
static SquareRootNode * FailedAllocationStaticNode();
|
||||
SquareRootNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
size_t size() const override { return sizeof(SquareRootNode); }
|
||||
int numberOfChildren() const override { return 1; }
|
||||
#if POINCARE_TREE_LOG
|
||||
|
||||
@@ -10,8 +10,6 @@ namespace Poincare {
|
||||
|
||||
class StoreNode : public ExpressionNode {
|
||||
public:
|
||||
static StoreNode * FailedAllocationStaticNode();
|
||||
StoreNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(StoreNode); }
|
||||
|
||||
@@ -9,8 +9,6 @@ namespace Poincare {
|
||||
|
||||
class SubtractionNode : public ExpressionNode {
|
||||
public:
|
||||
static SubtractionNode * FailedAllocationStaticNode();
|
||||
SubtractionNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(SubtractionNode); }
|
||||
|
||||
@@ -7,9 +7,6 @@ namespace Poincare {
|
||||
|
||||
class SumNode : public SequenceNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static SumNode * FailedAllocationStaticNode();
|
||||
SumNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(SumNode); }
|
||||
#if POINCARE_TREE_LOG
|
||||
|
||||
@@ -10,8 +10,6 @@ class SumLayoutNode : public SequenceLayoutNode {
|
||||
public:
|
||||
using SequenceLayoutNode::SequenceLayoutNode;
|
||||
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
static SumLayoutNode * FailedAllocationStaticNode();
|
||||
SumLayoutNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
size_t size() const override { return sizeof(SumLayoutNode); }
|
||||
#if POINCARE_TREE_LOG
|
||||
virtual void logNodeName(std::ostream & stream) const override {
|
||||
|
||||
@@ -10,8 +10,6 @@ class SymbolNode : public ExpressionNode {
|
||||
public:
|
||||
SymbolNode() : m_name(0) {}
|
||||
|
||||
static SymbolNode * FailedAllocationStaticNode();
|
||||
SymbolNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
void setName(const char name) { m_name = name; }
|
||||
char name() const { return m_name; }
|
||||
|
||||
@@ -9,9 +9,6 @@ namespace Poincare {
|
||||
|
||||
class TangentNode : public ExpressionNode {
|
||||
public:
|
||||
// Allocation Failure
|
||||
static TangentNode * FailedAllocationStaticNode();
|
||||
TangentNode * failedAllocationStaticNode() override { return FailedAllocationStaticNode(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override { return sizeof(TangentNode); }
|
||||
|
||||
@@ -46,7 +46,6 @@ public:
|
||||
|
||||
bool isGhost() const { return node()->isGhost(); }
|
||||
bool isUninitialized() const { return node()->isUninitialized(); }
|
||||
bool isAllocationFailure() const { return node()->isAllocationFailure(); }
|
||||
bool isStatic() const { return node()->isStatic(); }
|
||||
|
||||
|
||||
@@ -70,7 +69,6 @@ public:
|
||||
void replaceWithInPlace(TreeByReference t);
|
||||
void replaceChildInPlace(TreeByReference oldChild, TreeByReference newChild);
|
||||
void replaceChildAtIndexInPlace(int oldChildIndex, TreeByReference newChild);
|
||||
void replaceWithAllocationFailureInPlace(int currentNumberOfChildren);
|
||||
void replaceChildAtIndexWithGhostInPlace(int index) {
|
||||
assert(index >= 0 && index < numberOfChildren());
|
||||
replaceChildWithGhostInPlace(childAtIndex(index));
|
||||
|
||||
@@ -39,11 +39,6 @@ public:
|
||||
// Ghost
|
||||
virtual bool isGhost() const { return false; }
|
||||
|
||||
// Allocation failure
|
||||
virtual bool isAllocationFailure() const { return false; }
|
||||
virtual TreeNode * failedAllocationStaticNode() = 0;
|
||||
int allocationFailureNodeIdentifier() { return failedAllocationStaticNode()->identifier(); }
|
||||
|
||||
// Node operations
|
||||
void setReferenceCounter(int refCount) { m_referenceCounter = refCount; }
|
||||
void retain() { m_referenceCounter++; } // It doesn't matter if the node is static
|
||||
|
||||
@@ -48,36 +48,13 @@ public:
|
||||
template <typename T>
|
||||
T * createTreeNode(size_t size = sizeof(T)) {
|
||||
int nodeIdentifier = generateIdentifier();
|
||||
if (nodeIdentifier == -1) {
|
||||
T::FailedAllocationStaticNode()->retain();
|
||||
return T::FailedAllocationStaticNode();
|
||||
}
|
||||
void * ptr = alloc(size);
|
||||
if (ptr == nullptr) {
|
||||
T::FailedAllocationStaticNode()->retain();
|
||||
return T::FailedAllocationStaticNode();
|
||||
}
|
||||
T * node = new(ptr) T();
|
||||
|
||||
// Ensure the pool is syntactially correct by creating ghost children if needed.
|
||||
// It's needed for children that have a fixed, non-zero number of children.
|
||||
for (int i = 0; i < node->numberOfChildren(); i++) {
|
||||
TreeNode * ghost = createTreeNode<GhostNode>();
|
||||
if (ghost->isAllocationFailure()) {
|
||||
/* There is no room to create the node and all of its children, so
|
||||
* delete the node, the children already built and return an allocation
|
||||
* failure node. */
|
||||
// Discard the node and its first children
|
||||
discardTreeNode(node);
|
||||
for (int j = 0; j < i; j++) {
|
||||
/* The pool has been compacted, so the next child to discard is at the
|
||||
* address "node" */
|
||||
discardTreeNode(node);
|
||||
}
|
||||
// Return an allocation failure node
|
||||
T::FailedAllocationStaticNode()->retain();
|
||||
return T::FailedAllocationStaticNode();
|
||||
}
|
||||
ghost->retain();
|
||||
move(node->next(), ghost, 0);
|
||||
}
|
||||
@@ -93,10 +70,6 @@ public:
|
||||
TreeNode * deepCopy(TreeNode * node) {
|
||||
size_t size = node->deepSize(-1);
|
||||
void * ptr = alloc(size);
|
||||
if (ptr == nullptr) {
|
||||
node->failedAllocationStaticNode()->retain();
|
||||
return node->failedAllocationStaticNode();
|
||||
}
|
||||
memcpy(ptr, static_cast<void *>(node), size);
|
||||
TreeNode * copy = reinterpret_cast<TreeNode *>(ptr);
|
||||
renameNode(copy, false);
|
||||
@@ -238,6 +211,7 @@ private:
|
||||
}
|
||||
int pop() {
|
||||
if (m_currentIndex == 0) {
|
||||
assert(false);
|
||||
return -1;
|
||||
}
|
||||
assert(m_currentIndex > 0 && m_currentIndex <= MaxNumberOfNodes);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user