refactor(irgen): IR改成alloca和store形式

This commit is contained in:
jing
2026-03-01 15:36:50 +08:00
parent 29bf99727f
commit 730280abb8
10 changed files with 180 additions and 10 deletions

View File

@@ -18,7 +18,8 @@ ir::Value* IRGenImpl::GenExpr(const ast::Expr& expr) {
if (it == locals_.end()) {
throw std::runtime_error("变量未找到: " + var->name);
}
return it->second;
std::string name = ir::DefaultContext().NextTemp();
return builder_.CreateLoad(it->second, name);
}
if (auto bin = dynamic_cast<const ast::BinaryExpr*>(&expr)) {
auto* lhs = GenExpr(*bin->lhs);