fakir/src/SymEntry.hpp

61 lines
1.6 KiB
C++
Raw Normal View History

2023-09-20 15:17:13 +00:00
#ifndef fk_SYMENTRY_HPP
#define fk_SYMENTRY_HPP
#include "commons.hpp"
#include "Loc.hpp"
2023-09-23 22:40:08 +00:00
#include "types.hpp"
2023-09-20 15:17:13 +00:00
namespace fk
{
2023-09-21 13:59:46 +00:00
class Node;
2023-09-20 15:17:13 +00:00
class SymEntry
{
public:
explicit SymEntry(std::string const& name,
addr_t addr,
bool is_global,
2023-09-21 13:59:46 +00:00
int scope,
std::shared_ptr<Node> parent,
2023-09-20 15:17:13 +00:00
Loc const& loc);
virtual ~SymEntry();
std::string name() const { return m_name; }
addr_t addr() const { return m_addr; }
bool is_global() const { return m_is_global; }
2023-09-21 13:59:46 +00:00
int scope() const { return m_scope; }
std::shared_ptr<Node> parent() const { return m_parent; }
std::shared_ptr<Node> node() const { return m_node; }
2023-09-20 15:17:13 +00:00
Loc loc() const { return m_loc; }
size_t arity() const { return m_arity; }
2023-09-23 22:40:08 +00:00
bool is_array() const { return m_is_array; }
2023-09-20 15:17:13 +00:00
SymEntry& set_global(bool global) { m_is_global = global; return *this; }
SymEntry& set_addr(addr_t addr) { m_addr = addr; return *this; }
SymEntry& set_arity(size_t arity) { m_arity = arity; return *this; }
2023-09-23 22:40:08 +00:00
SymEntry& set_is_array(bool is_array)
{ m_is_array = is_array; return *this;}
SymEntry& set_parent(std::shared_ptr<Node> parent)
{ m_parent = parent; return *this; }
SymEntry& set_node(std::shared_ptr<Node> node)
{ m_node = node; return *this; }
2023-09-20 15:17:13 +00:00
2023-09-23 22:40:08 +00:00
2023-09-20 15:17:13 +00:00
std::string string() const;
private:
std::string m_name;
addr_t m_addr;
bool m_is_global = false;
2023-09-21 13:59:46 +00:00
int m_scope;
std::shared_ptr<Node> m_parent;
std::shared_ptr<Node> m_node;
2023-09-20 15:17:13 +00:00
Loc m_loc;
size_t m_arity = 0;
2023-09-23 22:40:08 +00:00
bool m_is_array = false;
2023-09-20 15:17:13 +00:00
};
}
#endif