Skip to content

Grab bag #302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions src/comp/front/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1558,39 +1558,6 @@ impure fn parse_source_stmt(parser p) -> @ast.stmt {
ret @spanned(lo, hi, ast.stmt_decl(decl));
}

// Handle the (few) block-expr stmts first.

case (token.IF) {
auto e = parse_expr(p);
ret @spanned(lo, e.span, ast.stmt_expr(e));
}

case (token.FOR) {
auto e = parse_expr(p);
ret @spanned(lo, e.span, ast.stmt_expr(e));
}

case (token.WHILE) {
auto e = parse_expr(p);
ret @spanned(lo, e.span, ast.stmt_expr(e));
}

case (token.DO) {
auto e = parse_expr(p);
ret @spanned(lo, e.span, ast.stmt_expr(e));
}

case (token.ALT) {
auto e = parse_expr(p);
ret @spanned(lo, e.span, ast.stmt_expr(e));
}

case (token.LBRACE) {
auto e = parse_expr(p);
ret @spanned(lo, e.span, ast.stmt_expr(e));
}


case (_) {
if (peeking_at_item(p)) {
// Might be a local item decl.
Expand Down
30 changes: 24 additions & 6 deletions src/comp/middle/trans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1668,7 +1668,7 @@ fn make_take_glue(@block_ctxt cx, ValueRef v, @ty.t t) -> result {

} else if (ty.type_is_structural(t)) {
ret iter_structural_ty(cx, v, t,
bind incr_all_refcnts(_, _, _));
bind take_ty(_, _, _));
}
ret res(cx, C_nil());
}
Expand Down Expand Up @@ -2315,7 +2315,7 @@ fn call_tydesc_glue(@block_ctxt cx, ValueRef v, @ty.t t, int field) {
call_tydesc_glue_full(td.bcx, v, td.val, field);
}

fn incr_all_refcnts(@block_ctxt cx,
fn take_ty(@block_ctxt cx,
ValueRef v,
@ty.t t) -> result {
if (!ty.type_is_scalar(t)) {
Expand Down Expand Up @@ -2397,15 +2397,15 @@ fn copy_ty(@block_ctxt cx,
ret res(cx, C_nil());

} else if (ty.type_is_boxed(t)) {
auto r = incr_all_refcnts(cx, src, t);
auto r = take_ty(cx, src, t);
if (action == DROP_EXISTING) {
r = drop_ty(r.bcx, r.bcx.build.Load(dst), t);
}
ret res(r.bcx, r.bcx.build.Store(src, dst));

} else if (ty.type_is_structural(t) ||
ty.type_has_dynamic_size(t)) {
auto r = incr_all_refcnts(cx, src, t);
auto r = take_ty(cx, src, t);
if (action == DROP_EXISTING) {
r = drop_ty(r.bcx, dst, t);
}
Expand Down Expand Up @@ -3063,7 +3063,18 @@ fn trans_if(@block_ctxt cx, @ast.expr cond,
auto expr_llty;
alt (els) {
case (some[@ast.expr](?elexpr)) {
else_res = trans_expr(else_cx, elexpr);
alt (elexpr.node) {
case (ast.expr_if(_, _, _, _)) {
else_res = trans_expr(else_cx, elexpr);
}
case (ast.expr_block(?blk, _)) {
// Calling trans_block directly instead of trans_expr
// because trans_expr will create another scope block
// context for the block, but we've already got the
// 'else' context
else_res = trans_block(else_cx, blk);
}
}

// If we have an else expression, then the entire
// if expression can have a non-nil type.
Expand Down Expand Up @@ -4617,7 +4628,14 @@ fn trans_expr(@block_ctxt cx, @ast.expr e) -> result {
}

case (ast.expr_block(?blk, _)) {
ret trans_block(cx, blk);
auto sub_cx = new_scope_block_ctxt(cx, "block-expr body");
auto next_cx = new_sub_block_ctxt(cx, "next");
auto sub = trans_block(sub_cx, blk);

cx.build.Br(sub_cx.llbb);
sub.bcx.build.Br(next_cx.llbb);

ret res(next_cx, sub.val);
}

case (ast.expr_assign(?dst, ?src, ?ann)) {
Expand Down