[poincare] Enable to call method on undefined Expression

This commit is contained in:
Émilie Feral
2018-08-10 10:10:12 +02:00
parent ed574620d3
commit 4ae72d68d8
4 changed files with 8 additions and 4 deletions

View File

@@ -105,6 +105,7 @@
#include <poincare/vertical_offset_layout_node.h>
#else
#include <poincare/global_context.h>
#include <poincare/addition.h>
#include <poincare/matrix_complex.h>
#include <poincare/multiplication.h>

View File

@@ -106,7 +106,7 @@ public:
bool isEqualToItsApproximationLayout(Expression approximation, int bufferSize, Preferences::AngleUnit angleUnit, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits, Context & context);
/* Layout Helper */
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return this->node()->createLayout(floatDisplayMode, numberOfSignificantDigits); }
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { return isDefined() ? node()->createLayout(floatDisplayMode, numberOfSignificantDigits) : LayoutRef(); }
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits = PrintFloat::k_numberOfStoredSignificantDigits) const { return this->node()->serialize(buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits); }
/* Simplification */

View File

@@ -14,7 +14,7 @@ public:
using TreeByReference::operator==;
using TreeByReference::operator!=;
LayoutReference(LayoutNode * node) :
LayoutReference(LayoutNode * node = nullptr) :
TreeByReference(node) {}
LayoutReference clone() const {

View File

@@ -220,8 +220,11 @@ Expression Expression::deepBeautify(Context & context, Preferences::AngleUnit an
template<typename U>
Expression Expression::approximate(Context& context, Preferences::AngleUnit angleUnit, Preferences::Preferences::ComplexFormat complexFormat) const {
Evaluation<U> e = node()->approximate(U(), context, angleUnit);
return e->complexToExpression(complexFormat);
if (isDefined()) {
Evaluation<U> e = node()->approximate(U(), context, angleUnit);
return e->complexToExpression(complexFormat);
}
return Undefined();
}
template<typename U>