From 98ec95d69cf425774339c8ea6f3c257234f93851 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Thu, 6 Mar 2025 22:59:41 +0100 Subject: [PATCH] Unify the build_type function --- gcc/elna-generic.cc | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/gcc/elna-generic.cc b/gcc/elna-generic.cc index 3ee4f94..f9303e2 100644 --- a/gcc/elna-generic.cc +++ b/gcc/elna-generic.cc @@ -79,7 +79,16 @@ namespace gcc { if (auto alias_node = type_expression->is_primitive()) { - return this->unresolved.at(alias_node->name); + auto unresolved_alias = this->unresolved.find(alias_node->name); + + if (unresolved_alias != this->unresolved.end()) + { + return unresolved_alias->second; + } + else + { + return new boot::primitive_type(alias_node->name); + } } else if (auto alias_node = type_expression->is_record()) { @@ -112,27 +121,7 @@ namespace gcc { auto unresolved_declaration = this->unresolved.at(type->identifier); - if (auto alias_node = type->body().is_primitive()) - { - auto unresolved_alias = this->unresolved.find(alias_node->name); - - if (unresolved_alias != this->unresolved.end()) - { - unresolved_declaration->reference = unresolved_alias->second; - } - else - { - unresolved_declaration->reference = new boot::primitive_type(alias_node->name); - } - } - else if (auto alias_node = type->body().is_record()) - { - unresolved_declaration->reference = build_record(alias_node.get()); - } - else if (auto alias_node = type->body().is_union()) - { - unresolved_declaration->reference = build_union(alias_node.get()); - } + unresolved_declaration->reference = build_type(&type->body()); } for (auto unresolved : this->unresolved) {