diff --git a/poincare/include/poincare/constant.h b/poincare/include/poincare/constant.h index 879ae4b8d..fe05d0a51 100644 --- a/poincare/include/poincare/constant.h +++ b/poincare/include/poincare/constant.h @@ -50,6 +50,9 @@ public: Expression shallowReduce(ReductionContext reductionContext) override; LayoutShape leftLayoutShape() const override { return LayoutShape::OneLetter; }; + /* Derivation */ + bool derivate(ReductionContext reductionContext, Expression symbol, Expression symbolValue) override; + private: char m_name[0]; // MUST be the last member variable @@ -70,6 +73,7 @@ public: // Simplification Expression shallowReduce(ExpressionNode::ReductionContext reductionContext); + bool derivate(ExpressionNode::ReductionContext reductionContext, Expression symbol, Expression symbolValue); private: ConstantNode * node() const { return static_cast(Expression::node()); } diff --git a/poincare/src/constant.cpp b/poincare/src/constant.cpp index eb53a14d9..b21d5ba2d 100644 --- a/poincare/src/constant.cpp +++ b/poincare/src/constant.cpp @@ -78,6 +78,10 @@ Expression ConstantNode::shallowReduce(ReductionContext reductionContext) { return Constant(this).shallowReduce(reductionContext); } +bool ConstantNode::derivate(ReductionContext reductionContext, Expression symbol, Expression symbolValue) { + return Constant(this).derivate(reductionContext, symbol, symbolValue); +} + bool ConstantNode::isConstantCodePoint(CodePoint c) const { UTF8Decoder decoder(m_name); bool result = (decoder.nextCodePoint() == c); @@ -106,4 +110,9 @@ Expression Constant::shallowReduce(ExpressionNode::ReductionContext reductionCon return result; } +bool Constant::derivate(ExpressionNode::ReductionContext reductionContext, Expression symbol, Expression symbolValue) { + replaceWithInPlace(Rational::Builder(0)); + return true; +} + }