elna/source/symboltable.cpp

101 lines
1.9 KiB
C++

#include "elna/source/symboltable.hpp"
namespace elna::source
{
name_collision::name_collision(const std::string& name, const position current, const position previous)
: error(current), name(name), previous(previous)
{
}
std::string name_collision::what() const
{
return "Name '" + name + "' was already defined";
}
std::shared_ptr<info> symbol_table::lookup(const std::string& name)
{
auto entry = entries.find(name);
if (entry == entries.cend())
{
return nullptr;
}
else
{
return entry->second;
}
}
void symbol_table::enter(const std::string& name, std::shared_ptr<info> entry)
{
entries.insert_or_assign(name, entry);
}
info::~info()
{
}
info::info()
{
}
constant_info::constant_info(const std::int32_t value)
: m_value(value)
{
}
constant_info::~constant_info()
{
}
std::int32_t constant_info::value() const noexcept
{
return m_value;
}
variable_info::variable_info(std::size_t offset)
: m_offset(offset)
{
}
variable_info::~variable_info()
{
}
std::size_t variable_info::offset() const noexcept
{
return m_offset;
}
void name_analysis_visitor::visit(declaration *declaration)
{
}
void name_analysis_visitor::visit(definition *definition)
{
}
void name_analysis_visitor::visit(bang_statement *statement)
{
}
void name_analysis_visitor::visit(compound_statement *statement)
{
}
void name_analysis_visitor::visit(block *block)
{
}
void name_analysis_visitor::visit(integer_literal *number)
{
}
void name_analysis_visitor::visit(variable_expression *variable)
{
}
void name_analysis_visitor::visit(binary_expression *expression)
{
}
}