[poincare] Add constants to context class

Change-Id: I31f1cdc6ac49062d5cac36c36f8f9650dac9ea61
This commit is contained in:
Émilie Feral
2016-11-18 17:37:30 +01:00
parent 4967681a80
commit 858c9fbb55
2 changed files with 7 additions and 5 deletions

View File

@@ -15,10 +15,12 @@ class Context {
virtual const Expression * expressionForSymbol(const Symbol * symbol);
virtual const Expression * scalarExpressionForIndex(int index);
void setExpressionForSymbolName(Expression * expression, const Symbol * symbol);
static constexpr uint16_t k_maxNumberOfScalarExpressions = 26;
static constexpr uint16_t k_maxNumberOfListExpressions = 10;
static constexpr uint16_t k_maxNumberOfMatrixExpressions = 10;
private:
int symbolIndex(const Symbol * symbol) const;
static constexpr uint16_t k_maxNumberOfExpressions = 26;
Expression * m_expressions[k_maxNumberOfExpressions];
Expression * m_expressions[k_maxNumberOfScalarExpressions];
static Float * defaultExpression();
};

View File

@@ -3,7 +3,7 @@
Context::Context()
{
for (int i = 0; i < k_maxNumberOfExpressions; i++) {
for (int i = 0; i < k_maxNumberOfScalarExpressions; i++) {
m_expressions[i] = nullptr;
}
}
@@ -20,7 +20,7 @@ int Context::symbolIndex(const Symbol * symbol) const {
const Expression * Context::expressionForSymbol(const Symbol * symbol) {
int index = symbolIndex(symbol);
if (index < 0 || index >= k_maxNumberOfExpressions) {
if (index < 0 || index >= k_maxNumberOfScalarExpressions) {
return nullptr;
}
if (m_expressions[index] == nullptr) {
@@ -30,7 +30,7 @@ const Expression * Context::expressionForSymbol(const Symbol * symbol) {
}
const Expression * Context::scalarExpressionForIndex(int index) {
assert(index < k_maxNumberOfExpressions);
assert(index < k_maxNumberOfScalarExpressions);
return m_expressions[index];
}