35 lines
629 B
C++
35 lines
629 B
C++
#ifndef zn_SYMTABLE_HPP
|
|
#define zn_SYMTABLE_HPP
|
|
|
|
#include "common.hpp"
|
|
#include "Prototype.hpp"
|
|
|
|
namespace zn
|
|
{
|
|
struct Sym {
|
|
std::string name;
|
|
size_t addr;
|
|
std::shared_ptr<Prototype> prototype = nullptr;
|
|
};
|
|
|
|
class SymTable
|
|
{
|
|
public:
|
|
explicit SymTable();
|
|
virtual ~SymTable();
|
|
|
|
void declare(std::string const& name, size_t addr);
|
|
|
|
void declare_function(std::string const& name,
|
|
size_t addr,
|
|
std::shared_ptr<Prototype> prototype);
|
|
|
|
std::optional<Sym> find(std::string const& name);
|
|
|
|
private:
|
|
std::vector<Sym> m_syms;
|
|
};
|
|
}
|
|
|
|
#endif
|