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

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