fix continue in do-while
This commit is contained in:
parent
04a58f8dec
commit
6b00b2bff9
1 changed files with 4 additions and 2 deletions
6
boot.c
6
boot.c
|
@ -1697,15 +1697,17 @@ void parse_for() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse_do_while() {
|
void parse_do_while() {
|
||||||
|
int body_label = next_label();
|
||||||
int cont_label = next_label();
|
int cont_label = next_label();
|
||||||
int break_label = next_label();
|
int break_label = next_label();
|
||||||
asm_push_label(break_label, cont_label);
|
asm_push_label(break_label, cont_label);
|
||||||
asm_label(cont_label);
|
asm_label(body_label);
|
||||||
parse_stmt(); // body
|
parse_stmt(); // body
|
||||||
expect_token(TOKEN_WHILE);
|
expect_token(TOKEN_WHILE);
|
||||||
expect_token(TOKEN_PAREN_LEFT);
|
expect_token(TOKEN_PAREN_LEFT);
|
||||||
|
asm_label(cont_label);
|
||||||
int cond = parse_expr();
|
int cond = parse_expr();
|
||||||
asm_bnez(cond, cont_label);
|
asm_bnez(cond, body_label);
|
||||||
expect_token(TOKEN_PAREN_RIGHT);
|
expect_token(TOKEN_PAREN_RIGHT);
|
||||||
asm_label(break_label);
|
asm_label(break_label);
|
||||||
asm_pop_label();
|
asm_pop_label();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue