elna/source/symboltable.cpp

101 lines
1.9 KiB
C++
Raw Normal View History

2024-03-09 08:36:07 +01:00
#include "elna/source/symboltable.hpp"
namespace elna::source
{
2024-03-10 08:50:55 +01:00
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";
}
2024-03-09 08:36:07 +01:00
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;
}
2024-03-10 08:50:55 +01:00
variable_info::variable_info(std::size_t offset)
: m_offset(offset)
{
}
2024-03-09 08:36:07 +01:00
variable_info::~variable_info()
{
}
2024-03-10 08:50:55 +01:00
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)
2024-03-09 08:36:07 +01:00
{
}
2024-03-10 08:50:55 +01:00
void name_analysis_visitor::visit(compound_statement *statement)
2024-03-09 08:36:07 +01:00
{
}
2024-03-10 08:50:55 +01:00
void name_analysis_visitor::visit(block *block)
2024-03-09 08:36:07 +01:00
{
}
2024-03-10 08:50:55 +01:00
void name_analysis_visitor::visit(integer_literal *number)
2024-03-09 08:36:07 +01:00
{
}
2024-03-10 08:50:55 +01:00
void name_analysis_visitor::visit(variable_expression *variable)
2024-03-09 08:36:07 +01:00
{
}
2024-03-10 08:50:55 +01:00
void name_analysis_visitor::visit(binary_expression *expression)
2024-03-09 08:36:07 +01:00
{
}
}