#include "cache_context.h" #include using namespace Poincare; namespace Sequence { template CacheContext::CacheContext(Context * parentContext) : VariableContext('n', parentContext), m_values{{Complex::Float(NAN), Complex::Float(NAN)}, {Complex::Float(NAN), Complex::Float(NAN)}} { } template const Expression * CacheContext::expressionForSymbol(const Symbol * symbol) { if (symbol->name() == Symbol::SpecialSymbols::un || symbol->name() == Symbol::SpecialSymbols::un1 || symbol->name() == Symbol::SpecialSymbols::vn || symbol->name() == Symbol::SpecialSymbols::vn1) { return &m_values[nameIndexForSymbol(symbol)][rankIndexForSymbol(symbol)]; } return VariableContext::expressionForSymbol(symbol); } template void CacheContext::setValueForSymbol(T value, const Poincare::Symbol * symbol) { m_values[nameIndexForSymbol(symbol)][rankIndexForSymbol(symbol)] = Complex::Float(value); } template int CacheContext::nameIndexForSymbol(const Poincare::Symbol * symbol) { switch (symbol->name()) { case Symbol::SpecialSymbols::un: return 0; case Symbol::SpecialSymbols::un1: return 0; case Symbol::SpecialSymbols::vn: return 1; case Symbol::SpecialSymbols::vn1: return 1; default: return 0; } } template int CacheContext::rankIndexForSymbol(const Poincare::Symbol * symbol) { switch (symbol->name()) { case Symbol::SpecialSymbols::un: return 0; case Symbol::SpecialSymbols::un1: return 1; case Symbol::SpecialSymbols::vn: return 0; case Symbol::SpecialSymbols::vn1: return 1; default: return 0; } } template class CacheContext; template class CacheContext; }