fix(ir): 修改了一下context的管理

This commit is contained in:
jing
2026-03-11 23:04:28 +08:00
parent fab6983d40
commit 0e5a75eaf3
13 changed files with 112 additions and 106 deletions

View File

@@ -39,14 +39,14 @@ void IRGenImpl::GenVarDecl(SysYParser::VarDeclContext& decl) {
if (storage_map_.find(&decl) != storage_map_.end()) {
throw std::runtime_error("[irgen] 声明重复生成存储槽位");
}
auto* slot = builder_.CreateAllocaI32(ir::DefaultContext().NextTemp());
auto* slot = builder_.CreateAllocaI32(module_.context().NextTemp());
storage_map_[&decl] = slot;
ir::Value* init = nullptr;
if (decl.exp()) {
init = GenExpr(*decl.exp());
} else {
init = ir::DefaultContext().GetConstInt(0);
init = builder_.CreateConstInt(0);
}
builder_.CreateStore(init, slot);
}