/* * UnaryBooleanFunctionExpression.h * * Created on: 03.01.2013 * Author: chris */ #ifndef UNARYBOOLEANFUNCTIONEXPRESSION_H_ #define UNARYBOOLEANFUNCTIONEXPRESSION_H_ #include "src/ir/expressions/UnaryExpression.h" namespace storm { namespace ir { namespace expressions { class UnaryBooleanFunctionExpression : public UnaryExpression { public: enum FunctionType {NOT}; UnaryBooleanFunctionExpression(std::shared_ptr child, FunctionType functionType) : UnaryExpression(bool_, child), functionType(functionType) { } virtual ~UnaryBooleanFunctionExpression() { } virtual std::shared_ptr clone(const std::map& renaming, const std::map& bools, const std::map& ints) { return std::shared_ptr(new UnaryBooleanFunctionExpression(this->getChild()->clone(renaming, bools, ints), this->functionType)); } FunctionType getFunctionType() const { return functionType; } virtual bool getValueAsBool(std::pair, std::vector> const* variableValues) const { bool resultChild = this->getChild()->getValueAsBool(variableValues); switch(functionType) { case NOT: return !resultChild; break; default: throw storm::exceptions::ExpressionEvaluationException() << "Cannot evaluate expression: " << "Unknown boolean unary operator: '" << functionType << "'."; } } virtual void accept(ExpressionVisitor* visitor) { visitor->visit(this); } virtual std::string toString() const { std::string result = ""; switch (functionType) { case NOT: result += "!"; break; } result += "(" + this->getChild()->toString() + ")"; return result; } virtual std::string dump(std::string prefix) const { std::stringstream result; result << prefix << "UnaryBooleanFunctionExpression" << std::endl; switch (functionType) { case NOT: result << prefix << "!" << std::endl; break; } result << this->getChild()->dump(prefix + "\t"); return result.str(); } private: FunctionType functionType; }; } } } #endif /* UNARYBOOLEANFUNCTIONEXPRESSION_H_ */