@@ -156,6 +156,8 @@ class ptr_pair {
156
156
157
157
ptr_pair (uint8_t *in_fst, uint8_t *in_snd) : fst(in_fst), snd(in_snd) {}
158
158
159
+ ptr_pair (data_pair<uint8_t *> &other) : fst(other.fst), snd(other.snd) {}
160
+
159
161
inline void operator =(uint8_t *rhs) { fst = snd = rhs; }
160
162
161
163
inline ptr_pair operator +(size_t n) const {
@@ -890,6 +892,7 @@ size_of::walk_ivec(bool align, bool is_pod, size_align &elem_sa) {
890
892
template <typename T,typename U>
891
893
class data : public ctxt < data<T,U> > {
892
894
protected:
895
+ void walk_box_contents (bool align);
893
896
void walk_variant (bool align, tag_info &tinfo, uint32_t variant);
894
897
895
898
static std::pair<uint8_t *,uint8_t *> get_evec_data_range (ptr dp);
@@ -953,6 +956,16 @@ class data : public ctxt< data<T,U> > {
953
956
void walk_number (bool align) { DATA_SIMPLE (W, walk_number<W>()); }
954
957
};
955
958
959
+ template <typename T,typename U>
960
+ void
961
+ data<T,U>::walk_box_contents(bool align) {
962
+ typename U::template data<uint8_t *>::t box_ptr = bump_dp<uint8_t *>(dp);
963
+
964
+ U ref_count_dp (box_ptr);
965
+ T sub (*static_cast <T *>(this ), ref_count_dp + sizeof (uint32_t ));
966
+ static_cast <T *>(this )->walk_box_contents (align, sub, ref_count_dp);
967
+ }
968
+
956
969
template <typename T,typename U>
957
970
void
958
971
data<T,U>::walk_variant(bool align, tag_info &tinfo, uint32_t variant_id) {
@@ -1079,6 +1092,12 @@ class cmp : public data<cmp,ptr_pair> {
1079
1092
result = sub.result ;
1080
1093
}
1081
1094
1095
+ inline void walk_box_contents (bool align, cmp &sub,
1096
+ ptr_pair &ref_count_dp) {
1097
+ sub.walk (true );
1098
+ result = sub.result ;
1099
+ }
1100
+
1082
1101
inline void cmp_two_pointers (bool align) {
1083
1102
if (align) dp = align_to (dp, ALIGNOF (uint8_t *) * 2 );
1084
1103
data_pair<uint8_t *> fst = bump_dp<uint8_t *>(dp);
@@ -1135,6 +1154,10 @@ class cmp : public data<cmp,ptr_pair> {
1135
1154
walk_vec (align, is_pod, get_ivec_data_range (dp));
1136
1155
}
1137
1156
1157
+ void walk_box (bool align) {
1158
+ data<cmp,ptr_pair>::walk_box_contents (align);
1159
+ }
1160
+
1138
1161
void walk_fn (bool align) { return cmp_two_pointers (align); }
1139
1162
void walk_obj (bool align) { return cmp_two_pointers (align); }
1140
1163
void walk_port (bool align) { return cmp_pointer (align); }
@@ -1143,7 +1166,6 @@ class cmp : public data<cmp,ptr_pair> {
1143
1166
1144
1167
void walk_tag (bool align, tag_info &tinfo,
1145
1168
const data_pair<uint32_t > &tag_variants);
1146
- void walk_box (bool align);
1147
1169
void walk_struct (bool align, const uint8_t *end_sp);
1148
1170
void walk_res (bool align, const rust_fn *dtor, uint16_t n_ty_params,
1149
1171
const uint8_t *ty_params_sp);
@@ -1188,16 +1210,6 @@ cmp::walk_tag(bool align, tag_info &tinfo,
1188
1210
data<cmp,ptr_pair>::walk_variant (align, tinfo, tag_variants.fst );
1189
1211
}
1190
1212
1191
- void
1192
- cmp::walk_box (bool align) {
1193
- data_pair<uint8_t *> subdp = bump_dp<uint8_t *>(dp);
1194
-
1195
- cmp sub (*this , ptr_pair::make (subdp));
1196
- sub.dp += sizeof (uint32_t ); // Skip over the reference count.
1197
- sub.walk (true );
1198
- result = sub.result ;
1199
- }
1200
-
1201
1213
void
1202
1214
cmp::walk_struct (bool align, const uint8_t *end_sp) {
1203
1215
while (!result && this ->sp != end_sp) {
@@ -1266,8 +1278,18 @@ class log : public data<log,ptr> {
1266
1278
data<log ,ptr>::walk_variant (align, tinfo, tag_variant);
1267
1279
}
1268
1280
1281
+ void walk_box (bool align) {
1282
+ out << " @" ;
1283
+ data<log ,ptr>::walk_box_contents (align);
1284
+ }
1285
+
1269
1286
void walk_subcontext (bool align, log &sub) { sub.walk (align); }
1270
1287
1288
+ void walk_box_contents (bool align, log &sub, ptr &ref_count_dp) {
1289
+ sub.walk (true );
1290
+ }
1291
+
1292
+ void walk_struct (bool align, const uint8_t *end_sp);
1271
1293
void walk_vec (bool align, bool is_pod, const std::pair<ptr,ptr> &data);
1272
1294
void walk_variant (bool align, tag_info &tinfo, uint32_t variant_id,
1273
1295
const std::pair<const uint8_t *,const uint8_t *>
@@ -1304,6 +1326,21 @@ log::walk_string(const std::pair<ptr,ptr> &data) {
1304
1326
out << " \" " << std::dec;
1305
1327
}
1306
1328
1329
+ void
1330
+ log::walk_struct (bool align, const uint8_t *end_sp) {
1331
+ out << " (" ;
1332
+
1333
+ bool first = true ;
1334
+ while (sp != end_sp) {
1335
+ if (!first)
1336
+ out << " , " ;
1337
+ walk (align);
1338
+ align = true , first = false ;
1339
+ }
1340
+
1341
+ out << " )" ;
1342
+ }
1343
+
1307
1344
void
1308
1345
log::walk_vec (bool align, bool is_pod, const std::pair<ptr,ptr> &data) {
1309
1346
if (peek () == SHAPE_U8) {
0 commit comments