#include #include #include #include namespace Poincare { template VariableContext::VariableContext(char name, Context * parentContext) : m_name(name), m_value(Approximation(NAN)), m_parentContext(parentContext) { } template void VariableContext::setApproximationForVariable(T value) { m_value = Approximation(value); } template void VariableContext::setExpressionForSymbolName(const Expression * expression, const Symbol * symbol, Context & context) { if (symbol->name() == m_name) { if (expression == nullptr) { return; } m_value = Approximation(expression->approximateToScalar(context, Preferences::sharedPreferences()->angleUnit())); } else { m_parentContext->setExpressionForSymbolName(expression, symbol, context); } } template const Expression * VariableContext::expressionForSymbol(const Symbol * symbol) { if (symbol->name() == m_name) { return &m_value; } else { return m_parentContext->expressionForSymbol(symbol); } } template class Poincare::VariableContext; template class Poincare::VariableContext; }