#ifndef wg_SYMTABLE_HPP #define wg_SYMTABLE_HPP #include #include "commons.hpp" #include "Loc.hpp" namespace wg { WG_ERROR(symbol_error); struct SymEntry { std::string name; llvm::Type* type; bool prototype = false; }; class SymTable { public: explicit SymTable(); virtual ~SymTable(); bool exists(std::string const& name) const; void declare_prototype(std::string const& name, llvm::Type* type, Loc const& loc); void declare(std::string const& name, llvm::Type* type, Loc const& loc); void set(std::string const& name, llvm::Type* type, Loc const& loc); SymEntry& get(std::string const& name, Loc const& loc); private: std::unordered_map m_entries; }; } #endif