using namespace std;
-/* I'd rather have overloads with different slots, but that creates an
-ambiguity because slots have template constructors. */
-BooleanEvaluator::BooleanEvaluator(const Function &f, bool allow_compare):
+BooleanEvaluator::BooleanEvaluator(const ValueFunction &f):
+ func([&f](const string &value, const string *){ return f(value); }),
+ ops("&|!")
+{ }
+
+BooleanEvaluator::BooleanEvaluator(const CompareFunction &f):
func(f),
- ops(allow_compare ? "&|!=^" : "&|!")
+ ops("&|!=^")
{ }
bool BooleanEvaluator::evaluate(const string &str)
class BooleanEvaluator
{
public:
- using Function = std::function<bool(const std::string &, const std::string *)>;
+ using ValueFunction = std::function<bool(const std::string &)>;
+ using CompareFunction = std::function<bool(const std::string &, const std::string *)>;
private:
- Function func;
+ CompareFunction func;
std::string ops;
std::vector<std::string> var_stack;
std::vector<unsigned char> value_stack;
bool last_was_op;
public:
- BooleanEvaluator(const Function &, bool = true);
+ BooleanEvaluator(const ValueFunction &);
+ BooleanEvaluator(const CompareFunction &);
bool evaluate(const std::string &);
private:
void ArchitectureConditional::if_arch(const string &cond)
{
const Architecture &arch = builder.get_current_arch();
- BooleanEvaluator eval([&arch](const string &value, const string *){ return arch.match_name(value); }, false);
+ BooleanEvaluator eval([&arch](const string &value){ return arch.match_name(value); });
bool match = eval.evaluate(cond);
builder.get_logger().log("configure", format("%s: arch %s %smatched", log_prefix, cond, (match ? "" : "not ")));
if(match)