mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-21 14:50:44 +01:00
Updates the addition code to use attributes.
We use a left and right attribtes instead of a children table. Change-Id: Ic11846bcf0763c717834124d626cb352a30e1045
This commit is contained in:
committed by
Félix Raimundo
parent
b33eb99067
commit
0059fe78fa
@@ -10,7 +10,8 @@ class Addition : public Expression {
|
||||
ExpressionLayout * createLayout(ExpressionLayout * parent) override;
|
||||
float approximate(Context& context) override;
|
||||
private:
|
||||
Expression * m_children[2];
|
||||
Expression * m_left;
|
||||
Expression * m_right;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
#include "layout/horizontal_layout.h"
|
||||
|
||||
Addition::Addition(Expression * first_operand, Expression * second_operand) {
|
||||
m_children[0] = first_operand;
|
||||
m_children[1] = second_operand;
|
||||
m_left = first_operand;
|
||||
m_right = second_operand;
|
||||
}
|
||||
|
||||
Addition::~Addition() {
|
||||
delete m_children[1];
|
||||
delete m_children[0];
|
||||
delete m_left;
|
||||
delete m_right;
|
||||
}
|
||||
|
||||
float Addition::approximate(Context& context) {
|
||||
return m_children[0]->approximate(context) + m_children[1]->approximate(context);
|
||||
return m_left->approximate(context) + m_right->approximate(context);
|
||||
}
|
||||
|
||||
ExpressionLayout * Addition::createLayout(ExpressionLayout * parent) {
|
||||
return new HorizontalLayout(parent, m_children[0], '+', m_children[1]);
|
||||
return new HorizontalLayout(parent, m_left, '+', m_right);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user