From 5ddcbbe4b7c7d4314f14f35df3d633e4ae91d054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 9 Oct 2017 14:02:16 +0200 Subject: [PATCH] [poincare] Implement isPositive for symbols Pi and e Change-Id: I6fb3f605eaf62848b2e90b186c9adb00b330f91d --- poincare/include/poincare/symbol.h | 1 + poincare/src/symbol.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/poincare/include/poincare/symbol.h b/poincare/include/poincare/symbol.h index 44d4c8984..893b26c8e 100644 --- a/poincare/include/poincare/symbol.h +++ b/poincare/include/poincare/symbol.h @@ -34,6 +34,7 @@ public: char name() const; Type type() const override; Expression * clone() const override; + bool isPositive() const override; bool isMatrixSymbol() const; private: Evaluation * privateEvaluate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { return templatedEvaluate(context, angleUnit); } diff --git a/poincare/src/symbol.cpp b/poincare/src/symbol.cpp index f9f00748f..40d704945 100644 --- a/poincare/src/symbol.cpp +++ b/poincare/src/symbol.cpp @@ -4,6 +4,7 @@ #include "layout/baseline_relative_layout.h" #include "layout/string_layout.h" #include +#include extern "C" { #include } @@ -53,6 +54,21 @@ Expression * Symbol::clone() const { return new Symbol(m_name); } +bool Symbol::isPositive() const { + /* TODO: Maybe, we will want to know that from a context given in parameter: + if (context.expressionForSymbol(this) != nullptr) { + return context.expressionForSymbol(this)->isPositive(context); + } + return false;*/ + if (m_name == Ion::Charset::SmallPi) { + return true; + } + if (m_name == Ion::Charset::Exponential) { + return true; + } + return false; +} + template Evaluation * Symbol::templatedEvaluate(Context& context, AngleUnit angleUnit) const { if (context.expressionForSymbol(this) != nullptr) {