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
+5 -3
View File
@@ -7,6 +7,7 @@
#include "toolchain/check/context.h"
#include "toolchain/check/eval.h"
#include "toolchain/check/generic.h"
#include "toolchain/check/type.h"
#include "toolchain/sem_ir/ids.h"
#include "toolchain/sem_ir/inst.h"
#include "toolchain/sem_ir/typed_insts.h"
@@ -34,7 +35,7 @@ auto BuildAssociatedEntity(Context& context, SemIR::InterfaceId interface_id,
// Name lookup for the declaration's name should name the associated entity,
// not the declaration itself.
auto type_id = context.GetAssociatedEntityType(self_type_id);
auto type_id = GetAssociatedEntityType(context, self_type_id);
return context.AddInst<SemIR::AssociatedEntity>(
context.insts().GetLocId(decl_id),
{.type_id = type_id, .index = index, .decl_id = decl_id});
@@ -173,8 +174,9 @@ auto GetTypeForSpecificAssociatedEntity(Context& context, SemIRLoc loc,
GetSelfFacet(context, interface_specific_id,
context.functions().Get(fn->function_id).generic_id,
self_type_id, self_witness_id);
return context.GetFunctionTypeWithSelfType(
context.types().GetInstId(interface_fn_type_id), self_facet_id);
return GetFunctionTypeWithSelfType(
context, context.types().GetInstId(interface_fn_type_id),
self_facet_id);
} else {
CARBON_FATAL("Unexpected kind for associated constant {0}", decl);
}