@@ -46,11 +46,18 @@ const uint8_t SHAPE_OBJ = 19u;
46
46
const uint8_t SHAPE_RES = 20u ;
47
47
const uint8_t SHAPE_VAR = 21u ;
48
48
49
+ #ifdef _LP64
50
+ const uint8_t SHAPE_PTR = SHAPE_U64;
51
+ #else
52
+ const uint8_t SHAPE_PTR = SHAPE_U32;
53
+ #endif
54
+
49
55
50
56
// Forward declarations
51
57
52
58
struct rust_obj ;
53
59
struct size_align ;
60
+ class ptr ;
54
61
class type_param ;
55
62
56
63
@@ -129,6 +136,21 @@ struct tag_info {
129
136
};
130
137
131
138
139
+ // Utility functions
140
+
141
+ inline uint16_t
142
+ get_u16 (const uint8_t *addr) {
143
+ return *reinterpret_cast <const uint16_t *>(addr);
144
+ }
145
+
146
+ inline uint16_t
147
+ get_u16_bump (const uint8_t *&addr) {
148
+ uint16_t result = get_u16 (addr);
149
+ addr += sizeof (uint16_t );
150
+ return result;
151
+ }
152
+
153
+
132
154
// Contexts
133
155
134
156
// The base context, an abstract class. We use the curiously recurring
@@ -166,8 +188,6 @@ class ctxt {
166
188
protected:
167
189
inline uint8_t peek () { return *sp; }
168
190
169
- static inline uint16_t get_u16 (const uint8_t *addr);
170
- static inline uint16_t get_u16_bump (const uint8_t *&addr);
171
191
inline size_align get_size_align (const uint8_t *&addr);
172
192
173
193
private:
@@ -226,7 +246,8 @@ class type_param {
226
246
const type_param *params; // subparameters
227
247
228
248
// Creates type parameters from an object shape description.
229
- static type_param *from_obj_shape (const uint8_t *sp, arena &arena);
249
+ static type_param *from_obj_shape (const uint8_t *sp, ptr dp,
250
+ arena &arena);
230
251
231
252
template <typename T>
232
253
inline void set (ctxt<T> *cx) {
@@ -284,20 +305,6 @@ ctxt<T>::walk_reset(bool align) {
284
305
sp = old_sp;
285
306
}
286
307
287
- template <typename T>
288
- uint16_t
289
- ctxt<T>::get_u16(const uint8_t *addr) {
290
- return *reinterpret_cast <const uint16_t *>(addr);
291
- }
292
-
293
- template <typename T>
294
- uint16_t
295
- ctxt<T>::get_u16_bump(const uint8_t *&addr) {
296
- uint16_t result = get_u16 (addr);
297
- addr += sizeof (uint16_t );
298
- return result;
299
- }
300
-
301
308
template <typename T>
302
309
size_align
303
310
ctxt<T>::get_size_align(const uint8_t *&addr) {
@@ -892,17 +899,13 @@ data<T,U>::walk_obj_contents(bool align, ptr &dp) {
892
899
uint8_t *box_ptr = bump_dp<uint8_t *>(dp);
893
900
type_desc *subtydesc =
894
901
*reinterpret_cast <type_desc **>(box_ptr + sizeof (void *));
895
- ptr obj_closure_dp (* box_ptr + sizeof (void *));
902
+ ptr obj_closure_dp (box_ptr + sizeof (void *));
896
903
897
- // FIXME: Should be type_param::from_obj_shape() below.
898
904
arena arena;
899
- type_param *params = type_param::from_tydesc (subtydesc, arena);
905
+ type_param *params = type_param::from_obj_shape (subtydesc->shape ,
906
+ obj_closure_dp, arena);
900
907
T sub (*static_cast <T *>(this ), subtydesc->shape , params,
901
908
subtydesc->shape_tables , obj_closure_dp);
902
-
903
- print print (sub);
904
- print.walk (false );
905
-
906
909
sub.walk (true );
907
910
}
908
911
0 commit comments