6663b6c9
adorian
projet complet av...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
extern "C" {
#include <assert.h>
#include <stdlib.h>
#include <math.h>
}
#include <poincare/store.h>
#include <ion.h>
#include <poincare/complex.h>
#include <poincare/context.h>
#include "layout/horizontal_layout.h"
#include "layout/string_layout.h"
namespace Poincare {
Expression::Type Store::type() const {
return Type::Store;
}
Expression * Store::clone() const {
return new Store(operands(), true);
}
static_assert('\x8F' == Ion::Charset::Sto, "Incorrect");
int Store::writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits) const {
return LayoutEngine::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "\x8F");
}
Expression * Store::shallowReduce(Context& context, AngleUnit angleUnit) {
context.setExpressionForSymbolName(value(), symbol(), context);
return replaceWith(editableOperand(1), true)->shallowReduce(context, angleUnit);
}
ExpressionLayout * Store::privateCreateLayout(FloatDisplayMode floatDisplayMode, ComplexFormat complexFormat) const {
assert(floatDisplayMode != FloatDisplayMode::Default);
assert(complexFormat != ComplexFormat::Default);
ExpressionLayout * childrenLayouts[3];
childrenLayouts[0] = value()->createLayout(floatDisplayMode, complexFormat);
const char stoSymbol[2] = {Ion::Charset::Sto, 0};
childrenLayouts[1] = new StringLayout(stoSymbol, 1);
childrenLayouts[2] = symbol()->createLayout(floatDisplayMode, complexFormat);
return new HorizontalLayout(childrenLayouts, 3);
}
template<typename T>
Expression * Store::templatedApproximate(Context& context, AngleUnit angleUnit) const {
context.setExpressionForSymbolName(value(), symbol(), context);
if (context.expressionForSymbol(symbol()) != nullptr) {
return context.expressionForSymbol(symbol())->approximate<T>(context, angleUnit);
}
return new Complex<T>(Complex<T>::Float(NAN));
}
}
|