Files
Upsilon/poincare/src/n_context.cpp
Émilie Feral 8860902444 [poincare] Create a class n_context
Change-Id: Icce8f8fe79c07e73587d8c0563e930c1b1e6b308
2017-01-15 20:09:21 +01:00

25 lines
625 B
C++

#include <poincare/n_context.h>
NContext::NContext(::Context * parentContext) :
m_nValue(Float(0.0f)),
m_parentContext(parentContext)
{
}
void NContext::setExpressionForSymbolName(Expression * expression, const Symbol * symbol) {
if (symbol->name() == 'n') {
m_nValue = Float((int)expression->approximate(*m_parentContext));
} else {
m_parentContext->setExpressionForSymbolName(expression, symbol);
}
}
const Expression * NContext::expressionForSymbol(const Symbol * symbol) {
if (symbol->name() == 'n') {
return &m_nValue;
} else {
return m_parentContext->expressionForSymbol(symbol);
}
}