From a6939784f806d32c890e38abfbca430c89caac55 Mon Sep 17 00:00:00 2001 From: Sofia Date: Thu, 9 Apr 2026 17:17:57 +0300 Subject: [PATCH] Codegen binops, kind-of --- src/codegen.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/codegen.cpp b/src/codegen.cpp index c7e406c..f6c1ae3 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -23,8 +23,15 @@ namespace AST { } llvm::Value* BinaryOperationExpression::codegen(codegen::Builder& builder, codegen::Scope& scope) { - auto ty = builder.builder->getInt32Ty(); - return llvm::ConstantInt::get(ty, 0); + auto lhs = this->m_lhs->codegen(builder, scope); + auto rhs = this->m_rhs->codegen(builder, scope); + switch (this->m_binop) { + case BinOp::Assignment: + builder.builder->CreateStore(rhs, lhs, false); + return lhs; + default: + throw std::runtime_error("invalid binop"); + } } void ReturnStatement::codegen(codegen::Builder& builder, codegen::Scope& scope) {