From 4e2bb8b828efa0421f0e2a51079759ebda5ec741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Fri, 10 Aug 2018 11:04:01 +0200 Subject: [PATCH] [poincare] Remove old files --- .../poincare/bounded_static_hierarchy.h | 24 --- .../bounded_static_layout_hierarchy.h | 22 --- poincare/include/poincare/dynamic_hierarchy.h | 44 ----- poincare/include/poincare/static_hierarchy.h | 34 ---- poincare/src/bounded_static_hierarchy.cpp | 48 ----- poincare/src/dynamic_hierarchy.cpp | 180 ------------------ poincare/src/static_hierarchy.cpp | 92 --------- 7 files changed, 444 deletions(-) delete mode 100644 poincare/include/poincare/bounded_static_hierarchy.h delete mode 100644 poincare/include/poincare/bounded_static_layout_hierarchy.h delete mode 100644 poincare/include/poincare/dynamic_hierarchy.h delete mode 100644 poincare/include/poincare/static_hierarchy.h delete mode 100644 poincare/src/bounded_static_hierarchy.cpp delete mode 100644 poincare/src/dynamic_hierarchy.cpp delete mode 100644 poincare/src/static_hierarchy.cpp diff --git a/poincare/include/poincare/bounded_static_hierarchy.h b/poincare/include/poincare/bounded_static_hierarchy.h deleted file mode 100644 index 3c1966151..000000000 --- a/poincare/include/poincare/bounded_static_hierarchy.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef POINCARE_BOUNDED_STATIC_HIERARCHY_H -#define POINCARE_BOUNDED_STATIC_HIERARCHY_H - -#include - -namespace Poincare { - -template -class BoundedStaticHierarchy : public StaticHierarchy { -public: - BoundedStaticHierarchy(); - BoundedStaticHierarchy(const Expression * expression, bool cloneOperands = true); // Specialized constructor for StaticHierarchy<2> - BoundedStaticHierarchy(const Expression * expression1, const Expression * expression2, bool cloneOperands = true); // Specialized constructor for StaticHierarchy<2> - BoundedStaticHierarchy(const Expression * const * operands, int numberOfChildren, bool cloneOperands = true); - void setArgument(ListData * listData, int numberOfEntries, bool clone) override; - int numberOfChildren() const override { return m_numberOfChildren; } - bool hasValidNumberOfOperands(int numberOfChildren) const override; -private: - int m_numberOfChildren; -}; - -} - -#endif diff --git a/poincare/include/poincare/bounded_static_layout_hierarchy.h b/poincare/include/poincare/bounded_static_layout_hierarchy.h deleted file mode 100644 index 5e3021dee..000000000 --- a/poincare/include/poincare/bounded_static_layout_hierarchy.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef POINCARE_BOUNDED_STATIC_LAYOUT_HIERARCHY_H -#define POINCARE_BOUNDED_STATIC_LAYOUT_HIERARCHY_H - -#include - -namespace Poincare { - -template -class BoundedStaticLayoutHierarchy : public StaticLayoutHierarchy { -public: - BoundedStaticLayoutHierarchy(); - BoundedStaticLayoutHierarchy(const ExpressionLayout * expressionLayout, bool cloneOperands); // Specialized constructor for StaticLayoutHierarchy<2> - BoundedStaticLayoutHierarchy(const ExpressionLayout * expressionLayout1, const ExpressionLayout * expressionLayout2, bool cloneOperands); // Specialized constructor for StaticLayoutHierarchy<2> - BoundedStaticLayoutHierarchy(const ExpressionLayout * const * operands, int numberOfChildren, bool cloneOperands); - int numberOfChildren() const override { return m_numberOfChildren; } -private: - int m_numberOfChildren; -}; - -} - -#endif diff --git a/poincare/include/poincare/dynamic_hierarchy.h b/poincare/include/poincare/dynamic_hierarchy.h deleted file mode 100644 index c53c893d9..000000000 --- a/poincare/include/poincare/dynamic_hierarchy.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef POINCARE_DYNAMIC_HIERARCHY_H -#define POINCARE_DYNAMIC_HIERARCHY_H - -#include -#include -#include - -namespace Poincare { - -class DynamicHierarchy : public Expression { -public: - DynamicHierarchy(); - DynamicHierarchy(const Expression * const * operands, int numberOfChildren, bool cloneOperands); - DynamicHierarchy(const Expression * operand1, const Expression * operand2, bool cloneOperands) : - DynamicHierarchy(ExpressionArray(operand1, operand2).array(), 2, cloneOperands) {} - ~DynamicHierarchy(); - DynamicHierarchy(const DynamicHierarchy & other) = delete; - DynamicHierarchy(DynamicHierarchy && other) = delete; - DynamicHierarchy& operator=(const DynamicHierarchy & other) = delete; - DynamicHierarchy& operator=(DynamicHierarchy && other) = delete; - - int numberOfChildren() const override { return m_numberOfChildren; } - const Expression * const * operands() const override { return m_operands; }; - - void removeOperand(const Expression * e, bool deleteAfterRemoval = true); - void addOperands(const Expression * const * operands, int numberOfChildren); - void addOperand(Expression * operand); - void addOperandAtIndex(Expression * operand, int index); - void mergeOperands(DynamicHierarchy * d); - typedef int (*ExpressionOrder)(const Expression * e1, const Expression * e2, bool canBeInterrupted); - void sortOperands(ExpressionOrder order, bool canBeInterrupted); - Expression * squashUnaryHierarchy(); -protected: - const Expression ** m_operands; - int m_numberOfChildren; -private: - void removeOperandAtIndex(int i, bool deleteAfterRemoval); - int simplificationOrderSameType(const ExpressionNode * e, bool canBeInterrupted) const override; - int simplificationOrderGreaterType(const Expression * e, bool canBeInterrupted) const override; -}; - -} - -#endif diff --git a/poincare/include/poincare/static_hierarchy.h b/poincare/include/poincare/static_hierarchy.h deleted file mode 100644 index 8edf03b37..000000000 --- a/poincare/include/poincare/static_hierarchy.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef POINCARE_STATIC_HIERARCHY_H -#define POINCARE_STATIC_HIERARCHY_H - -#include -#include - -namespace Poincare { - -template -class StaticHierarchy : public Expression { -public: - StaticHierarchy(); - StaticHierarchy(const Expression * const * operands, bool cloneOperands); - StaticHierarchy(const Expression * expression, bool cloneOperands); // Specialized constructor for StaticHierarchy<1> - StaticHierarchy(const Expression * expression1, const Expression * expression2, bool cloneOperands = true); // Specialized constructor for StaticHierarchy<2> - ~StaticHierarchy(); - StaticHierarchy(const StaticHierarchy & other) = delete; - StaticHierarchy(StaticHierarchy && other) = delete; - StaticHierarchy& operator=(const StaticHierarchy & other) = delete; - StaticHierarchy& operator=(StaticHierarchy && other) = delete; - - virtual void setArgument(ListData * listData, int numberOfEntries, bool clone); - int numberOfChildren() const override { return T; } - const Expression * const * operands() const override { return m_operands; } - virtual bool hasValidNumberOfOperands(int numberOfChildren) const; -protected: - void build(const Expression * const * operands, int numberOfChildren, bool cloneOperands); - int simplificationOrderSameType(const ExpressionNode * e, bool canBeInterrupted) const override; - const Expression * m_operands[T]; -}; - -} - -#endif diff --git a/poincare/src/bounded_static_hierarchy.cpp b/poincare/src/bounded_static_hierarchy.cpp deleted file mode 100644 index 03b8cc91b..000000000 --- a/poincare/src/bounded_static_hierarchy.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include -extern "C" { -#include -} - -namespace Poincare { - -template -BoundedStaticHierarchy::BoundedStaticHierarchy() : - StaticHierarchy(), - m_numberOfChildren(0) -{ -} - -template -BoundedStaticHierarchy::BoundedStaticHierarchy(const Expression * const * operands, int numberOfChildren, bool cloneOperands) : - m_numberOfChildren(numberOfChildren) -{ - StaticHierarchy::build(operands, numberOfChildren, cloneOperands); -} - -template<> -BoundedStaticHierarchy<2>::BoundedStaticHierarchy(const Expression * e1, const Expression * e2, bool cloneOperands) : - BoundedStaticHierarchy(ExpressionArray(e1, e2).array(), 2, cloneOperands) -{ -} - -template<> -BoundedStaticHierarchy<2>::BoundedStaticHierarchy(const Expression * e, bool cloneOperands) : - BoundedStaticHierarchy((Expression **)&e, 1, cloneOperands) -{ -} - -template -void BoundedStaticHierarchy::setArgument(ListData * listData, int numberOfChildren, bool clone) { - StaticHierarchy::setArgument(listData, numberOfChildren, clone); - m_numberOfChildren = listData->numberOfChildren(); -} - -template -bool BoundedStaticHierarchy::hasValidNumberOfOperands(int numberOfChildren) const { - return numberOfChildren >= 1 && numberOfChildren <= T; -} - -template class Poincare::BoundedStaticHierarchy<2>; - -} diff --git a/poincare/src/dynamic_hierarchy.cpp b/poincare/src/dynamic_hierarchy.cpp deleted file mode 100644 index f755c472b..000000000 --- a/poincare/src/dynamic_hierarchy.cpp +++ /dev/null @@ -1,180 +0,0 @@ -#include -extern "C" { -#include -#include -} - -namespace Poincare { - -DynamicHierarchy::DynamicHierarchy() : - Expression(), - m_operands(nullptr), - m_numberOfChildren(0) -{ -} - -DynamicHierarchy::DynamicHierarchy(const Expression * const * operands, int numberOfChildren, bool cloneOperands) : - Expression(), - m_numberOfChildren(numberOfChildren) -{ - assert(operands != nullptr); - m_operands = new const Expression * [numberOfChildren]; - for (int i=0; iclone(); - } else { - m_operands[i] = operands[i]; - } - const_cast(m_operands[i])->setParent(this); - } -} - -DynamicHierarchy::~DynamicHierarchy() { - if (m_operands != nullptr) { - for (int i = 0; i < m_numberOfChildren; i++) { - if (m_operands[i] != nullptr) { - delete m_operands[i]; - } - } - } - delete[] m_operands; -} - -void DynamicHierarchy::addOperands(const Expression * const * operands, int numberOfChildren) { - assert(numberOfChildren > 0); - const Expression ** newOperands = new const Expression * [m_numberOfChildren+numberOfChildren]; - for (int i=0; i(operands[i])->setParent(this); - newOperands[i+m_numberOfChildren] = operands[i]; - } - delete[] m_operands; - m_operands = newOperands; - m_numberOfChildren += numberOfChildren; -} - -void DynamicHierarchy::mergeOperands(DynamicHierarchy * d) { - removeOperand(d, false); - addOperands(d->operands(), d->numberOfChildren()); - d->detachOperands(); - delete d; -} - -void DynamicHierarchy::addOperand(Expression * operand) { - addOperandAtIndex(operand, m_numberOfChildren); -} - -void DynamicHierarchy::addOperandAtIndex(Expression * operand, int index) { - assert(index >= 0 && index <= m_numberOfChildren); - const Expression ** newOperands = new const Expression * [m_numberOfChildren+1]; - int j = 0; - for (int i=0; i<=m_numberOfChildren; i++) { - if (i == index) { - operand->setParent(this); - newOperands[i] = operand; - } else { - newOperands[i] = m_operands[j++]; - } - } - delete[] m_operands; - m_operands = newOperands; - m_numberOfChildren += 1; -} - -void DynamicHierarchy::removeOperand(const Expression * e, bool deleteAfterRemoval) { - for (int i=0; i 0; i--) { - bool isSorted = true; - for (int j = 0; j < numberOfChildren()-1; j++) { - /* Warning: Matrix operations are not always commutative (ie, - * multiplication) so we never swap 2 matrices. */ -#if MATRIX_EXACT_REDUCING - if (order(operand(j), operand(j+1), canBeInterrupted) > 0 && (!operand(j)->recursivelyMatches(Expression::IsMatrix) || !operand(j+1)->recursivelyMatches(Expression::IsMatrix))) { -#else - if (order(operand(j), operand(j+1), canBeInterrupted) > 0) { -#endif - swapOperands(j, j+1); - isSorted = false; - } - } - if (isSorted) { - return; - } - } -} - -Expression * DynamicHierarchy::squashUnaryHierarchy() { - if (numberOfChildren() == 1) { - assert(parent() != nullptr); - Expression * o = editableOperand(0); - replaceWith(o, true); - return o; - } - return this; -} - -// Private - -void DynamicHierarchy::removeOperandAtIndex(int i, bool deleteAfterRemoval) { - if (deleteAfterRemoval) { - delete m_operands[i]; - } else { - const_cast(m_operands[i])->setParent(nullptr); - } - m_numberOfChildren--; - for (int j=i; jnumberOfChildren(); - int n = e->numberOfChildren(); - for (int i = 1; i <= m; i++) { - // The NULL node is the least node type. - if (n < i) { - return 1; - } - int order = SimplificationOrder(this->operand(m-i), e->operand(n-i), canBeInterrupted); - if (order != 0) { - return order; - } - } - // The NULL node is the least node type. - if (n > m) { - return -1; - } - return 0; -} - -int DynamicHierarchy::simplificationOrderGreaterType(const Expression * e, bool canBeInterrupted) const { - int m = numberOfChildren(); - if (m == 0) { - return -1; - } - /* Compare e to last term of hierarchy. */ - int order = SimplificationOrder(operand(m-1), e, canBeInterrupted); - if (order != 0) { - return order; - } - if (m > 1) { - return 1; - } - return 0; -} - -} diff --git a/poincare/src/static_hierarchy.cpp b/poincare/src/static_hierarchy.cpp deleted file mode 100644 index d7699bd68..000000000 --- a/poincare/src/static_hierarchy.cpp +++ /dev/null @@ -1,92 +0,0 @@ -#include -#include -extern "C" { -#include -} - -namespace Poincare { - -template -StaticHierarchy::StaticHierarchy() : - Expression(), - m_operands{} -{ -} - -template -StaticHierarchy::StaticHierarchy(const Expression * const * operands, bool cloneOperands) : - Expression() -{ - build(operands, T, cloneOperands); -} - -template<> -StaticHierarchy<1>::StaticHierarchy(const Expression * e, bool cloneOperands) : - StaticHierarchy((Expression **)&e, cloneOperands) -{ -} - -template<> -StaticHierarchy<2>::StaticHierarchy(const Expression * e1, const Expression * e2, bool cloneOperands) : - StaticHierarchy(ExpressionArray(e1, e2).array(), cloneOperands) -{ -} - -template -StaticHierarchy::~StaticHierarchy() { - for (int i = 0; i < T; i++) { - if (m_operands[i] != nullptr) { - delete m_operands[i]; - } - } -} - -template -void StaticHierarchy::setArgument(ListData * listData, int numberOfChildren, bool clone) { - build(listData->operands(), listData->numberOfChildren(), clone); -} - -template -bool StaticHierarchy::hasValidNumberOfOperands(int numberOfChildren) const { - return numberOfChildren == T; -} - -template -void StaticHierarchy::build(const Expression * const * operands, int numberOfChildren, bool cloneOperands) { - assert(operands != nullptr); - assert(numberOfChildren <= T); - for (int i=0; i < numberOfChildren; i++) { - assert(operands[i] != nullptr); - if (cloneOperands) { - m_operands[i] = operands[i]->clone(); - } else { - m_operands[i] = operands[i]; - } - const_cast(m_operands[i])->setParent(this); - } -} - -template -int StaticHierarchy::simplificationOrderSameType(const Expression * e, bool canBeInterrupted) const { - for (int i = 0; i < this->numberOfChildren(); i++) { - // The NULL node is the least node type. - if (e->numberOfChildren() <= i) { - return 1; - } - if (SimplificationOrder(this->operand(i), e->operand(i), canBeInterrupted) != 0) { - return SimplificationOrder(this->operand(i), e->operand(i), canBeInterrupted); - } - } - // The NULL node is the least node type. - if (e->numberOfChildren() > numberOfChildren()) { - return -1; - } - return 0; -} - -template class Poincare::StaticHierarchy<0>; -template class Poincare::StaticHierarchy<1>; -template class Poincare::StaticHierarchy<2>; -template class Poincare::StaticHierarchy<3>; - -}