From f7b035a505e86ad916a43ab1dc1a662a6066b011 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Thu, 24 Sep 2026 00:39:51 +0200 Subject: Move module heading to the top --- include/elna/boot/ast.h | 8 ++++---- include/elna/boot/dependency.h | 5 +++-- include/elna/boot/driver.h | 8 ++++++-- include/elna/boot/result.h | 24 +++++++++++++----------- include/elna/boot/symbol.h | 4 ++-- include/elna/boot/type_check.h | 6 ++++++ 6 files changed, 34 insertions(+), 21 deletions(-) (limited to 'include') diff --git a/include/elna/boot/ast.h b/include/elna/boot/ast.h index 52461e6..4a0cdb0 100644 --- a/include/elna/boot/ast.h +++ b/include/elna/boot/ast.h @@ -687,7 +687,7 @@ namespace elna::boot { expression *return_expression{ nullptr }; - procedure_body(block&& body, expression *return_expression = nullptr); + explicit procedure_body(block&& body, expression *return_expression = nullptr); procedure_body(procedure_body&& that) noexcept = default; virtual ~procedure_body() = default; @@ -1076,7 +1076,7 @@ namespace elna::boot public: const std::vector imports; const std::vector declarations; - std::optional entry_point; + std::optional> entry_point; const std::vector parameters; const std::optional entry_position; @@ -1088,7 +1088,7 @@ namespace elna::boot std::vector&& declarations, std::vector&& parameters, const source_position entry_position, - std::optional&& body); + std::vector&& body); void accept(parser_visitor *visitor) override; @@ -1157,7 +1157,7 @@ namespace elna::boot class empty_statement : public statement { public: - empty_statement(const source_position); + explicit empty_statement(const source_position); void accept(parser_visitor *visitor) override; }; diff --git a/include/elna/boot/dependency.h b/include/elna/boot/dependency.h index a87503e..7bd3de9 100644 --- a/include/elna/boot/dependency.h +++ b/include/elna/boot/dependency.h @@ -23,7 +23,7 @@ along with GCC; see the file COPYING3. If not see #include #include -#include +#include #include #include #include @@ -250,7 +250,8 @@ namespace elna::boot dependency compile(const std::filesystem::path& key, Loader& loader, const target_info& target, const bool imported = false) { - auto cached = this->cache.find(key); + const auto cached = this->cache.find(key); + if (cached != this->cache.cend()) { return {}; diff --git a/include/elna/boot/driver.h b/include/elna/boot/driver.h index e918954..6bcfa9e 100644 --- a/include/elna/boot/driver.h +++ b/include/elna/boot/driver.h @@ -38,10 +38,14 @@ namespace elna::boot class driver final : public diagnostic_container { public: - std::unique_ptr tree; /// Set once the module terminator has been parsed. The lexer stops /// scanning then, so whatever follows is not program text. - bool finished{ false }; + std::unique_ptr tree; + + /** + * \return Whenever module terminator has been parsed. + */ + bool has_finished() const; driver() = default; }; diff --git a/include/elna/boot/result.h b/include/elna/boot/result.h index a8ad73b..d0a550a 100644 --- a/include/elna/boot/result.h +++ b/include/elna/boot/result.h @@ -100,7 +100,7 @@ namespace elna::boot class diagnostic { protected: - diagnostic(const source_position position); + explicit diagnostic(const source_position position); public: virtual ~diagnostic() = default; @@ -716,7 +716,8 @@ namespace elna::boot */ iterator find(const key_type& key) { - auto search_result = this->index_map.find(key); + const auto search_result = this->index_map.find(key); + if (search_result == this->index_map.cend()) { return this->payload.end(); @@ -730,7 +731,8 @@ namespace elna::boot /// \overload const_iterator find(const key_type& key) const { - auto search_result = this->index_map.find(key); + const auto search_result = this->index_map.find(key); + if (search_result == this->index_map.cend()) { return this->payload.cend(); @@ -752,23 +754,23 @@ namespace elna::boot */ std::pair insert(const key_type& key, const mapped_type& value) { - auto insert_result = this->index_map.emplace(key, this->payload.size()); - if (insert_result.second) + const auto [at_position, inserted] = this->index_map.emplace(key, this->payload.size()); + if (inserted) { this->payload.emplace_back(key, value); } - return { this->payload.begin() + insert_result.first->second, insert_result.second }; + return { this->payload.begin() + at_position->second, inserted }; } /// \overload std::pair insert(const key_type& key, mapped_type&& value) { - auto insert_result = this->index_map.emplace(key, this->payload.size()); - if (insert_result.second) + const auto [at_position, inserted] = this->index_map.emplace(key, this->payload.size()); + if (inserted) { this->payload.emplace_back(key, std::move(value)); } - return { this->payload.begin() + insert_result.first->second, insert_result.second }; + return { this->payload.begin() + at_position->second, inserted }; } /** @@ -992,8 +994,8 @@ namespace elna::boot private: static constexpr std::size_t golden_ratio = 0x9e3779b9; - static constexpr int mix_shift_left = 6; - static constexpr int mix_shift_right = 2; + static constexpr unsigned int mix_shift_left = 6; + static constexpr unsigned int mix_shift_right = 2; std::size_t m_seed{ 0 }; }; diff --git a/include/elna/boot/symbol.h b/include/elna/boot/symbol.h index a5f7ca8..38aee08 100644 --- a/include/elna/boot/symbol.h +++ b/include/elna/boot/symbol.h @@ -182,7 +182,7 @@ namespace elna::boot /// type's own alignment. std::optional alignment; - field_info(type field_type = type(), std::optional alignment = std::nullopt); + explicit field_info(type field_type = type(), std::optional alignment = std::nullopt); }; struct record_type @@ -370,7 +370,7 @@ namespace elna::boot */ symbol_ptr lookup(const std::string& name) { - auto entry = entries.find(name); + const iterator entry = entries.find(name); if (entry != entries.cend()) { diff --git a/include/elna/boot/type_check.h b/include/elna/boot/type_check.h index 94f8961..620af74 100644 --- a/include/elna/boot/type_check.h +++ b/include/elna/boot/type_check.h @@ -253,7 +253,13 @@ namespace elna::boot }; context ctx; + /** + * Checks whether derived has base in its record parent chain. + * + * Base record type must not be null. Derived record type may be null. + */ verdict guard_const_laundering() const; + verdict check_exact_match() const; verdict check_pointer_hatch() const; verdict check_pointer_conversion() const; -- cgit v1.2.3