fix continue in do-while

This commit is contained in:
Yaossg 2025-04-14 19:52:51 +08:00
parent 04a58f8dec
commit 6b00b2bff9

6
boot.c
View file

@ -1697,15 +1697,17 @@ void parse_for() {
}
void parse_do_while() {
int body_label = next_label();
int cont_label = next_label();
int break_label = next_label();
asm_push_label(break_label, cont_label);
asm_label(cont_label);
asm_label(body_label);
parse_stmt(); // body
expect_token(TOKEN_WHILE);
expect_token(TOKEN_PAREN_LEFT);
asm_label(cont_label);
int cond = parse_expr();
asm_bnez(cond, cont_label);
asm_bnez(cond, body_label);
expect_token(TOKEN_PAREN_RIGHT);
asm_label(break_label);
asm_pop_label();