// 维护对象符号的多层作用域。
#pragma once

#include <string>
#include <string_view>
#include <unordered_map>
#include <vector>

#include "sem/Sema.h"

class SymbolTable {
 public:
  SymbolTable();

  void EnterScope();
  void ExitScope();

  bool Add(const ObjectBinding& symbol);
  bool ContainsInCurrentScope(std::string_view name) const;
  const ObjectBinding* Lookup(std::string_view name) const;
  size_t Depth() const;

 private:
  std::vector<std::unordered_map<std::string, ObjectBinding>> scopes_;
};
