You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
578 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// 这是一个“可跑”的最小 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;
}