aboutsummaryrefslogtreecommitdiff
path: root/src/comp/middle
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-10-22 19:23:10 -0700
committerGraydon Hoare <[email protected]>2010-10-22 19:23:10 -0700
commitd4497e481e99af8806f78deaeb60c67cb88eb5c5 (patch)
tree756702d2918c6effec5f2473788e91146ea4b550 /src/comp/middle
parentMore fire-fighting. (diff)
downloadrust-d4497e481e99af8806f78deaeb60c67cb88eb5c5.tar.xz
rust-d4497e481e99af8806f78deaeb60c67cb88eb5c5.zip
Extremely broken hacked-up incorrect attempt at 'ret'.
Diffstat (limited to 'src/comp/middle')
-rw-r--r--src/comp/middle/trans.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index cc1af53f..b80ddbea 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -811,6 +811,22 @@ fn trans_check_expr(@block_ctxt cx, &ast.expr e) -> result {
ret res(next_cx, C_nil());
}
+fn trans_ret(@block_ctxt cx, &option[@ast.expr] e) -> result {
+ auto r = res(cx, C_nil());
+ alt (e) {
+ case (some[@ast.expr](?x)) {
+ r = trans_expr(cx, *x);
+ r.bcx.build.Store(r.val, cx.fcx.lloutptr);
+ }
+ }
+ // FIXME: if we actually ret here, the block structure falls apart;
+ // need to do something more-clever with terminators and block cleanup.
+ // Mean time 'ret' means 'copy result to output slot and keep going'.
+
+ // r.val = r.bcx.build.RetVoid();
+ ret r;
+}
+
fn trans_stmt(@block_ctxt cx, &ast.stmt s) -> result {
auto sub = res(cx, C_nil());
alt (s.node) {
@@ -822,6 +838,10 @@ fn trans_stmt(@block_ctxt cx, &ast.stmt s) -> result {
sub.bcx = trans_check_expr(cx, *a).bcx;
}
+ case (ast.stmt_ret(?e)) {
+ sub.bcx = trans_ret(cx, e).bcx;
+ }
+
case (ast.stmt_expr(?e)) {
sub.bcx = trans_expr(cx, *e).bcx;
}