mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 07:24:42 +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:
@@ -541,7 +541,7 @@ auto MatchContext::DoPostWork(State /*state*/,
|
||||
WorkItem /*entry*/) -> void {}
|
||||
|
||||
auto MatchContext::DoPreWork(State /*state*/, SemIR::FieldDecl field_decl,
|
||||
SemIR::InstId scrutinee_id, WorkItem entry)
|
||||
SemIR::InstId scrutinee_id, WorkItem /*entry*/)
|
||||
-> void {
|
||||
if (!scrutinee_id.has_value()) {
|
||||
return;
|
||||
@@ -559,8 +559,8 @@ auto MatchContext::DoPreWork(State /*state*/, SemIR::FieldDecl field_decl,
|
||||
return;
|
||||
}
|
||||
|
||||
// Store a mapping to the field's initializer.
|
||||
context_.field_initializers().Insert(entry.pattern_id, converted_id);
|
||||
// Store the field's initializer.
|
||||
context_.fields().Get(field_decl.field_id).initializer_id = converted_id;
|
||||
}
|
||||
|
||||
auto MatchContext::DoPreWork(State state,
|
||||
|
||||
Reference in New Issue
Block a user