Move type functions off Context (#4951)

This creates a new check/type.h for most logic, and also moves some
functions to TypeStore in sem_ir/type.h. My approach for TypeStore is to
focus on moving the read-only functions there.
This commit is contained in:
Jon Ross-Perkins
2025-02-13 23:02:38 +00:00
committed by GitHub
parent 23e5677c8e
commit dc8f47e6ad
39 changed files with 506 additions and 393 deletions
+6 -5
View File
@@ -172,7 +172,7 @@ static auto PopOperand(Context& context, Worklist& worklist, SemIR::IdKind kind,
if (!type_id.has_value()) {
return arg;
}
return context.GetTypeIdForTypeInst(worklist.Pop()).index;
return context.types().GetTypeIdForTypeInstId(worklist.Pop()).index;
}
case SemIR::IdKind::For<SemIR::InstBlockId>: {
return pop_block_id(SemIR::InstBlockId(arg)).index;
@@ -183,9 +183,9 @@ static auto PopOperand(Context& context, Worklist& worklist, SemIR::IdKind kind,
SemIR::CopyOnWriteStructTypeFieldsBlock new_fields(context.sem_ir(),
old_fields_id);
for (auto i : llvm::reverse(llvm::seq(old_fields.size()))) {
new_fields.Set(
i, {.name_id = old_fields[i].name_id,
.type_id = context.GetTypeIdForTypeInst(worklist.Pop())});
new_fields.Set(i, {.name_id = old_fields[i].name_id,
.type_id = context.types().GetTypeIdForTypeInstId(
worklist.Pop())});
}
return new_fields.GetCanonical().index;
}
@@ -195,7 +195,8 @@ static auto PopOperand(Context& context, Worklist& worklist, SemIR::IdKind kind,
SemIR::CopyOnWriteTypeBlock new_type_block(context.sem_ir(),
old_type_block_id);
for (auto i : llvm::reverse(llvm::seq(size))) {
new_type_block.Set(i, context.GetTypeIdForTypeInst(worklist.Pop()));
new_type_block.Set(
i, context.types().GetTypeIdForTypeInstId(worklist.Pop()));
}
return new_type_block.GetCanonical().index;
}