style(ir): 纠正代码位置
This commit is contained in:
@@ -4,21 +4,12 @@
|
||||
#include <stdexcept>
|
||||
|
||||
#include "SysYParser.h"
|
||||
#include "antlr4-runtime.h"
|
||||
#include "ir/IR.h"
|
||||
|
||||
std::unique_ptr<ir::Module> GenerateIR(antlr4::tree::ParseTree* tree) {
|
||||
if (!tree) {
|
||||
throw std::runtime_error("[irgen] 语法树为空");
|
||||
}
|
||||
|
||||
auto* cu = dynamic_cast<SysYParser::CompUnitContext*>(tree);
|
||||
if (!cu) {
|
||||
throw std::runtime_error("[irgen] 语法树根节点不是 compUnit");
|
||||
}
|
||||
|
||||
std::unique_ptr<ir::Module> GenerateIR(SysYParser::CompUnitContext& tree,
|
||||
const SemanticContext& sema) {
|
||||
auto module = std::make_unique<ir::Module>();
|
||||
IRGenImpl gen(*module);
|
||||
gen.Gen(*cu);
|
||||
IRGenImpl gen(*module, sema);
|
||||
gen.Gen(tree);
|
||||
return module;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user