28class DumpEvaluateExpr {
30 DumpEvaluateExpr() : outs_(llvm::errs()) {}
31 DumpEvaluateExpr(llvm::raw_ostream &str) : outs_(str) {}
33 template <
typename A>
static void Dump(
const A &x) {
34 DumpEvaluateExpr{}.Show(x);
37 static void Dump(llvm::raw_ostream &stream,
const A &x) {
38 DumpEvaluateExpr{stream}.Show(x);
42 template <
typename T>
struct TypeOf {
43 static constexpr std::string_view get() {
45#define DUMP_EXPR_SHOW_TYPE
46 std::string_view v(__PRETTY_FUNCTION__);
49 std::string_view front(
"with T = ");
50 std::string_view back(
"; std::string_view =");
52#elif defined(_MSC_VER)
53#define DUMP_EXPR_SHOW_TYPE
54 std::string_view v(__FUNCSIG__);
57 std::string_view front(
"TypeOf<");
58 std::string_view back(
">::get(void)");
62#if defined(DUMP_EXPR_SHOW_TYPE)
63#undef DUMP_EXPR_SHOW_TYPE
64 if (
auto fpos{v.find(front)}; fpos != v.npos) {
65 v.remove_prefix(fpos + front.size());
66 if (
auto bpos{v.find(back)}; bpos != v.npos) {
67 v.remove_suffix(v.size() - bpos);
76 static constexpr std::string_view name{TypeOf<T>::get()};
82 template <
typename A>
void Show(
const SymbolRef x) { Show(*x); }
83 template <
typename A>
void Show(
const std::unique_ptr<A> &x) {
86 template <
typename A>
void Show(
const std::shared_ptr<A> &x) {
89 template <
typename A>
void Show(
const A *x) {
96 template <
typename A>
void Show(
const std::optional<A> &x) {
103 template <
typename... A>
void Show(
const std::variant<A...> &u) {
104 common::visit([&](
const auto &v) { Show(v); }, u);
106 template <
typename A>
void Show(
const std::vector<A> &x) {
108 for (
const auto &v : x) {
113 void Show(
const evaluate::BOZLiteralConstant &);
116 if constexpr (T::category == common::TypeCategory::Derived) {
117 Indent(
"derived constant "s + std::string(TypeOf<T>::name));
118 for (
const auto &map : x.values()) {
119 for (
const auto &pair : map) {
120 Show(pair.second.value());
125 Print(
"constant "s + std::string(TypeOf<T>::name));
128 void Show(
const Symbol &symbol);
143 Indent(
"designator "s + std::string(TypeOf<T>::name));
152 Indent(
"procedure ref");
158 Indent(
"function ref "s + std::string(TypeOf<T>::name));
166 template <
typename T>
168 Indent(
"array constructor value "s + std::string(TypeOf<T>::name));
175 Indent(
"implied do "s + std::string(TypeOf<T>::name));
183 void Show(
const DerivedTypeSpec::ParameterMapType::value_type &x);
185 void Show(
const evaluate::StructureConstructorValues::value_type &x);
187 template <
typename D,
typename R,
typename O>
189 Indent(
"unary op "s + std::string(TypeOf<D>::name));
193 template <
typename D,
typename R,
typename LO,
typename RO>
195 Indent(
"binary op "s + std::string(TypeOf<D>::name));
202 Indent(
"expr <" + std::string(TypeOf<T>::name) +
">");
207 const char *GetIndentString()
const;
208 void Print(llvm::Twine s);
209 void Indent(llvm::StringRef s);
212 llvm::raw_ostream &outs_;