This repository has been archived on 2024-03-07. You can view files and clone it, but cannot push or open issues/pull-requests.
wongola/lib/SymTable.hpp

40 lines
825 B
C++

#ifndef wg_SYMTABLE_HPP
#define wg_SYMTABLE_HPP
#include <llvm/IR/Type.h>
#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<std::string, SymEntry> m_entries;
};
}
#endif