diff options
| author | Eugen Wissner <belka@caraus.de> | 2026-07-24 21:28:33 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2026-07-25 02:22:34 +0200 |
| commit | 1e0f89df48ba10cdde80bd623b84e20fb48b977d (patch) | |
| tree | 58f550342ff7ef42e506131b5c04a35ffdeb4a00 /boot/name_analysis.cc | |
| parent | 6301c1f2f669b84a429e836888629873721e7219 (diff) | |
| download | elna-1e0f89df48ba10cdde80bd623b84e20fb48b977d.tar.gz | |
Accept any constant types in case labels
Diffstat (limited to 'boot/name_analysis.cc')
| -rw-r--r-- | boot/name_analysis.cc | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/boot/name_analysis.cc b/boot/name_analysis.cc index 1e224da..07f6d31 100644 --- a/boot/name_analysis.cc +++ b/boot/name_analysis.cc @@ -303,7 +303,7 @@ namespace elna::boot * Collects field names from a record type recursively, base first. */ static void collect_field_names(const type& composite_type, - std::map<std::string, field_origin>& names) + ordered_map<field_origin>& names) { auto record = resolve_underlying_type(composite_type).get<record_type>(); if (record == nullptr) @@ -316,24 +316,25 @@ namespace elna::boot } for (auto& field : record->fields) { - names.insert({ field.first, field_origin{ .declaration = std::nullopt, .base_type = composite_type } }); + names.insert(field.first, field_origin{ .declaration = std::nullopt, .base_type = composite_type }); } } - std::vector<type_field> name_analysis_visitor::build_composite_type( + ordered_map<type> name_analysis_visitor::build_composite_type( const std::vector<field_declaration>& fields, - std::map<std::string, field_origin>& field_names, + ordered_map<field_origin>& field_names, const type& aggregate) { - std::vector<type_field> result; + ordered_map<type> result; for (const auto& field : fields) { field.second->accept(this); for (const auto& field_name : field.first) { - auto existing = field_names.find(field_name.name()); - if (existing != field_names.end()) + auto [existing, inserted] = field_names.insert(field_name.name(), + field_origin{ .declaration = field.second->position(), .base_type = type() }); + if (!inserted) { std::optional<std::string> base_name; @@ -351,9 +352,7 @@ namespace elna::boot } else { - field_names.insert({ field_name.name(), - field_origin{ .declaration = field.second->position(), .base_type = type() } }); - result.emplace_back(field_name.name(), this->current_type); + result.insert(field_name.name(), this->current_type); } } } @@ -394,7 +393,7 @@ namespace elna::boot result_type = std::make_shared<record_type>(); } - std::map<std::string, field_origin> field_names; + ordered_map<field_origin> field_names; collect_field_names(result_type->base, field_names); result_type->fields = build_composite_type(expression->fields, field_names, type(result_type)); |
