refactor(irgen): 完善irgen代码和文档,提升扩展兼容性
This commit is contained in:
@@ -22,27 +22,25 @@ class IRGenImpl {
|
||||
public:
|
||||
IRGenImpl(ir::Module& module, const SemanticContext& sema);
|
||||
|
||||
void Gen(SysYParser::CompUnitContext& cu);
|
||||
void Gen(SysYParser::CompUnitContext& cu);
|
||||
|
||||
private:
|
||||
void GenFuncDef(SysYParser::FuncDefContext& func);
|
||||
void GenBlock(SysYParser::BlockContext& block);
|
||||
void GenBlock(SysYParser::BlockStmtContext& block);
|
||||
bool GenBlockItem(SysYParser::BlockItemContext& item);
|
||||
void GenDecl(SysYParser::DeclContext& decl);
|
||||
bool GenStmt(SysYParser::StmtContext& stmt);
|
||||
void GenVarDecl(SysYParser::VarDeclContext& decl);
|
||||
void GenVarDef(SysYParser::VarDefContext& decl);
|
||||
void GenReturnStmt(SysYParser::ReturnStmtContext& ret);
|
||||
|
||||
ir::Value* GenExpr(SysYParser::ExpContext& expr);
|
||||
ir::Value* GenAddExpr(SysYParser::AddExpContext& add);
|
||||
ir::Value* GenPrimary(SysYParser::PrimaryContext& primary);
|
||||
|
||||
ir::Module& module_;
|
||||
const SemanticContext& sema_;
|
||||
ir::Function* func_;
|
||||
ir::IRBuilder builder_;
|
||||
// 名称绑定由 Sema 负责;IRGen 只维护“声明 -> 存储槽位”的代码生成状态。
|
||||
std::unordered_map<SysYParser::VarDeclContext*, ir::Value*> storage_map_;
|
||||
std::unordered_map<SysYParser::VarDefContext*, ir::Value*> storage_map_;
|
||||
};
|
||||
|
||||
std::unique_ptr<ir::Module> GenerateIR(SysYParser::CompUnitContext& tree,
|
||||
|
||||
Reference in New Issue
Block a user