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 /boot/symbol.cc | |
| parent | 74e75e41fe12f19e5365a3152ffafa1a29376240 (diff) | |
| download | elna-f7b035a505e86ad916a43ab1dc1a662a6066b011.tar.gz | |
Move module heading to the top
Diffstat (limited to 'boot/symbol.cc')
| -rw-r--r-- | boot/symbol.cc | 112 |
1 files changed, 59 insertions, 53 deletions
diff --git a/boot/symbol.cc b/boot/symbol.cc index 962808a..54cb595 100644 --- a/boot/symbol.cc +++ b/boot/symbol.cc @@ -67,77 +67,80 @@ namespace elna::boot bool type::operator==(const type& other) const { - type const resolved_this = resolve_aliases(*this); - type const resolved_that = resolve_aliases(other); + const type resolved_this = resolve_aliases(*this); + const type resolved_that = resolve_aliases(other); - if (auto left_record = resolved_this.get<record_type>()) + if (const auto left_record = resolved_this.get<record_type>()) { return left_record == resolved_that.get<record_type>(); } - if (auto left_primitive = resolved_this.get<primitive_type>()) + else if (const auto left_primitive = resolved_this.get<primitive_type>()) { - auto right_primitive = resolved_that.get<primitive_type>(); + const std::shared_ptr<primitive_type> right_primitive = resolved_that.get<primitive_type>(); return right_primitive != nullptr && left_primitive->identifier == right_primitive->identifier; } - if (auto left_enumeration = resolved_this.get<enumeration_type>()) + else if (const auto left_enumeration = resolved_this.get<enumeration_type>()) { return left_enumeration == resolved_that.get<enumeration_type>(); } - if (auto left_extern = resolved_this.get<extern_type>()) + else if (const auto left_extern = resolved_this.get<extern_type>()) { return left_extern == resolved_that.get<extern_type>(); } - if (auto left_pointer = resolved_this.get<pointer_type>()) + else if (const auto left_pointer = resolved_this.get<pointer_type>()) { - auto right_pointer = resolved_that.get<pointer_type>(); + const std::shared_ptr<pointer_type> right_pointer = resolved_that.get<pointer_type>(); return right_pointer != nullptr && left_pointer->base == right_pointer->base; } - if (auto left_const = resolved_this.get<constant_type>()) + else if (const auto left_const = resolved_this.get<constant_type>()) { - auto right_const = resolved_that.get<constant_type>(); + const std::shared_ptr<constant_type> right_const = resolved_that.get<constant_type>(); return right_const != nullptr && left_const->unqualified == right_const->unqualified; } - if (auto left_array = resolved_this.get<array_type>()) + else if (const auto left_array = resolved_this.get<array_type>()) { - auto right_array = resolved_that.get<array_type>(); + const std::shared_ptr<array_type> right_array = resolved_that.get<array_type>(); return right_array != nullptr && left_array->size == right_array->size && left_array->base == right_array->base; } - if (auto left_slice = resolved_this.get<slice_type>()) + else if (const auto left_slice = resolved_this.get<slice_type>()) { - auto right_slice = resolved_that.get<slice_type>(); + const std::shared_ptr<slice_type> right_slice = resolved_that.get<slice_type>(); return right_slice != nullptr && left_slice->base == right_slice->base; } - if (auto left_procedure = resolved_this.get<procedure_type>()) + else if (const auto left_procedure = resolved_this.get<procedure_type>()) { - auto right_procedure = resolved_that.get<procedure_type>(); + const std::shared_ptr<procedure_type> right_procedure = resolved_that.get<procedure_type>(); return right_procedure != nullptr && left_procedure->return_type == right_procedure->return_type && left_procedure->parameters == right_procedure->parameters && left_procedure->variadic == right_procedure->variadic; } - if (auto left_parameter = resolved_this.get<parameter_type>()) + else if (const auto left_parameter = resolved_this.get<parameter_type>()) { return left_parameter == resolved_that.get<parameter_type>(); } - if (auto left_generic = resolved_this.get<generic_type>()) + else if (const auto left_generic = resolved_this.get<generic_type>()) { return left_generic == resolved_that.get<generic_type>(); } - if (auto left_instance = resolved_this.get<instantiated_type>()) + else if (const auto left_instance = resolved_this.get<instantiated_type>()) { - auto right_instance = resolved_that.get<instantiated_type>(); + const std::shared_ptr<instantiated_type> right_instance = resolved_that.get<instantiated_type>(); return right_instance != nullptr && left_instance->generic == right_instance->generic && left_instance->arguments == right_instance->arguments; } - return resolved_this.empty() && resolved_that.empty(); + else + { + return resolved_this.empty() && resolved_that.empty(); + } } type::operator bool() const @@ -378,14 +381,14 @@ namespace elna::boot // matching the machine word. if (bit_size == properties.front().size * CHAR_BIT) { - auto alias = std::make_shared<alias_type>(integer_name, variant_type); + const std::shared_ptr<alias_type> alias = std::make_shared<alias_type>(integer_name, variant_type); symbols->enter(integer_name, std::make_shared<type_info>(type(alias))); } } if (!symbols->contains(integer_name)) { - auto variant_type = type(std::make_shared<primitive_type>(integer_name, properties.front())); + const type variant_type = type(std::make_shared<primitive_type>(integer_name, properties.front())); symbols->enter(integer_name, std::make_shared<type_info>(variant_type)); } @@ -489,14 +492,14 @@ namespace elna::boot std::shared_ptr<alias_type> symbol_bag::declared(const std::string& symbol_name) { - auto unresolved_alias = this->unresolved.find(symbol_name); + const auto unresolved_alias = this->unresolved.find(symbol_name); return unresolved_alias == this->unresolved.end() ? std::shared_ptr<alias_type>() : unresolved_alias->second; } std::shared_ptr<alias_type> symbol_bag::resolve(const std::string& symbol_name, type& resolution) { - auto unresolved_node = this->unresolved.extract(symbol_name); + const auto unresolved_node = this->unresolved.extract(symbol_name); assert(!unresolved_node.empty()); auto unresolved_declaration = unresolved_node.mapped(); @@ -563,7 +566,7 @@ namespace elna::boot { type resolved_alias = resolve_aliases(alias); - if (auto qualified = resolved_alias.get<constant_type>()) + if (const auto qualified = resolved_alias.get<constant_type>()) { return resolve_underlying_type(qualified->unqualified); } @@ -575,7 +578,7 @@ namespace elna::boot type unwrap_aliases(const type& checked) { - if (auto alias = checked.get<alias_type>()) + if (const auto alias = checked.get<alias_type>()) { return unwrap_aliases(alias->referent); } @@ -590,7 +593,7 @@ namespace elna::boot type substitute(const type& subject, const std::vector<type>& parameters, const std::vector<type>& arguments) { - if (auto parameter = subject.get<parameter_type>()) + if (const auto parameter = subject.get<parameter_type>()) { for (std::size_t i = 0; i < parameters.size() && i < arguments.size(); ++i) { @@ -601,27 +604,27 @@ namespace elna::boot } return subject; } - if (auto pointer = subject.get<pointer_type>()) + else if (const auto pointer = subject.get<pointer_type>()) { return type(std::make_shared<pointer_type>( substitute(pointer->base, parameters, arguments))); } - if (auto slice = subject.get<slice_type>()) + else if (const auto slice = subject.get<slice_type>()) { return type(std::make_shared<slice_type>( substitute(slice->base, parameters, arguments))); } - if (auto array = subject.get<array_type>()) + else if (const auto array = subject.get<array_type>()) { return type(std::make_shared<array_type>( substitute(array->base, parameters, arguments), array->size)); } - if (auto qualified = subject.get<constant_type>()) + else if (const auto qualified = subject.get<constant_type>()) { return type(std::make_shared<constant_type>( substitute(qualified->unqualified, parameters, arguments))); } - if (auto procedure = subject.get<procedure_type>()) + else if (const auto procedure = subject.get<procedure_type>()) { procedure_type::return_t result_return = procedure->return_type; @@ -630,7 +633,7 @@ namespace elna::boot result_return = procedure_type::return_t( substitute(result_return.proper_type, parameters, arguments)); } - auto result = std::make_shared<procedure_type>(std::move(result_return)); + const std::shared_ptr<procedure_type> result = std::make_shared<procedure_type>(std::move(result_return)); result->variadic = procedure->variadic; result->parameters.reserve(procedure->parameters.size()); @@ -640,7 +643,7 @@ namespace elna::boot } return type(result); } - if (auto instance = subject.get<instantiated_type>()) + else if (const auto instance = subject.get<instantiated_type>()) { std::vector<type> substituted; @@ -667,17 +670,20 @@ namespace elna::boot { type resolved = resolve_underlying_type(checked); - if (auto instance = resolved.get<instantiated_type>()) + if (const auto instance = resolved.get<instantiated_type>()) { std::shared_ptr<generic_type> const generic = unwrap_generic(instance->generic); return generic == nullptr ? type() : resolve_underlying_type(generic->referent); } - if (auto generic = resolved.get<generic_type>()) + else if (const auto generic = resolved.get<generic_type>()) { return resolve_underlying_type(generic->referent); } - return resolved; + else + { + return resolved; + } } /* @@ -686,13 +692,13 @@ namespace elna::boot */ static type substitute_from(const type& subject, const type& taken) { - auto instance = subject.get<instantiated_type>(); + const std::shared_ptr<instantiated_type> instance = subject.get<instantiated_type>(); if (instance == nullptr) { return taken; } - std::shared_ptr<generic_type> const generic = unwrap_generic(instance->generic); + const std::shared_ptr<generic_type> generic = unwrap_generic(instance->generic); return generic == nullptr ? type() @@ -702,7 +708,7 @@ namespace elna::boot type base_of(const type& derived) { const type resolved = resolve_underlying_type(derived); - auto record = erase_generic(resolved).get<record_type>(); + const std::shared_ptr<record_type> record = erase_generic(resolved).get<record_type>(); return record == nullptr || record->base.empty() ? type() @@ -723,13 +729,13 @@ namespace elna::boot type resolve_aliases(const type& checked) { - if (auto alias = checked.get<alias_type>()) + if (const auto alias = checked.get<alias_type>()) { return resolve_aliases(alias->referent); } - if (auto instance = checked.get<instantiated_type>()) + else if (const auto instance = checked.get<instantiated_type>()) { - std::shared_ptr<generic_type> const generic = unwrap_generic(instance->generic); + const std::shared_ptr<generic_type> generic = unwrap_generic(instance->generic); // A record referent makes the instantiation nominal, so resolution // stops here and Stack#[^File] stays distinct from Stack#[^Socket]. @@ -744,7 +750,7 @@ namespace elna::boot bool is_primitive_type(const type& checked, const std::string& name) { - if (auto primitive_checked = checked.get<primitive_type>()) + if (const auto primitive_checked = checked.get<primitive_type>()) { return primitive_checked->identifier == name; } @@ -753,7 +759,7 @@ namespace elna::boot bool is_integer_type(const type& checked) { - if (auto primitive_checked = checked.get<primitive_type>()) + if (const auto primitive_checked = checked.get<primitive_type>()) { return primitive_checked->identifier.starts_with("Int"); } @@ -762,7 +768,7 @@ namespace elna::boot bool is_word_type(const type& checked) { - if (auto primitive_checked = checked.get<primitive_type>()) + if (const auto primitive_checked = checked.get<primitive_type>()) { return primitive_checked->identifier.starts_with("Word"); } @@ -811,9 +817,9 @@ namespace elna::boot bool is_string_type(const type& checked) { - if (auto slice = checked.get<slice_type>()) + if (const auto slice = checked.get<slice_type>()) { - if (auto base = resolve_aliases(slice->base).get<constant_type>()) + if (const auto base = resolve_aliases(slice->base).get<constant_type>()) { return is_primitive_type(resolve_aliases(base->unqualified), "Word8"); } @@ -823,11 +829,11 @@ namespace elna::boot type get_range_base_type(const type& range) { - if (auto array = range.get<array_type>()) + if (const auto array = range.get<array_type>()) { return array->base; } - else if (auto slice = range.get<slice_type>()) + else if (const auto slice = range.get<slice_type>()) { return slice->base; } @@ -838,7 +844,7 @@ namespace elna::boot { const type resolved_type = resolve_underlying_type(composite_type); - if (auto record = erase_generic(resolved_type).get<record_type>()) + if (const auto record = erase_generic(resolved_type).get<record_type>()) { for (const auto& [name, field] : record->fields) { |
