aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-item.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/backend/rust-compile-item.h')
-rw-r--r--gcc/rust/backend/rust-compile-item.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-item.h b/gcc/rust/backend/rust-compile-item.h
index 10bdce0..aa65962 100644
--- a/gcc/rust/backend/rust-compile-item.h
+++ b/gcc/rust/backend/rust-compile-item.h
@@ -39,6 +39,35 @@ public:
virtual ~CompileItem () {}
+ void visit (HIR::StructStruct &struct_decl)
+ {
+ std::vector<Backend::Btyped_identifier> fields;
+ struct_decl.iterate ([&] (HIR::StructField &field) mutable -> bool {
+ TyTy::TyBase *resolved_type = nullptr;
+ bool ok
+ = ctx->get_tyctx ()->lookup_type (field.get_mappings ().get_hirid (),
+ &resolved_type);
+ rust_assert (ok);
+
+ Btype *compiled_field_ty
+ = TyTyCompile::compile (ctx->get_backend (), resolved_type);
+
+ Backend::Btyped_identifier f (field.field_name, compiled_field_ty,
+ field.get_locus ());
+ fields.push_back (std::move (f));
+ return true;
+ });
+
+ Btype *struct_type_record = ctx->get_backend ()->struct_type (fields);
+ Btype *named_struct
+ = ctx->get_backend ()->named_type (struct_decl.get_identifier (),
+ struct_type_record,
+ struct_decl.get_locus ());
+ ctx->push_type (named_struct);
+ ctx->insert_compiled_type (struct_decl.get_mappings ().get_hirid (),
+ named_struct);
+ }
+
void visit (HIR::ConstantItem &constant)
{
TyTy::TyBase *resolved_type = nullptr;