#include "irgen/IRGen.h" #include #include #include "SysYParser.h" #include "antlr4-runtime.h" #include "ir/IR.h" std::unique_ptr GenerateIR(antlr4::tree::ParseTree* tree) { if (!tree) { throw std::runtime_error("[irgen] parse tree 为空"); } auto* cu = dynamic_cast(tree); if (!cu) { throw std::runtime_error("[irgen] parse tree 根节点不是 compUnit"); } auto module = std::make_unique(); IRGenImpl gen(*module); gen.Gen(*cu); return module; }