diff options
| author | Eugen Wissner <belka@caraus.de> | 2026-09-24 00:39:51 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2026-09-24 00:39:51 +0200 |
| commit | f7b035a505e86ad916a43ab1dc1a662a6066b011 (patch) | |
| tree | a54369ae8ad56352d148c4583ab568f7d4869d30 /include | |
| parent | 74e75e41fe12f19e5365a3152ffafa1a29376240 (diff) | |
| download | elna-f7b035a505e86ad916a43ab1dc1a662a6066b011.tar.gz | |
Move module heading to the top
Diffstat (limited to 'include')
| -rw-r--r-- | include/elna/boot/ast.h | 8 | ||||
| -rw-r--r-- | include/elna/boot/dependency.h | 5 | ||||
| -rw-r--r-- | include/elna/boot/driver.h | 8 | ||||
| -rw-r--r-- | include/elna/boot/result.h | 24 | ||||
| -rw-r--r-- | include/elna/boot/symbol.h | 4 | ||||
| -rw-r--r-- | include/elna/boot/type_check.h | 6 |
6 files changed, 34 insertions, 21 deletions
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<import_declaration *> imports; const std::vector<declaration *> declarations; - std::optional<procedure_body> entry_point; + std::optional<std::vector<statement *>> entry_point; const std::vector<identifier> parameters; const std::optional<source_position> entry_position; @@ -1088,7 +1088,7 @@ namespace elna::boot std::vector<declaration *>&& declarations, std::vector<identifier>&& parameters, const source_position entry_position, - std::optional<procedure_body>&& body); + std::vector<statement *>&& 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 <concepts> #include <filesystem> -#include <fstream> +#include <istream> #include <unordered_set> #include <variant> #include <vector> @@ -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<unit> 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<unit> 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<iterator, bool> 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<iterator, bool> 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<std::size_t> alignment; - field_info(type field_type = type(), std::optional<std::size_t> alignment = std::nullopt); + explicit field_info(type field_type = type(), std::optional<std::size_t> 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; |
