Skip to content

Commit b64204e

Browse files
committed
---
yaml --- r: 1126 b: refs/heads/master c: ed1dddc h: refs/heads/master v: v3
1 parent 966b499 commit b64204e

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 399929ba0bfd02b458d99bac7ef49b0e50731754
2+
refs/heads/master: ed1dddc33f2dfb6f9247ae877e64fead5642f360

trunk/src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ TEST_XFAILS_SELF := $(filter-out \
553553
rec-auto.rs \
554554
rec-tup.rs \
555555
return-nil.rs \
556+
simple-obj.rs \
556557
type-in-nested-module.rs \
557558
tup.rs \
558559
u32-decr.rs \

trunk/src/comp/middle/trans.rs

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,23 @@ fn iter_structural_ty(@block_ctxt cx,
812812
-> result {
813813
let result r = res(cx, C_nil());
814814

815+
fn iter_boxpp(@block_ctxt cx,
816+
ValueRef box_cell,
817+
val_and_ty_fn f) -> result {
818+
auto box_ptr = cx.build.Load(box_cell);
819+
auto tnil = typeck.plain_ty(typeck.ty_nil);
820+
auto tbox = typeck.plain_ty(typeck.ty_box(tnil));
821+
822+
auto inner_cx = new_sub_block_ctxt(cx, "iter box");
823+
auto next_cx = new_sub_block_ctxt(cx, "next");
824+
auto null_test = cx.build.IsNull(box_ptr);
825+
cx.build.CondBr(null_test, next_cx.llbb, inner_cx.llbb);
826+
827+
auto r = f(inner_cx, box_ptr, tbox);
828+
r.bcx.build.Br(next_cx.llbb);
829+
ret res(next_cx, r.val);
830+
}
831+
815832
alt (t.struct) {
816833
case (typeck.ty_tup(?args)) {
817834
let int i = 0;
@@ -919,20 +936,14 @@ fn iter_structural_ty(@block_ctxt cx,
919936
cx.build.GEP(v,
920937
vec(C_int(0),
921938
C_int(abi.fn_field_box)));
922-
auto box_ptr = cx.build.Load(box_cell);
923-
auto tnil = typeck.plain_ty(typeck.ty_nil);
924-
auto tbox = typeck.plain_ty(typeck.ty_box(tnil));
925-
ret f(cx, box_ptr, tbox);
939+
ret iter_boxpp(cx, box_cell, f);
926940
}
927941
case (typeck.ty_obj(_)) {
928942
auto box_cell =
929943
cx.build.GEP(v,
930944
vec(C_int(0),
931945
C_int(abi.obj_field_box)));
932-
auto box_ptr = cx.build.Load(box_cell);
933-
auto tnil = typeck.plain_ty(typeck.ty_nil);
934-
auto tbox = typeck.plain_ty(typeck.ty_box(tnil));
935-
ret f(cx, box_ptr, tbox);
946+
ret iter_boxpp(cx, box_cell, f);
936947
}
937948
case (_) {
938949
cx.fcx.ccx.sess.unimpl("type in iter_structural_ty");
@@ -2447,7 +2458,14 @@ impure fn trans_obj(@crate_ctxt cx, &ast._obj ob, ast.def_id oid,
24472458
auto pair_vtbl = bcx.build.GEP(pair,
24482459
vec(C_int(0),
24492460
C_int(abi.obj_field_vtbl)));
2461+
auto pair_box = bcx.build.GEP(pair,
2462+
vec(C_int(0),
2463+
C_int(abi.obj_field_box)));
24502464
bcx.build.Store(vtbl, pair_vtbl);
2465+
2466+
// FIXME: allocate the object body, copy the args in, etc.
2467+
bcx.build.Store(C_null(T_ptr(T_box(T_nil()))), pair_box);
2468+
24512469
bcx.build.Ret(bcx.build.Load(pair));
24522470
}
24532471

0 commit comments

Comments
 (0)