提交 47cfeba4 编写于 作者: M Marijn Haverbeke

Add cases for iface values to rust_shape.h

They appear to log okay now, but I can't promise much beyond that.

@pcwalton If you feel like taking a look, I'd be grateful. Interfaces are
boxes containing a (tydesc, dict, value_of_any_type) tuple, where the leading
tydesc describes the whole tuple.

Issue #1437
上级 9fa74916
......@@ -51,6 +51,7 @@ const uint8_t SHAPE_OBJ = 19u;
const uint8_t SHAPE_RES = 20u;
const uint8_t SHAPE_VAR = 21u;
const uint8_t SHAPE_UNIQ = 22u;
const uint8_t SHAPE_IFACE = 24u;
#ifdef _LP64
const uint8_t SHAPE_PTR = SHAPE_U64;
......@@ -382,6 +383,7 @@ ctxt<T>::walk() {
case SHAPE_RES: walk_res(); break;
case SHAPE_VAR: walk_var(); break;
case SHAPE_UNIQ: walk_uniq(); break;
case SHAPE_IFACE: WALK_SIMPLE(walk_iface); break;
default: abort();
}
}
......@@ -566,6 +568,7 @@ public:
void walk_fn() { DPRINT("fn"); }
void walk_obj() { DPRINT("obj"); }
void walk_iface() { DPRINT("iface"); }
void walk_closure();
template<typename T>
......@@ -611,6 +614,7 @@ public:
void walk_box() { sa.set(sizeof(void *), sizeof(void *)); }
void walk_fn() { sa.set(sizeof(void *)*2, sizeof(void *)); }
void walk_obj() { sa.set(sizeof(void *)*2, sizeof(void *)); }
void walk_iface() { sa.set(sizeof(void *), sizeof(void *)); }
void walk_closure();
void walk_vec(bool is_pod, uint16_t sp_size) {
......@@ -819,6 +823,7 @@ protected:
void walk_uniq_contents();
void walk_fn_contents(ptr &dp);
void walk_obj_contents(ptr &dp);
void walk_iface_value(ptr &dp);
void walk_variant(tag_info &tinfo, tag_variant_t variant);
static std::pair<uint8_t *,uint8_t *> get_vec_data_range(ptr dp);
......@@ -863,6 +868,8 @@ public:
dp = next_dp;
}
void walk_iface() { DATA_SIMPLE(void *, walk_iface()); }
void walk_res(const rust_fn *dtor, unsigned n_params,
const type_param *params, const uint8_t *end_sp) {
typename U::template data<uintptr_t>::t live = bump_dp<uintptr_t>(dp);
......@@ -989,6 +996,20 @@ data<T,U>::walk_obj_contents(ptr &dp) {
sub.walk();
}
template<typename T,typename U>
void
data<T,U>::walk_iface_value(ptr &dp) {
uint8_t *box_ptr = bump_dp<uint8_t *>(dp);
if (!box_ptr) return;
uint8_t *body_ptr = box_ptr + sizeof(void*);
type_desc *valtydesc =
*reinterpret_cast<type_desc **>(body_ptr);
ptr value_dp(body_ptr + sizeof(void*) * 2);
T sub(*static_cast<T *>(this), valtydesc->shape + 2, NULL, NULL,
value_dp);
sub.align = true;
sub.walk();
}
// Polymorphic logging, for convenience
......@@ -1073,6 +1094,13 @@ private:
data<log,ptr>::walk_obj_contents(dp);
}
void walk_iface() {
out << prefix << "iface(";
prefix = "";
data<log,ptr>::walk_iface_value(dp);
out << prefix << ")";
}
void walk_subcontext(log &sub) { sub.walk(); }
void walk_box_contents(log &sub, ptr &ref_count_dp) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册