style(ir): 纠正代码位置

This commit is contained in:
jing
2026-03-11 22:08:27 +08:00
parent 62dde8d7ab
commit fab6983d40
17 changed files with 193 additions and 88 deletions

View File

@@ -1,16 +1,24 @@
// 极简符号表:记录局部变量是否定义。
// 极简符号表:记录局部变量定义
#pragma once
#include <string>
#include <unordered_map>
#include "SysYParser.h"
class SymbolTable {
public:
void Add(const std::string& name) { table_[name] = true; }
void Add(const std::string& name, SysYParser::VarDeclContext* decl) {
table_[name] = decl;
}
bool Contains(const std::string& name) const {
return table_.find(name) != table_.end();
}
SysYParser::VarDeclContext* Lookup(const std::string& name) const {
auto it = table_.find(name);
return it == table_.end() ? nullptr : it->second;
}
private:
std::unordered_map<std::string, bool> table_;
std::unordered_map<std::string, SysYParser::VarDeclContext*> table_;
};