Document symbol bag class and methods

This commit is contained in:
2025-08-23 00:48:58 +02:00
parent 809e41bcc3
commit 8fc60202ff
9 changed files with 168 additions and 52 deletions

View File

@@ -238,6 +238,17 @@ namespace elna::gcc
DECL_EXTERNAL(fndecl) = info.symbols == nullptr;
}
tree declare_variable(const std::string& name, const boot::variable_info& info,
std::shared_ptr<symbol_table> symbols)
{
auto variable_type = get_inner_alias(info.symbol, symbols);
tree declaration_tree = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier(name.c_str()), variable_type);
symbols->enter(name, declaration_tree);
return declaration_tree;
}
void rewrite_symbol_table(std::shared_ptr<boot::symbol_table> info_table, std::shared_ptr<symbol_table> symbols)
{
for (auto& [symbol_name, symbol_info] : *info_table)
@@ -250,6 +261,10 @@ namespace elna::gcc
handle_symbol(symbol_name, alias_type, symbols);
}
}
else if (auto variable_info = symbol_info->is_variable())
{
declare_variable(symbol_name, *variable_info, symbols);
}
else if (auto procedure_info = symbol_info->is_procedure())
{
declare_procedure(symbol_name, *procedure_info, symbols);