diff options
| author | Patrick Walton <[email protected]> | 2011-03-18 16:04:16 -0700 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2011-03-18 16:04:16 -0700 |
| commit | 8ff77b14a933a6ca5c8275e6f08ae26ea803107b (patch) | |
| tree | e3d2fe19da82aa813d394dd3e7c1ec206c82f0c2 | |
| parent | rustc: Fix list.foldl() to pass its second argument by alias (diff) | |
| download | rust-8ff77b14a933a6ca5c8275e6f08ae26ea803107b.tar.xz rust-8ff77b14a933a6ca5c8275e6f08ae26ea803107b.zip | |
rustc: Make iter_sequence() work with generic vectors
| -rw-r--r-- | src/comp/middle/trans.rs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 90a26cc5..718f152b 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -2066,8 +2066,15 @@ fn iter_sequence_inner(@block_ctxt cx, @block_ctxt cx, ValueRef dst, ValueRef src) -> result { - auto llty = type_of(cx.fcx.ccx, elt_ty); - auto p = cx.build.PointerCast(src, T_ptr(llty)); + auto llptrty; + if (!ty.type_has_dynamic_size(elt_ty)) { + auto llty = type_of(cx.fcx.ccx, elt_ty); + llptrty = T_ptr(llty); + } else { + llptrty = T_ptr(T_ptr(T_i8())); + } + + auto p = cx.build.PointerCast(src, llptrty); ret f(cx, load_scalar_or_boxed(cx, p, elt_ty), elt_ty); } @@ -2094,7 +2101,13 @@ fn iter_sequence(@block_ctxt cx, auto lenptr = cx.build.GEP(v, vec(C_int(0), C_int(abi.vec_elt_fill))); - auto llunit_ty = type_of(cx.fcx.ccx, elt_ty); + auto llunit_ty; + if (ty.type_has_dynamic_size(elt_ty)) { + llunit_ty = T_i8(); + } else { + llunit_ty = type_of(cx.fcx.ccx, elt_ty); + } + auto bcx = cx; auto len = bcx.build.Load(lenptr); |