mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Add FieldStore and fix field initializer imports (#7287)
As suggested in [1], replace `FieldInitializerMap` with a `FieldStore`. The corresponding `FieldId` is now stored in `FieldDecl`. To make room for the `FieldId`, the `ElementIndex` is now stored in the `Field`, along with the initializer. In import_ref.cpp, resolving `FieldDecl` initializers is now supported, and in convert.cpp `LoadImportRef` is called to do so. The `field_initializer_import.carbon` test now passes. Printing a `FieldDecl` instruction now prints the initializer as well, if present. See field_initializer.carbon for an example. [1]: https://github.com/carbon-language/carbon-lang/pull/7238#discussion_r3283217158
This commit is contained in:
@@ -153,13 +153,14 @@ auto AddBindingPattern(Context& context, SemIR::LocId name_loc,
|
||||
}
|
||||
|
||||
auto field_id =
|
||||
AddInst<SemIR::FieldDecl>(context, name_loc,
|
||||
{.type_id = field_type_id,
|
||||
.name_id = name_id,
|
||||
.index = SemIR::ElementIndex::None});
|
||||
context.field_decls_stack().AppendToTop(field_id);
|
||||
context.fields().Add({.index = SemIR::ElementIndex::None,
|
||||
.initializer_id = SemIR::InstId::None});
|
||||
auto field_decl_id = AddInst<SemIR::FieldDecl>(
|
||||
context, name_loc,
|
||||
{.type_id = field_type_id, .name_id = name_id, .field_id = field_id});
|
||||
context.field_decls_stack().AppendToTop(field_decl_id);
|
||||
|
||||
return {.pattern_id = field_id, .bind_id = field_id};
|
||||
return {.pattern_id = field_decl_id, .bind_id = field_decl_id};
|
||||
}
|
||||
|
||||
auto bind_id = AddInstInNoBlock(
|
||||
|
||||
Reference in New Issue
Block a user