aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/codegen.c12
-rw-r--r--src/parse.c3
2 files changed, 14 insertions, 1 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();
}
diff --git a/src/parse.c b/src/parse.c
index da1345d..ba9b7e5 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -801,7 +801,8 @@ static AstNode* parse_assignment_expr(Parser* p) {
TokenKind op = peek_token(p)->kind;
// TODO: check if the lhs is unary expression.
if (op == TokenKind_assign || op == TokenKind_assign_mul || op == TokenKind_assign_div ||
- op == TokenKind_assign_mod) {
+ op == TokenKind_assign_mod || op == TokenKind_assign_or || op == TokenKind_assign_and ||
+ op == TokenKind_assign_xor || op == TokenKind_assign_lshift || op == TokenKind_assign_rshift) {
next_token(p);
AstNode* rhs = parse_assignment_expr(p);
lhs = ast_new_assign_expr(op, lhs, rhs);