IR生成文件即IRGenxx设计
This commit is contained in:
@@ -1,4 +1,19 @@
|
||||
// 这是一个“可跑”的最小 IR 生成示例,便于对照/调试。
|
||||
// IR 生成驱动(Driver):
|
||||
// - 驱动 Visitor 遍历 AST,调度各子模块完成翻译
|
||||
// - 统一管理模块级翻译入口与上下文(Module/IRBuilder 等)
|
||||
// - 组织函数/语句/表达式/声明等翻译流程
|
||||
|
||||
#include "irgen/IRGen.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "ast/AstNodes.h"
|
||||
#include "ir/IR.h"
|
||||
|
||||
std::unique_ptr<ir::Module> GenerateIR(const ast::CompUnit& ast) {
|
||||
auto module = std::make_unique<ir::Module>();
|
||||
IRGenImpl gen(*module);
|
||||
gen.Gen(ast);
|
||||
return module;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user