Skip to content

Commit d6f5344

Browse files
committed
---
yaml --- r: 878 b: refs/heads/master c: 16faef2 h: refs/heads/master v: v3
1 parent 10c5a51 commit d6f5344

File tree

5 files changed

+36
-13
lines changed

5 files changed

+36
-13
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 896570a3a9fe5c5e4a457f7cfea5917eb547d5ce
2+
refs/heads/master: 16faef2218ec5c3621079f04e6b093a5bb1b44c2

trunk/src/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,9 @@ TEST_XFAILS_X86 := $(TASK_XFAILS) \
447447
test/run-pass/mlist-cycle.rs \
448448
test/run-pass/obj-as.rs \
449449
test/run-pass/task-comm.rs \
450-
test/run-pass/vec-slice.rs \
451450
test/run-pass/task-comm-3.rs \
451+
test/run-pass/vec-slice.rs \
452+
test/run-pass/while-and-do-while.rs \
452453
test/run-fail/task-comm-14.rs \
453454
test/compile-fail/bad-recv.rs \
454455
test/compile-fail/bad-send.rs \

trunk/src/comp/front/parser.rs

+1
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,7 @@ impure fn parse_do_while_expr(parser p) -> @ast.expr {
636636
expect (p, token.LPAREN);
637637
auto cond = parse_expr(p);
638638
expect(p, token.RPAREN);
639+
expect(p, token.SEMI);
639640
hi = cond.span;
640641
ret @spanned(lo, hi, ast.expr_do_while(body, cond, ast.ann_none));
641642
}

trunk/src/comp/middle/trans.rs

+18-11
Original file line numberDiff line numberDiff line change
@@ -660,13 +660,15 @@ impure fn trans_while(@block_ctxt cx, &ast.expr cond,
660660
auto body_cx = new_empty_block_ctxt(cx.fcx);
661661
auto next_cx = new_extension_block_ctxt(cx);
662662

663-
cx.build.Br(cond_cx.llbb);
664-
auto cond_res = trans_expr(cond_cx, cond);
665-
cond_cx.build.CondBr(cond_res.val,
666-
body_cx.llbb,
667-
next_cx.llbb);
668663
auto body_res = trans_block(body_cx, body);
669-
body_cx.build.Br(cond_cx.llbb);
664+
auto cond_res = trans_expr(cond_cx, cond);
665+
666+
body_res.bcx.build.Br(cond_cx.llbb);
667+
cond_res.bcx.build.CondBr(cond_res.val,
668+
body_cx.llbb,
669+
next_cx.llbb);
670+
671+
cx.build.Br(cond_cx.llbb);
670672
ret res(next_cx, C_nil());
671673
}
672674

@@ -676,12 +678,13 @@ impure fn trans_do_while(@block_ctxt cx, &ast.block body,
676678
auto body_cx = new_empty_block_ctxt(cx.fcx);
677679
auto next_cx = new_extension_block_ctxt(cx);
678680

679-
cx.build.Br(body_cx.llbb);
680681
auto body_res = trans_block(body_cx, body);
681-
auto cond_res = trans_expr(body_cx, cond);
682-
body_cx.build.CondBr(cond_res.val,
683-
body_cx.llbb,
684-
next_cx.llbb);
682+
auto cond_res = trans_expr(body_res.bcx, cond);
683+
684+
cond_res.bcx.build.CondBr(cond_res.val,
685+
body_cx.llbb,
686+
next_cx.llbb);
687+
cx.build.Br(body_cx.llbb);
685688
ret res(next_cx, body_res.val);
686689
}
687690

@@ -759,6 +762,10 @@ impure fn trans_expr(@block_ctxt cx, &ast.expr e) -> result {
759762
ret trans_while(cx, *cond, body);
760763
}
761764

765+
case (ast.expr_do_while(?body, ?cond, _)) {
766+
ret trans_do_while(cx, body, *cond);
767+
}
768+
762769
case (ast.expr_block(?blk, _)) {
763770
auto sub_cx = new_empty_block_ctxt(cx.fcx);
764771
auto next_cx = new_extension_block_ctxt(cx);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
fn main() {
2+
let int x = 10;
3+
let int y = 0;
4+
while(y < x) {
5+
log y;
6+
log "hello";
7+
y = y + 1;
8+
}
9+
do {
10+
log "goodbye";
11+
x = x - 1;
12+
log x;
13+
} while (x > 0);
14+
}

0 commit comments

Comments
 (0)