diff options
| author | Eugen Wissner <belka@caraus.de> | 2026-07-13 23:59:36 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2026-07-13 23:59:36 +0200 |
| commit | 8ceb48a4e60b8ff89f28372da4f66cd152e2e0fe (patch) | |
| tree | b5e5522c47de3a7f62cd51a3258bfec7e99c062e /gcc | |
| parent | 500c0676b3f6cd5a2297987d5b0dc7ccf34a28d9 (diff) | |
| download | elna-8ceb48a4e60b8ff89f28372da4f66cd152e2e0fe.tar.gz | |
Change record constructor syntax
Diffstat (limited to 'gcc')
| -rw-r--r-- | gcc/gcc/elna-generic.cc | 24 |
1 files changed, 24 insertions, 0 deletions
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<constructor_elt, va_gc> *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) |
