Document symbol bag class and methods

This commit is contained in:
2025-08-23 00:48:58 +02:00
parent 809e41bcc3
commit fd3729ba16
13 changed files with 294 additions and 117 deletions

View File

@@ -87,7 +87,7 @@ namespace elna::gcc
tree definition_tree = build_decl(UNKNOWN_LOCATION, TYPE_DECL,
get_identifier(identifier.c_str()), type);
TREE_PUBLIC(definition_tree) = true;
TREE_PUBLIC(definition_tree) = 1;
if (is_unique_type(type))
{
TYPE_NAME(type) = DECL_NAME(definition_tree);
@@ -235,7 +235,21 @@ namespace elna::gcc
}
DECL_ARGUMENTS(fndecl) = argument_chain;
TREE_ADDRESSABLE(fndecl) = 1;
DECL_EXTERNAL(fndecl) = info.symbols == nullptr;
DECL_EXTERNAL(fndecl) = info.is_extern();
}
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);
TREE_ADDRESSABLE(declaration_tree) = 1;
DECL_EXTERNAL(declaration_tree) = info.is_extern;
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)
@@ -250,6 +264,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);