From 8ceb48a4e60b8ff89f28372da4f66cd152e2e0fe Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Mon, 13 Jul 2026 23:59:36 +0200 Subject: Change record constructor syntax --- gcc/gcc/elna-generic.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'gcc') diff --git a/gcc/gcc/elna-generic.cc b/gcc/gcc/elna-generic.cc index 30dd68b..5749bbc 100644 --- a/gcc/gcc/elna-generic.cc +++ b/gcc/gcc/elna-generic.cc @@ -178,6 +178,30 @@ namespace elna::gcc } } + void generic_visitor::visit(boot::record_constructor_expression *expression) + { + tree type_decl = this->symbols->lookup(expression->type_name); + + if (type_decl == NULL_TREE) + { + error_at(get_location(&expression->position()), "Type '%s' not declared", + expression->type_name.c_str()); + this->current_expression = error_mark_node; + return; + } + tree record_type = TREE_TYPE(type_decl); + vec *tree_arguments = nullptr; + + for (const boot::field_initializer& initializer : expression->field_initializers) + { + tree field_decl = find_field_by_name(get_location(&expression->position()), + record_type, initializer.name); + initializer.value->accept(this); + CONSTRUCTOR_APPEND_ELT(tree_arguments, field_decl, this->current_expression); + } + this->current_expression = build_constructor(record_type, tree_arguments); + } + void generic_visitor::visit(boot::unit *unit) { for (boot::import_declaration *const declaration : unit->imports) -- cgit v1.2.3