40 lines
825 B
C++
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
|