mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 05:40:38 +01:00
[poincare] Hierarchy::operands() is a "const Expression * const *"
This commit is contained in:
@@ -9,7 +9,7 @@ template<int T>
|
||||
class BoundedStaticHierarchy : public StaticHierarchy<T> {
|
||||
public:
|
||||
BoundedStaticHierarchy();
|
||||
BoundedStaticHierarchy(Expression * const * operands, int numberOfOperands, bool cloneOperands = true);
|
||||
BoundedStaticHierarchy(const Expression * const * operands, int numberOfOperands, bool cloneOperands = true);
|
||||
int numberOfOperands() const override { return m_numberOfOperands; }
|
||||
bool hasValidNumberOfOperands(int numberOfOperands) const override;
|
||||
private:
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Poincare {
|
||||
class DynamicHierarchy : public Hierarchy {
|
||||
public:
|
||||
DynamicHierarchy();
|
||||
DynamicHierarchy(Expression * const * operands, int numberOfOperands, bool cloneOperands = true);
|
||||
DynamicHierarchy(const Expression * const * operands, int numberOfOperands, bool cloneOperands = true);
|
||||
~DynamicHierarchy();
|
||||
DynamicHierarchy(const DynamicHierarchy & other) = delete;
|
||||
DynamicHierarchy(DynamicHierarchy && other) = delete;
|
||||
@@ -16,12 +16,12 @@ public:
|
||||
DynamicHierarchy& operator=(DynamicHierarchy && other) = delete;
|
||||
|
||||
int numberOfOperands() const override { return m_numberOfOperands; }
|
||||
Expression * const * operands() const override { return m_operands; };
|
||||
const Expression * const * operands() const override { return m_operands; };
|
||||
|
||||
void removeOperand(const Expression * e, bool deleteAfterRemoval = true);
|
||||
void addOperands(Expression * const * operands, int numberOfOperands);
|
||||
void addOperands(const Expression * const * operands, int numberOfOperands);
|
||||
private:
|
||||
Expression ** m_operands;
|
||||
const Expression ** m_operands;
|
||||
int m_numberOfOperands;
|
||||
};
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Poincare {
|
||||
|
||||
class Factorial : public StaticHierarchy<1> {
|
||||
public:
|
||||
Factorial(Expression * argument, bool clone = true);
|
||||
Factorial(const Expression * argument, bool clone = true);
|
||||
Type type() const override;
|
||||
Expression * clone() const override;
|
||||
bool isCommutative() const override;
|
||||
|
||||
@@ -11,7 +11,7 @@ public:
|
||||
void swapOperands(int i, int j) override;
|
||||
void replaceOperand(const Expression * oldOperand, Expression * newOperand, bool deleteOldOperand = true) override;
|
||||
void detachOperands(); // Removes all operands WITHOUT deleting them
|
||||
virtual Expression * const * operands() const = 0;
|
||||
virtual const Expression * const * operands() const = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ class StaticHierarchy : public Hierarchy {
|
||||
public:
|
||||
|
||||
StaticHierarchy();
|
||||
StaticHierarchy(Expression * const * operands, bool cloneOperands = true);
|
||||
StaticHierarchy(const Expression * const * operands, bool cloneOperands = true);
|
||||
~StaticHierarchy();
|
||||
StaticHierarchy(const StaticHierarchy & other) = delete;
|
||||
StaticHierarchy(StaticHierarchy && other) = delete;
|
||||
@@ -20,11 +20,11 @@ public:
|
||||
|
||||
virtual void setArgument(ListData * listData, int numberOfEntries, bool clone);
|
||||
int numberOfOperands() const override { return T; }
|
||||
Expression * const * operands() const override { return m_operands; }
|
||||
const Expression * const * operands() const override { return m_operands; }
|
||||
virtual bool hasValidNumberOfOperands(int numberOfOperands) const;
|
||||
protected:
|
||||
void build(Expression * const * operands, int numberOfOperands, bool cloneOperands);
|
||||
Expression * m_operands[T];
|
||||
void build(const Expression * const * operands, int numberOfOperands, bool cloneOperands);
|
||||
const Expression * m_operands[T];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ BoundedStaticHierarchy<T>::BoundedStaticHierarchy() :
|
||||
}
|
||||
|
||||
template<int T>
|
||||
BoundedStaticHierarchy<T>::BoundedStaticHierarchy(Expression * const * operands, int numberOfOperands, bool cloneOperands) :
|
||||
BoundedStaticHierarchy<T>::BoundedStaticHierarchy(const Expression * const * operands, int numberOfOperands, bool cloneOperands) :
|
||||
m_numberOfOperands(numberOfOperands)
|
||||
{
|
||||
StaticHierarchy<T>::build(operands, numberOfOperands, cloneOperands);
|
||||
|
||||
@@ -12,12 +12,12 @@ DynamicHierarchy::DynamicHierarchy() :
|
||||
{
|
||||
}
|
||||
|
||||
DynamicHierarchy::DynamicHierarchy(Expression * const * operands, int numberOfOperands, bool cloneOperands) :
|
||||
DynamicHierarchy::DynamicHierarchy(const Expression * const * operands, int numberOfOperands, bool cloneOperands) :
|
||||
m_numberOfOperands(numberOfOperands)
|
||||
{
|
||||
assert(operands != nullptr);
|
||||
assert(numberOfOperands >= 2);
|
||||
m_operands = new Expression * [numberOfOperands];
|
||||
m_operands = new const Expression * [numberOfOperands];
|
||||
for (int i=0; i<numberOfOperands; i++) {
|
||||
assert(operands[i] != nullptr);
|
||||
if (cloneOperands) {
|
||||
@@ -39,9 +39,9 @@ DynamicHierarchy::~DynamicHierarchy() {
|
||||
delete[] m_operands;
|
||||
}
|
||||
|
||||
void DynamicHierarchy::addOperands(Expression * const * operands, int numberOfOperands) {
|
||||
void DynamicHierarchy::addOperands(const Expression * const * operands, int numberOfOperands) {
|
||||
assert(numberOfOperands > 0);
|
||||
Expression ** newOperands = new Expression * [m_numberOfOperands+numberOfOperands];
|
||||
const Expression ** newOperands = new const Expression * [m_numberOfOperands+numberOfOperands];
|
||||
for (int i=0; i<m_numberOfOperands; i++) {
|
||||
newOperands[i] = m_operands[i];
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ extern "C" {
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
Factorial::Factorial(Expression * argument, bool clone) :
|
||||
Factorial::Factorial(const Expression * argument, bool clone) :
|
||||
StaticHierarchy<1>(&argument, clone)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ template<typename T> Evaluation<T> * Power::computeOnMatrices(Evaluation<T> * m,
|
||||
ExpressionLayout * Power::privateCreateLayout(FloatDisplayMode floatDisplayMode, ComplexFormat complexFormat) const {
|
||||
assert(floatDisplayMode != FloatDisplayMode::Default);
|
||||
assert(complexFormat != ComplexFormat::Default);
|
||||
Expression * indiceOperand = m_operands[1];
|
||||
const Expression * indiceOperand = m_operands[1];
|
||||
// Delete eventual parentheses of the indice in the pretty print
|
||||
if (m_operands[1]->type() == Type::Parenthesis) {
|
||||
indiceOperand = (Expression *)m_operands[1]->operand(0);
|
||||
|
||||
@@ -12,7 +12,7 @@ StaticHierarchy<T>::StaticHierarchy() :
|
||||
}
|
||||
|
||||
template<int T>
|
||||
StaticHierarchy<T>::StaticHierarchy(Expression * const * operands, bool cloneOperands)
|
||||
StaticHierarchy<T>::StaticHierarchy(const Expression * const * operands, bool cloneOperands)
|
||||
{
|
||||
build(operands, T, cloneOperands);
|
||||
}
|
||||
@@ -37,7 +37,7 @@ bool StaticHierarchy<T>::hasValidNumberOfOperands(int numberOfOperands) const {
|
||||
}
|
||||
|
||||
template<int T>
|
||||
void StaticHierarchy<T>::build(Expression * const * operands, int numberOfOperands, bool cloneOperands) {
|
||||
void StaticHierarchy<T>::build(const Expression * const * operands, int numberOfOperands, bool cloneOperands) {
|
||||
assert(operands != nullptr);
|
||||
assert(numberOfOperands <= T);
|
||||
for (int i=0; i < numberOfOperands; i++) {
|
||||
|
||||
Reference in New Issue
Block a user