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
+7 -5
View File
@@ -9,6 +9,7 @@
#include "toolchain/check/convert.h"
#include "toolchain/check/deduce.h"
#include "toolchain/check/function.h"
#include "toolchain/check/type.h"
#include "toolchain/diagnostics/format_providers.h"
#include "toolchain/sem_ir/builtin_function_kind.h"
#include "toolchain/sem_ir/entity_with_params_base.h"
@@ -118,8 +119,9 @@ static auto PerformCallToGenericInterface(
if (!callee_specific_id) {
return SemIR::ErrorInst::SingletonInstId;
}
return context.GetOrAddInst(loc_id, context.FacetTypeFromInterface(
interface_id, *callee_specific_id));
return context.GetOrAddInst(
loc_id,
FacetTypeFromInterface(context, interface_id, *callee_specific_id));
}
auto PerformCall(Context& context, SemIR::LocId loc_id, SemIR::InstId callee_id,
@@ -164,8 +166,8 @@ auto PerformCall(Context& context, SemIR::LocId loc_id, SemIR::InstId callee_id,
callee_id = context.GetOrAddInst(
context.insts().GetLocId(callee_id),
SemIR::SpecificFunction{
.type_id = context.GetSingletonType(
SemIR::SpecificFunctionType::SingletonInstId),
.type_id = GetSingletonType(
context, SemIR::SpecificFunctionType::SingletonInstId),
.callee_id = callee_id,
.specific_id = *callee_specific_id});
if (callee_function.self_type_id.has_value()) {
@@ -201,7 +203,7 @@ auto PerformCall(Context& context, SemIR::LocId loc_id, SemIR::InstId callee_id,
// For functions with an implicit return type, the return type is the
// empty tuple type.
if (!return_info.type_id.has_value()) {
return_info.type_id = context.GetTupleType({});
return_info.type_id = GetTupleType(context, {});
}
break;
case SemIR::InitRepr::ByCopy: