Skip to content

Commit 6affa32

Browse files
committed
rt: Allow tags to be logged
1 parent c659ba4 commit 6affa32

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

src/rt/rust_shape.cpp

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,8 +1239,12 @@ class log : public data<log,ptr> {
12391239
log(log &other,
12401240
const uint8_t *in_sp,
12411241
const type_param *in_params,
1242-
const rust_shape_tables *in_tables)
1243-
: data<log,ptr>(other.task, in_sp, in_params, in_tables, other.dp),
1242+
const rust_shape_tables *in_tables = NULL)
1243+
: data<log,ptr>(other.task,
1244+
in_sp,
1245+
in_params,
1246+
in_tables ? in_tables : other.tables,
1247+
other.dp),
12441248
out(other.out) {}
12451249

12461250
log(log &other, ptr in_dp)
@@ -1259,12 +1263,15 @@ class log : public data<log,ptr> {
12591263

12601264
void walk_tag(bool align, tag_info &tinfo, uint32_t tag_variant) {
12611265
out << "tag" << tag_variant;
1262-
// TODO: Print insides.
1266+
data<log,ptr>::walk_variant(align, tinfo, tag_variant);
12631267
}
12641268

12651269
void walk_subcontext(bool align, log &sub) { sub.walk(align); }
12661270

12671271
void walk_vec(bool align, bool is_pod, const std::pair<ptr,ptr> &data);
1272+
void walk_variant(bool align, tag_info &tinfo, uint32_t variant_id,
1273+
const std::pair<const uint8_t *,const uint8_t *>
1274+
variant_ptr_and_end);
12681275

12691276
template<typename T>
12701277
void walk_number() { out << get_dp<T>(dp); }
@@ -1323,6 +1330,27 @@ log::walk_vec(bool align, bool is_pod, const std::pair<ptr,ptr> &data) {
13231330
out << "]";
13241331
}
13251332

1333+
void
1334+
log::walk_variant(bool align, tag_info &tinfo, uint32_t variant_id,
1335+
const std::pair<const uint8_t *,const uint8_t *>
1336+
variant_ptr_and_end) {
1337+
log sub(*this, variant_ptr_and_end.first, tinfo.params);
1338+
const uint8_t *variant_end = variant_ptr_and_end.second;
1339+
1340+
bool first = true;
1341+
while (sub.sp < variant_end) {
1342+
out << (first ? "(" : ", ");
1343+
1344+
sub.walk(align);
1345+
1346+
align = true;
1347+
first = false;
1348+
}
1349+
1350+
if (!first)
1351+
out << ")";
1352+
}
1353+
13261354
} // end namespace shape
13271355

13281356
extern "C" void

0 commit comments

Comments
 (0)