mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-29 11:39:58 +02:00
[poincare] Fix implemenation of AnySelector
Change-Id: I8b17cf9e06a22bdcb84787a03fb9011b08dc93c4
This commit is contained in:
@@ -15,6 +15,7 @@ products += $(rulesets)
|
||||
objs += $(addprefix $(prefix)/,\
|
||||
expression_simplify.o \
|
||||
rule.o \
|
||||
selector/any_selector.o \
|
||||
selector/combination.o \
|
||||
selector/selector.o \
|
||||
selector/type_and_identifier_selector.o \
|
||||
|
||||
18
poincare/src/simplification/selector/any_selector.cpp
Normal file
18
poincare/src/simplification/selector/any_selector.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "any_selector.h"
|
||||
#include "combination.h"
|
||||
|
||||
namespace Poincare {
|
||||
namespace Simplification {
|
||||
|
||||
bool AnySelector::acceptsLocationInCombination(const Combination * combination, int location) const {
|
||||
// Yes, if no other slot in the combination before me is the same
|
||||
for (int i=0; i<location; i++) {
|
||||
if (combination->expressionIndexForSelectorIndex(i) == combination->expressionIndexForSelectorIndex(location)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return immediateMatch(combination->expressionForSelectorIndex(location));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,7 @@ namespace Simplification {
|
||||
class AnySelector : public Selector {
|
||||
public:
|
||||
using Selector::Selector;
|
||||
bool acceptsLocationInCombination(const Combination * combination, int location) const override {
|
||||
return true;
|
||||
}
|
||||
bool acceptsLocationInCombination(const Combination * combination, int location) const override;
|
||||
bool immediateMatch(const Expression * e) const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user