16
16
17
17
#include < memory>
18
18
#include < optional>
19
+ #include < string>
19
20
#include < variant>
20
21
#include < vector>
21
22
@@ -38,6 +39,17 @@ class DumpEvaluateExpr {
38
39
}
39
40
40
41
private:
42
+ template <typename T>
43
+ struct TypeOf {
44
+ static constexpr std::string_view name{TypeOf<T>::get ()};
45
+ static constexpr std::string_view get () {
46
+ std::string_view v (__PRETTY_FUNCTION__);
47
+ v.remove_prefix (99 ); // Strip the part "... [with T = "
48
+ v.remove_suffix (50 ); // Strip the ending "; string_view = ...]"
49
+ return v;
50
+ }
51
+ };
52
+
41
53
template <typename A, bool C> void Show (const common::Indirection<A, C> &x) {
42
54
Show (x.value ());
43
55
}
@@ -76,15 +88,15 @@ class DumpEvaluateExpr {
76
88
void Show (const evaluate::NullPointer &);
77
89
template <typename T> void Show (const evaluate::Constant<T> &x) {
78
90
if constexpr (T::category == common::TypeCategory::Derived) {
79
- Indent (" derived constant" );
91
+ Indent (" derived constant " s + std::string (TypeOf<T>::name) );
80
92
for (const auto &map : x.values ()) {
81
93
for (const auto &pair : map) {
82
94
Show (pair.second .value ());
83
95
}
84
96
}
85
97
Outdent ();
86
98
} else {
87
- Print (" constant" );
99
+ Print (" constant " s + std::string (TypeOf<T>::name) );
88
100
}
89
101
}
90
102
void Show (const Symbol &symbol);
@@ -102,7 +114,7 @@ class DumpEvaluateExpr {
102
114
void Show (const evaluate::Substring &x);
103
115
void Show (const evaluate::ComplexPart &x);
104
116
template <typename T> void Show (const evaluate::Designator<T> &x) {
105
- Indent (" designator" );
117
+ Indent (" designator " s + std::string (TypeOf<T>::name) );
106
118
Show (x.u );
107
119
Outdent ();
108
120
}
@@ -117,7 +129,7 @@ class DumpEvaluateExpr {
117
129
Outdent ();
118
130
}
119
131
template <typename T> void Show (const evaluate::FunctionRef<T> &x) {
120
- Indent (" function ref" );
132
+ Indent (" function ref " s + std::string (TypeOf<T>::name) );
121
133
Show (x.proc ());
122
134
Show (x.arguments ());
123
135
Outdent ();
@@ -127,14 +139,14 @@ class DumpEvaluateExpr {
127
139
}
128
140
template <typename T>
129
141
void Show (const evaluate::ArrayConstructorValues<T> &x) {
130
- Indent (" array constructor value" );
142
+ Indent (" array constructor value " s + std::string (TypeOf<T>::name) );
131
143
for (auto &v : x) {
132
144
Show (v);
133
145
}
134
146
Outdent ();
135
147
}
136
148
template <typename T> void Show (const evaluate::ImpliedDo<T> &x) {
137
- Indent (" implied do" );
149
+ Indent (" implied do " s + std::string (TypeOf<T>::name) );
138
150
Show (x.lower ());
139
151
Show (x.upper ());
140
152
Show (x.stride ());
@@ -148,20 +160,20 @@ class DumpEvaluateExpr {
148
160
void Show (const evaluate::StructureConstructor &x);
149
161
template <typename D, typename R, typename O>
150
162
void Show (const evaluate::Operation<D, R, O> &op) {
151
- Indent (" unary op" );
163
+ Indent (" unary op " s + std::string (TypeOf<D>::name) );
152
164
Show (op.left ());
153
165
Outdent ();
154
166
}
155
167
template <typename D, typename R, typename LO, typename RO>
156
168
void Show (const evaluate::Operation<D, R, LO, RO> &op) {
157
- Indent (" binary op" );
169
+ Indent (" binary op " s + std::string (TypeOf<D>::name) );
158
170
Show (op.left ());
159
171
Show (op.right ());
160
172
Outdent ();
161
173
}
162
174
void Show (const evaluate::Relational<evaluate::SomeType> &x);
163
175
template <typename T> void Show (const evaluate::Expr<T> &x) {
164
- Indent (" expr T " );
176
+ Indent (" expr < " + std::string (TypeOf<T>::name) + " > " );
165
177
Show (x.u );
166
178
Outdent ();
167
179
}
0 commit comments