Skip to content

Commit

Permalink
codegen labels
Browse files Browse the repository at this point in the history
  • Loading branch information
omdxp committed Sep 1, 2024
1 parent 291a8e8 commit b3858a4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1843,6 +1843,10 @@ void codegen_generate_goto_stmt(struct node *node) {
asm_push("jmp label_%s", node->stmt._goto.label->sval);
}

void codegen_generate_label(struct node *node) {
asm_push("label_%s:", node->label.name->sval);
}

void codegen_generate_statement(struct node *node, struct history *history) {
switch (node->type) {
case NODE_TYPE_VARIABLE:
Expand Down Expand Up @@ -1900,6 +1904,10 @@ void codegen_generate_statement(struct node *node, struct history *history) {
case NODE_TYPE_STATEMENT_GOTO:
codegen_generate_goto_stmt(node);
break;

case NODE_TYPE_LABEL:
codegen_generate_label(node);
break;
}

codegen_discard_unused_stack();
Expand Down

0 comments on commit b3858a4

Please sign in to comment.