diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-09-28 10:35:44 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-09-28 10:35:44 +0900 |
| commit | 931cbe657ccdcfefe4077cd7371f1ea4ad4e5b53 (patch) | |
| tree | fe0950e80e3ff1a6a559ac4b169a6991131816a9 /src/codegen.c | |
| parent | 86ae353d6267387bf216d5fd760a7ced7bced402 (diff) | |
| download | ducc-931cbe657ccdcfefe4077cd7371f1ea4ad4e5b53.tar.gz ducc-931cbe657ccdcfefe4077cd7371f1ea4ad4e5b53.tar.zst ducc-931cbe657ccdcfefe4077cd7371f1ea4ad4e5b53.zip | |
feat: implement |=, &=, ^=, <<= and >>= operators
Diffstat (limited to 'src/codegen.c')
| -rw-r--r-- | src/codegen.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/codegen.c b/src/codegen.c index 716660d..cc3f9a7 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -292,6 +292,18 @@ static void codegen_assign_expr_helper(CodeGen* g, AstNode* ast) { fprintf(g->out, " cqo\n"); fprintf(g->out, " idiv rdi\n"); fprintf(g->out, " mov rax, rdx\n"); + } else if (ast->node_op == TokenKind_assign_or) { + fprintf(g->out, " or rax, rdi\n"); + } else if (ast->node_op == TokenKind_assign_and) { + fprintf(g->out, " and rax, rdi\n"); + } else if (ast->node_op == TokenKind_assign_xor) { + fprintf(g->out, " xor rax, rdi\n"); + } else if (ast->node_op == TokenKind_assign_lshift) { + fprintf(g->out, " mov rcx, rdi\n"); + fprintf(g->out, " shl rax, cl\n"); + } else if (ast->node_op == TokenKind_assign_rshift) { + fprintf(g->out, " mov rcx, rdi\n"); + fprintf(g->out, " sar rax, cl\n"); } else { unreachable(); } |
