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 /include | |
| parent | 74b1bee5415aefba988002319f374abb6a95380a (diff) | |
| download | elna-4d4537866690a1ef3d882f5e9a6e01d8220a3650.tar.gz | |
Make type_info alias owner
Diffstat (limited to 'include')
| -rw-r--r-- | include/elna/boot/dependency.h | 6 | ||||
| -rw-r--r-- | include/elna/boot/symbol.h | 9 |
2 files changed, 8 insertions, 7 deletions
diff --git a/include/elna/boot/dependency.h b/include/elna/boot/dependency.h index bcd0035..028dcf1 100644 --- a/include/elna/boot/dependency.h +++ b/include/elna/boot/dependency.h @@ -142,10 +142,6 @@ namespace elna::boot // Modules being compiled right now. Used to detect circular imports. std::unordered_set<std::filesystem::path> in_progress; - // The builtin table stores global aliases (such as Int, Word) as weak - // pointers, so the state keeps their owners alive. - std::vector<std::shared_ptr<alias_type>> alias_owners; - public: const std::shared_ptr<symbol_table> globals; T custom; @@ -153,7 +149,7 @@ namespace elna::boot using const_iterator = std::unordered_map<std::filesystem::path, symbol_bag>::const_iterator; explicit dependency_state(T custom, const target_info& target) - : globals(builtin_symbol_table(target, this->alias_owners)), custom(std::move(custom)) + : globals(builtin_symbol_table(target)), custom(std::move(custom)) { } diff --git a/include/elna/boot/symbol.h b/include/elna/boot/symbol.h index e67f0f7..46fb9e2 100644 --- a/include/elna/boot/symbol.h +++ b/include/elna/boot/symbol.h @@ -352,6 +352,12 @@ namespace elna::boot explicit type_info(const type& symbol); std::shared_ptr<type_info> is_type() override; + + private: + // Strong owner of the alias if \c symbol is an alias. Aliases are + // stored weakly in \c type, so the owning type_info keeps them alive + // for the whole lifetime of the symbol table. + const std::shared_ptr<alias_type> owner; }; /** @@ -413,8 +419,7 @@ namespace elna::boot std::shared_ptr<variable_info> is_variable() override; }; - 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); /** * Symbol bag contains: |
