mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 05:40:38 +01:00
Poincare: Add a Simplification class
Change-Id: Ide99e912262111722e11ae82dbc7eedb591ba14c
This commit is contained in:
@@ -34,6 +34,7 @@ objs += $(addprefix poincare/src/simplify/,\
|
||||
simplify_product_zero.o\
|
||||
expression_selector.o\
|
||||
expression_builder.o\
|
||||
simplification.o\
|
||||
)
|
||||
tests += $(addprefix poincare/test/,\
|
||||
addition.cpp\
|
||||
|
||||
@@ -41,13 +41,4 @@ public:
|
||||
uint8_t m_numberOfChildren;
|
||||
};
|
||||
|
||||
/*
|
||||
{
|
||||
my_tree_selector, my_expression_builder;
|
||||
if (my_tree_selector->match(my_expression)) {
|
||||
my_expression_builder->build(my_expression, *matchedData);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
10
poincare/src/simplify/simplification.cpp
Normal file
10
poincare/src/simplify/simplification.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include "simplification.h"
|
||||
|
||||
Expression * Simplification::simplify(Expression * expression) const {
|
||||
Expression * matches[255]; //FIXME: The sized ca be given by our compiler
|
||||
if (m_selector->match(expression, matches)) {
|
||||
return m_builder->build(matches);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
15
poincare/src/simplify/simplification.h
Normal file
15
poincare/src/simplify/simplification.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef POINCARE_SIMPLIFY_SIMPLIFICATION_H
|
||||
#define POINCARE_SIMPLIFY_SIMPLIFICATION_H
|
||||
|
||||
#include <poincare/expression.h>
|
||||
#include "expression_selector.h"
|
||||
#include "expression_builder.h"
|
||||
|
||||
class Simplification {
|
||||
public:
|
||||
ExpressionSelector * m_selector;
|
||||
ExpressionBuilder * m_builder;
|
||||
Expression * simplify(Expression * expression) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user