aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPatrick Walton <[email protected]>2010-12-03 12:31:25 -0800
committerPatrick Walton <[email protected]>2010-12-03 12:35:49 -0800
commit5347cac92d0d44b5f1ca2f3b742a3786b62335d7 (patch)
treefc97740bd27696d7559c32ede7a6297b7464e28b /src
parentTrim whitespace. (diff)
downloadrust-5347cac92d0d44b5f1ca2f3b742a3786b62335d7.tar.xz
rust-5347cac92d0d44b5f1ca2f3b742a3786b62335d7.zip
rustc: Handle n-ary tag constructors in iter_structural_ty (which lets us process their refcounts correctly)
Diffstat (limited to 'src')
-rw-r--r--src/comp/middle/trans.rs27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 86adb040..378c01c2 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -604,15 +604,28 @@ fn iter_structural_ty(@block_ctxt cx,
alt (variant._1) {
case (n_ary) {
- // FIXME: broken at the moment, causes type_is_binding
- // errors; need to unpack the fn type returned by
- // ann_to_type.
let vec[ValueRef] vals = vec(C_int(0), C_int(1),
C_int(i as int));
- auto llfld = r.bcx.build.GEP(v, vals);
- auto ty = typeck.ann_to_type(variants.(i).ann);
- r = f(variant_cx, llfld, ty);
- r.bcx.build.Br(next_cx.llbb);
+ auto llvar = variant_cx.build.GEP(v, vals);
+
+ auto fn_ty = typeck.ann_to_type(variants.(i).ann);
+ alt (fn_ty.struct) {
+ case (typeck.ty_fn(?args, _)) {
+ auto j = 0u;
+ for (typeck.arg a in args) {
+ auto idx = vec(C_int(0), C_int(j as int));
+ auto llfp = variant_cx.build.GEP(llvar,
+ idx);
+ auto llfld = variant_cx.build.Load(llfp);
+ auto res = f(variant_cx, llfld, a.ty);
+ variant_cx = res.bcx;
+ j += 1u;
+ }
+ }
+ case (_) { fail; }
+ }
+
+ variant_cx.build.Br(next_cx.llbb);
}
case (nullary) {
// Nothing to do.