// 维护局部变量声明的注册与查找。

#include "sem/SymbolTable.h"

void SymbolTable::Add(const std::string& name,
                      SysYParser::VarDeclContext* decl) {
  table_[name] = decl;
}

bool SymbolTable::Contains(const std::string& name) const {
  return table_.find(name) != table_.end();
}

SysYParser::VarDeclContext* SymbolTable::Lookup(const std::string& name) const {
  auto it = table_.find(name);
  return it == table_.end() ? nullptr : it->second;
}
