diff options
| author | Eugen Wissner <belka@caraus.de> | 2026-08-26 00:30:06 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2026-08-26 00:30:06 +0200 |
| commit | 4d4537866690a1ef3d882f5e9a6e01d8220a3650 (patch) | |
| tree | ece440e4dfdab7958280903792b8d360bc85f4c8 /boot | |
| parent | 74b1bee5415aefba988002319f374abb6a95380a (diff) | |
| download | elna-4d4537866690a1ef3d882f5e9a6e01d8220a3650.tar.gz | |
Make type_info alias owner
Diffstat (limited to 'boot')
| -rw-r--r-- | boot/symbol.cc | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/boot/symbol.cc b/boot/symbol.cc index fcafae4..8855d52 100644 --- a/boot/symbol.cc +++ b/boot/symbol.cc @@ -17,6 +17,7 @@ along with GCC; see the file COPYING3. If not see #include "elna/boot/symbol.h" +#include <cassert> #include <utility> namespace elna::boot @@ -256,7 +257,7 @@ namespace elna::boot } type_info::type_info(const type& symbol) - : symbol(symbol) + : symbol(symbol), owner(symbol.get<alias_type>()) { } @@ -293,8 +294,7 @@ namespace elna::boot static void builtin_integers(const std::shared_ptr<symbol_table>& symbols, const std::array<type_properties, target_integer_count>& properties, - const std::string& integer_name, - std::vector<std::shared_ptr<alias_type>>& alias_owners) + const std::string& integer_name) { for (std::size_t i = 1; i < properties.size(); ++i) { @@ -310,7 +310,6 @@ namespace elna::boot { auto alias = std::make_shared<alias_type>(integer_name, variant_type); - alias_owners.push_back(alias); symbols->enter(integer_name, std::make_shared<type_info>(type(alias))); } } @@ -322,13 +321,12 @@ namespace elna::boot } } - std::shared_ptr<symbol_table> builtin_symbol_table(const target_info& target, - std::vector<std::shared_ptr<alias_type>>& alias_owners) + std::shared_ptr<symbol_table> builtin_symbol_table(const target_info& target) { auto result = std::make_shared<symbol_table>(); - builtin_integers(result, target.int_properties, "Int", alias_owners); - builtin_integers(result, target.word_properties, "Word", alias_owners); + builtin_integers(result, target.int_properties, "Int"); + builtin_integers(result, target.word_properties, "Word"); result->enter("Char", std::make_shared<type_info>(type(std::make_shared<primitive_type>("Char", target.char_properties)))); @@ -403,9 +401,14 @@ namespace elna::boot std::shared_ptr<alias_type> symbol_bag::resolve(const std::string& symbol_name, type& resolution) { - auto unresolved_declaration = this->unresolved.at(symbol_name); + auto unresolved_node = this->unresolved.extract(symbol_name); + + assert(!unresolved_node.empty()); + auto unresolved_declaration = unresolved_node.mapped(); unresolved_declaration->referent = resolution; + // The alias is owned by the type_info the caller enters into the + // symbol table from now on. return unresolved_declaration; } |
