35 virtual ~GenericExpressionVisitor() =
default;
37 [[nodiscard]]
virtual Result VisitExpression(
const Expression &e, Args... args)
const {
38 switch (e.get_kind()) {
39 case ExpressionKind::Constant:
40 return VisitConstant(e, std::forward<Args>(args)...);
41 case ExpressionKind::Var:
42 return VisitVariable(e, std::forward<Args>(args)...);
43 case ExpressionKind::Add:
44 return VisitAddition(e, std::forward<Args>(args)...);
45 case ExpressionKind::Mul:
46 return VisitMultiplication(e, std::forward<Args>(args)...);
47 case ExpressionKind::Div:
48 return VisitDivision(e, std::forward<Args>(args)...);
49 case ExpressionKind::Log:
50 return VisitLog(e, std::forward<Args>(args)...);
51 case ExpressionKind::Abs:
52 return VisitAbs(e, std::forward<Args>(args)...);
53 case ExpressionKind::Exp:
54 return VisitExp(e, std::forward<Args>(args)...);
55 case ExpressionKind::Sqrt:
56 return VisitSqrt(e, std::forward<Args>(args)...);
57 case ExpressionKind::Pow:
58 return VisitPow(e, std::forward<Args>(args)...);
59 case ExpressionKind::Sin:
60 return VisitSin(e, std::forward<Args>(args)...);
61 case ExpressionKind::Cos:
62 return VisitCos(e, std::forward<Args>(args)...);
63 case ExpressionKind::Tan:
64 return VisitTan(e, std::forward<Args>(args)...);
65 case ExpressionKind::Asin:
66 return VisitAsin(e, std::forward<Args>(args)...);
67 case ExpressionKind::Acos:
68 return VisitAcos(e, std::forward<Args>(args)...);
69 case ExpressionKind::Atan:
70 return VisitAtan(e, std::forward<Args>(args)...);
71 case ExpressionKind::Atan2:
72 return VisitAtan2(e, std::forward<Args>(args)...);
73 case ExpressionKind::Sinh:
74 return VisitSinh(e, std::forward<Args>(args)...);
75 case ExpressionKind::Cosh:
76 return VisitCosh(e, std::forward<Args>(args)...);
77 case ExpressionKind::Tanh:
78 return VisitTanh(e, std::forward<Args>(args)...);
79 case ExpressionKind::Min:
80 return VisitMin(e, std::forward<Args>(args)...);
81 case ExpressionKind::Max:
82 return VisitMax(e, std::forward<Args>(args)...);
83 case ExpressionKind::IfThenElse:
84 return VisitIfThenElse(e, std::forward<Args>(args)...);
85 case ExpressionKind::Infty:
86 throw std::runtime_error(
"An infinity is detected while visiting an expression.");
87 case ExpressionKind::NaN:
88 throw std::runtime_error(
"NaN is detected while visiting an expression.");
89 case ExpressionKind::UninterpretedFunction:
90 return VisitUninterpretedFunction(e, std::forward<Args>(args)...);
92 throw std::runtime_error(
"Unreachable code.");
96 virtual Result VisitVariable(
const Expression &e, Args... args)
const = 0;
97 virtual Result VisitConstant(
const Expression &e, Args... args)
const = 0;
98 virtual Result VisitAddition(
const Expression &e, Args... args)
const = 0;
99 virtual Result VisitMultiplication(
const Expression &e, Args... args)
const = 0;
100 virtual Result VisitDivision(
const Expression &e, Args... args)
const = 0;
101 virtual Result VisitLog(
const Expression &e, Args... args)
const = 0;
102 virtual Result VisitAbs(
const Expression &e, Args... args)
const = 0;
103 virtual Result VisitExp(
const Expression &e, Args... args)
const = 0;
104 virtual Result VisitSqrt(
const Expression &e, Args... args)
const = 0;
105 virtual Result VisitPow(
const Expression &e, Args... args)
const = 0;
106 virtual Result VisitSin(
const Expression &e, Args... args)
const = 0;
107 virtual Result VisitCos(
const Expression &e, Args... args)
const = 0;
108 virtual Result VisitTan(
const Expression &e, Args... args)
const = 0;
109 virtual Result VisitAsin(
const Expression &e, Args... args)
const = 0;
110 virtual Result VisitAcos(
const Expression &e, Args... args)
const = 0;
111 virtual Result VisitAtan(
const Expression &e, Args... args)
const = 0;
112 virtual Result VisitAtan2(
const Expression &e, Args... args)
const = 0;
113 virtual Result VisitSinh(
const Expression &e, Args... args)
const = 0;
114 virtual Result VisitCosh(
const Expression &e, Args... args)
const = 0;
115 virtual Result VisitTanh(
const Expression &e, Args... args)
const = 0;
116 virtual Result VisitMin(
const Expression &e, Args... args)
const = 0;
117 virtual Result VisitMax(
const Expression &e, Args... args)
const = 0;
118 virtual Result VisitIfThenElse(
const Expression &e, Args... args)
const = 0;
119 virtual Result VisitUninterpretedFunction(
const Expression &e, Args... args)
const = 0;