aboutsummaryrefslogtreecommitdiff
path: root/src/comp/middle
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-10-22 19:35:48 -0700
committerGraydon Hoare <[email protected]>2010-10-22 19:35:48 -0700
commit3bf775e80feb8cf04c67d37dd2aa826ba4fa6111 (patch)
treedfd757a6c178367ef459b2dc5fb5d4224867b95d /src/comp/middle
parentCollect all fns first so decl order doesn't matter to translation. (diff)
downloadrust-3bf775e80feb8cf04c67d37dd2aa826ba4fa6111.tar.xz
rust-3bf775e80feb8cf04c67d37dd2aa826ba4fa6111.zip
Pass outptr as in rustboot. Probably need to revisit this ABI. Also disgusting hack employed. Please remove.
Diffstat (limited to 'src/comp/middle')
-rw-r--r--src/comp/middle/trans.rs23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index e778a6d4..07fcce04 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -657,21 +657,24 @@ fn trans_if(@block_ctxt cx, &ast.expr cond,
// (that is represented as an alloca, hence needs a 'load' to be
// used as an rval).
-fn trans_lval(@block_ctxt cx, &ast.expr e) -> tup(result, bool) {
+fn trans_lval(@block_ctxt cx, &ast.expr e)
+ -> tup(result, bool, ast.def_id) {
alt (e.node) {
case (ast.expr_name(?n, ?dopt, _)) {
alt (dopt) {
case (some[ast.def](?def)) {
alt (def) {
case (ast.def_arg(?did)) {
- ret tup(res(cx, cx.fcx.llargs.get(did)), false);
+ ret tup(res(cx, cx.fcx.llargs.get(did)),
+ false, did);
}
case (ast.def_local(?did)) {
- ret tup(res(cx, cx.fcx.lllocals.get(did)), true);
+ ret tup(res(cx, cx.fcx.lllocals.get(did)),
+ true, did);
}
case (ast.def_fn(?did)) {
ret tup(res(cx, cx.fcx.tcx.fn_ids.get(did)),
- false);
+ false, did);
}
case (_) {
cx.fcx.tcx.sess.unimpl("def variant in trans");
@@ -751,8 +754,18 @@ fn trans_expr(@block_ctxt cx, &ast.expr e) -> result {
case (ast.expr_call(?f, ?args, _)) {
auto f_res = trans_lval(cx, *f);
check (! f_res._1);
+
+ // FIXME: Revolting hack to get the type of the outptr. Can get a
+ // variety of other ways; will wait until we have a typechecker
+ // perhaps to pick a more tasteful one.
+ auto outptr = cx.fcx.lloutptr;
+ alt (cx.fcx.tcx.items.get(f_res._2).node) {
+ case (ast.item_fn(_, ?ff, _)) {
+ outptr = cx.build.Alloca(type_of(cx.fcx.tcx, ff.output));
+ }
+ }
auto args_res = trans_exprs(f_res._0.bcx, args);
- auto llargs = vec(cx.fcx.lloutptr,
+ auto llargs = vec(outptr,
cx.fcx.lltaskptr);
llargs += args_res._1;
ret res(args_res._0,