diff options
| author | Graydon Hoare <[email protected]> | 2010-11-30 16:31:43 -0800 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2010-11-30 16:32:00 -0800 |
| commit | 45043374ff4d4eb48bed52ff8f8251f9cddf239a (patch) | |
| tree | 7a6e5d2114776a896f5d1f7c70f89f1d68ff1781 /src/comp/middle/trans.rs | |
| parent | rustc: Add def ids to variants (diff) | |
| download | rust-45043374ff4d4eb48bed52ff8f8251f9cddf239a.tar.xz rust-45043374ff4d4eb48bed52ff8f8251f9cddf239a.zip | |
Tidy up structural types for rec, tup AST and typeck nodes.
Diffstat (limited to 'src/comp/middle/trans.rs')
| -rw-r--r-- | src/comp/middle/trans.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index d5b73826..bc580166 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -1197,15 +1197,15 @@ impure fn trans_call(@block_ctxt cx, @ast.expr f, args_res._0.build.FastCall(f_res._0.val, args_res._1)); } -impure fn trans_tup(@block_ctxt cx, vec[tup(ast.mutability, @ast.expr)] args, +impure fn trans_tup(@block_ctxt cx, vec[ast.elt] elts, &ast.ann ann) -> result { auto ty = node_type(cx.fcx.ccx, ann); auto tup_val = cx.build.Alloca(ty); let int i = 0; auto r = res(cx, C_nil()); - for (tup(ast.mutability, @ast.expr) arg in args) { - auto t = typeck.expr_ty(arg._1); - auto src_res = trans_expr(r.bcx, arg._1); + for (ast.elt e in elts) { + auto t = typeck.expr_ty(e.expr); + auto src_res = trans_expr(r.bcx, e.expr); auto dst_elt = r.bcx.build.GEP(tup_val, vec(C_int(0), C_int(i))); // FIXME: calculate copy init-ness in typestate. r = copy_ty(src_res.bcx, true, dst_elt, src_res.val, t); @@ -1214,21 +1214,21 @@ impure fn trans_tup(@block_ctxt cx, vec[tup(ast.mutability, @ast.expr)] args, ret res(r.bcx, tup_val); } -impure fn trans_rec(@block_ctxt cx, vec[tup(ast.ident, @ast.expr)] args, +impure fn trans_rec(@block_ctxt cx, vec[ast.field] fields, &ast.ann ann) -> result { auto ty = node_type(cx.fcx.ccx, ann); - auto tup_val = cx.build.Alloca(ty); + auto rec_val = cx.build.Alloca(ty); let int i = 0; auto r = res(cx, C_nil()); - for (tup(ast.ident, @ast.expr) arg in args) { - auto t = typeck.expr_ty(arg._1); - auto src_res = trans_expr(r.bcx, arg._1); - auto dst_elt = r.bcx.build.GEP(tup_val, vec(C_int(0), C_int(i))); + for (ast.field f in fields) { + auto t = typeck.expr_ty(f.expr); + auto src_res = trans_expr(r.bcx, f.expr); + auto dst_elt = r.bcx.build.GEP(rec_val, vec(C_int(0), C_int(i))); // FIXME: calculate copy init-ness in typestate. r = copy_ty(src_res.bcx, true, dst_elt, src_res.val, t); i += 1; } - ret res(r.bcx, tup_val); + ret res(r.bcx, rec_val); } |