mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
Poincare: Add hand-generated Simplifications
This will be generated by a compiler Change-Id: I5ae606417ecd4e86a61c38be65fc6a4f44e9c3d5
This commit is contained in:
99
poincare/src/simplify/simplification_rules.cpp
Normal file
99
poincare/src/simplify/simplification_rules.cpp
Normal file
@@ -0,0 +1,99 @@
|
||||
#include "simplification_rules.h"
|
||||
#include "simplification_generator.h"
|
||||
|
||||
const ExpressionSelector additionCommutativeSelector[5] = {
|
||||
{
|
||||
.m_match = ExpressionSelector::Match::TypeAndValue,
|
||||
.m_expressionType = Expression::Type::Addition,
|
||||
.m_numberOfChildren = 2
|
||||
},
|
||||
{
|
||||
.m_match = ExpressionSelector::Match::Any,
|
||||
.m_numberOfChildren = 0
|
||||
},
|
||||
{
|
||||
.m_match = ExpressionSelector::Match::TypeAndValue,
|
||||
.m_expressionType = Expression::Type::Addition,
|
||||
.m_numberOfChildren = 2,
|
||||
},
|
||||
{
|
||||
.m_match = ExpressionSelector::Match::Any,
|
||||
.m_numberOfChildren = 0
|
||||
},
|
||||
{
|
||||
.m_match = ExpressionSelector::Match::Any,
|
||||
.m_numberOfChildren = 0
|
||||
}
|
||||
};
|
||||
|
||||
const ExpressionBuilder additionCommutativeBuilder[4] = {
|
||||
{
|
||||
.m_action = ExpressionBuilder::Action::BuildFromTypeAndValue,
|
||||
.m_expressionType = Expression::Type::Addition,
|
||||
.m_numberOfChildren = 3
|
||||
},
|
||||
{
|
||||
.m_action = ExpressionBuilder::Action::Clone,
|
||||
.m_matchIndex = 1,
|
||||
.m_numberOfChildren = 0
|
||||
},
|
||||
{
|
||||
.m_action = ExpressionBuilder::Action::Clone,
|
||||
.m_matchIndex = 3,
|
||||
.m_numberOfChildren = 0
|
||||
},
|
||||
{
|
||||
.m_action = ExpressionBuilder::Action::Clone,
|
||||
.m_matchIndex = 4,
|
||||
.m_numberOfChildren = 0
|
||||
}
|
||||
};
|
||||
|
||||
const ExpressionSelector additionIntegerSelector[3] = {
|
||||
{
|
||||
.m_match = ExpressionSelector::Match::TypeAndValue,
|
||||
.m_expressionType = Expression::Type::Addition,
|
||||
.m_numberOfChildren = 2
|
||||
},
|
||||
{
|
||||
.m_match = ExpressionSelector::Match::TypeAndValue,
|
||||
.m_expressionType = Expression::Type::Integer,
|
||||
.m_numberOfChildren = 0
|
||||
},
|
||||
{
|
||||
.m_match = ExpressionSelector::Match::TypeAndValue,
|
||||
.m_expressionType = Expression::Type::Integer,
|
||||
.m_numberOfChildren = 0
|
||||
}
|
||||
};
|
||||
|
||||
const ExpressionBuilder additionIntegerBuilder[3] = {
|
||||
{
|
||||
.m_action = ExpressionBuilder::Action::CallExternalGenerator,
|
||||
.m_generator = &SimplificationGenerator::AddIntegers,
|
||||
.m_numberOfChildren = 2
|
||||
},
|
||||
{
|
||||
.m_action = ExpressionBuilder::Action::Clone,
|
||||
.m_matchIndex = 1,
|
||||
.m_numberOfChildren = 0
|
||||
},
|
||||
{
|
||||
.m_action = ExpressionBuilder::Action::Clone,
|
||||
.m_matchIndex = 2,
|
||||
.m_numberOfChildren = 0
|
||||
}
|
||||
};
|
||||
|
||||
const Simplification simplifications[2] = {
|
||||
{
|
||||
.m_selector = (ExpressionSelector *)additionCommutativeSelector,
|
||||
.m_builder = (ExpressionBuilder *)additionCommutativeBuilder
|
||||
},
|
||||
{
|
||||
.m_selector = (ExpressionSelector *)additionIntegerSelector,
|
||||
.m_builder = (ExpressionBuilder *)additionIntegerBuilder
|
||||
}
|
||||
};
|
||||
|
||||
const int numberOfSimplifications = 2;
|
||||
9
poincare/src/simplify/simplification_rules.h
Normal file
9
poincare/src/simplify/simplification_rules.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef POINCARE_SIMPLIFY_SIMPLIFICATION_RULES_H
|
||||
#define POINCARE_SIMPLIFY_SIMPLIFICATION_RULES_H
|
||||
|
||||
#include "simplification.h"
|
||||
|
||||
extern const Simplification simplifications[];
|
||||
extern const int numberOfSimplifications;
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user