fix(ir): 修改了一下context的管理
This commit is contained in:
@@ -20,7 +20,10 @@ void VerifyFunctionStructure(const ir::Function& func) {
|
||||
} // namespace
|
||||
|
||||
IRGenImpl::IRGenImpl(ir::Module& module, const SemanticContext& sema)
|
||||
: module_(module), sema_(sema), func_(nullptr), builder_(nullptr) {}
|
||||
: module_(module),
|
||||
sema_(sema),
|
||||
func_(nullptr),
|
||||
builder_(module.context(), nullptr) {}
|
||||
|
||||
void IRGenImpl::Gen(SysYParser::CompUnitContext& cu) {
|
||||
if (!cu.funcDef()) {
|
||||
@@ -37,7 +40,9 @@ void IRGenImpl::GenFuncDef(SysYParser::FuncDefContext& func) {
|
||||
throw std::runtime_error("[irgen] 缺少函数名");
|
||||
}
|
||||
|
||||
func_ = module_.CreateFunction(func.Ident()->getText(), ir::Type::Int32());
|
||||
func_ = module_.CreateFunction(
|
||||
func.Ident()->getText(),
|
||||
std::make_shared<ir::Type>(ir::Type::Kind::Int32));
|
||||
builder_.SetInsertPoint(func_->entry());
|
||||
storage_map_.clear();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user