mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 10:54:49 +01:00
Convert remaining type-value InstId fields to TypeInstId (#5294)
After #5280 there are a few more typed instructions that have an `InstId type_inst_id` that always holds a type value. These are converted to `TypeInstId` to encode this fact in the type system. The `ConvertAggregateElement()` function in convert.cpp is now able to receive `TypeInstId` for a couple arguments as well. Additionally, the `type_inst_id` field of `StructTypeField` is made into a `TypeInstId`. The `TupleType::elements_id` is renamed to `TupleType::type_elements_id` to try record the fact that it's an InstBlock of type value instructions. We don't introduce a TypeInstBlockId at this time, but it might be nice to make blocks of TypeInstIds in the future. To assist in working with a block of InstId that are type values, two additional helpers are added to the TypeStore: - GetBlockAsTypeInstIds which turns an `ArrayRef<InstId>` into a range of `TypeInstId` - GetBlockAsTypeIds which turns an `ArrayRef<InstId>` into a range of `TypeId` We use these helpers in places that iterate over the `TupleType::type_elements_id`.
This commit is contained in:
@@ -67,8 +67,7 @@ auto HandleParseNode(Context& context, Parse::StructLiteralFieldId node_id)
|
||||
auto HandleParseNode(Context& context,
|
||||
Parse::StructTypeLiteralFieldId /*node_id*/) -> bool {
|
||||
auto [type_node, type_id] = context.node_stack().PopExprWithNodeId();
|
||||
SemIR::InstId cast_type_inst_id =
|
||||
ExprAsType(context, type_node, type_id).inst_id;
|
||||
auto cast_type_inst_id = ExprAsType(context, type_node, type_id).inst_id;
|
||||
// Get the name while leaving it on the stack.
|
||||
auto name_id = context.node_stack().Peek<Parse::NodeCategory::MemberName>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user