about summary refs log tree commit diff
path: root/src/comp
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2010-12-03 12:31:25 -0800
committerPatrick Walton <pcwalton@mimiga.net>2010-12-03 12:35:49 -0800
commit5347cac92d0d44b5f1ca2f3b742a3786b62335d7 (patch)
treefc97740bd27696d7559c32ede7a6297b7464e28b /src/comp
parent4316df63231dbf9c698e1bf464f7cecafea54a0c (diff)
downloadrust-5347cac92d0d44b5f1ca2f3b742a3786b62335d7.tar.gz
rust-5347cac92d0d44b5f1ca2f3b742a3786b62335d7.zip
rustc: Handle n-ary tag constructors in iter_structural_ty (which lets us process their refcounts correctly)
Diffstat (limited to 'src/comp')
-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 86adb0406b4..378c01c2a7e 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.