style(ir): 纠正代码位置
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "SysYParser.h"
|
||||
#include "ir/IR.h"
|
||||
#include "sem/Sema.h"
|
||||
|
||||
namespace antlr4 {
|
||||
namespace tree {
|
||||
@@ -25,7 +26,7 @@ class Value;
|
||||
|
||||
class IRGenImpl {
|
||||
public:
|
||||
explicit IRGenImpl(ir::Module& module);
|
||||
IRGenImpl(ir::Module& module, const SemanticContext& sema);
|
||||
|
||||
void Gen(SysYParser::CompUnitContext& cu);
|
||||
|
||||
@@ -43,10 +44,12 @@ class IRGenImpl {
|
||||
ir::Value* GenPrimary(SysYParser::PrimaryContext& primary);
|
||||
|
||||
ir::Module& module_;
|
||||
const SemanticContext& sema_;
|
||||
ir::Function* func_;
|
||||
ir::IRBuilder builder_;
|
||||
// 当前只维护函数级局部变量表;若后续引入嵌套块作用域,需要改成作用域栈。
|
||||
std::unordered_map<std::string, ir::Value*> locals_;
|
||||
// 名称绑定由 Sema 负责;IRGen 只维护“声明 -> 存储槽位”的代码生成状态。
|
||||
std::unordered_map<SysYParser::VarDeclContext*, ir::Value*> storage_map_;
|
||||
};
|
||||
|
||||
std::unique_ptr<ir::Module> GenerateIR(antlr4::tree::ParseTree* tree);
|
||||
std::unique_ptr<ir::Module> GenerateIR(SysYParser::CompUnitContext& tree,
|
||||
const SemanticContext& sema);
|
||||
|
||||
Reference in New Issue
Block a user