mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 07:31:04 +01:00
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:
@@ -8,6 +8,7 @@
|
||||
#include "toolchain/check/diagnostic_helpers.h"
|
||||
#include "toolchain/check/generic.h"
|
||||
#include "toolchain/check/import_ref.h"
|
||||
#include "toolchain/check/type.h"
|
||||
#include "toolchain/check/type_completion.h"
|
||||
#include "toolchain/diagnostics/diagnostic_emitter.h"
|
||||
#include "toolchain/diagnostics/format_providers.h"
|
||||
@@ -124,7 +125,7 @@ class EvalContext {
|
||||
|
||||
// Gets the constant value of the specified type in this context.
|
||||
auto GetConstantValueAsType(SemIR::TypeId id) -> SemIR::TypeId {
|
||||
return context().GetTypeIdForTypeConstant(GetConstantValue(id));
|
||||
return context().types().GetTypeIdForTypeConstantId(GetConstantValue(id));
|
||||
}
|
||||
|
||||
// Gets the instruction describing the constant value of the specified type in
|
||||
@@ -332,7 +333,7 @@ static auto GetConstantValue(EvalContext& eval_context, SemIR::TypeId type_id,
|
||||
Phase* phase) -> SemIR::TypeId {
|
||||
auto const_id = eval_context.GetConstantValue(type_id);
|
||||
*phase = LatestPhase(*phase, GetPhase(eval_context, const_id));
|
||||
return eval_context.context().GetTypeIdForTypeConstant(const_id);
|
||||
return eval_context.context().types().GetTypeIdForTypeConstantId(const_id);
|
||||
}
|
||||
|
||||
// If the given instruction block contains only constants, returns a
|
||||
@@ -689,7 +690,7 @@ static auto MakeIntTypeResult(Context& context, SemIRLoc loc,
|
||||
SemIR::IntKind int_kind, SemIR::InstId width_id,
|
||||
Phase phase) -> SemIR::ConstantId {
|
||||
auto result = SemIR::IntType{
|
||||
.type_id = context.GetSingletonType(SemIR::TypeType::SingletonInstId),
|
||||
.type_id = GetSingletonType(context, SemIR::TypeType::SingletonInstId),
|
||||
.int_kind = int_kind,
|
||||
.bit_width_id = width_id};
|
||||
if (!ValidateIntType(context, loc, result)) {
|
||||
@@ -1751,8 +1752,9 @@ static auto TryEvalInstInContext(EvalContext& eval_context,
|
||||
// A non-generic interface declaration evaluates to a facet type.
|
||||
return MakeConstantResult(
|
||||
eval_context.context(),
|
||||
eval_context.context().FacetTypeFromInterface(
|
||||
interface_decl.interface_id, SemIR::SpecificId::None),
|
||||
FacetTypeFromInterface(eval_context.context(),
|
||||
interface_decl.interface_id,
|
||||
SemIR::SpecificId::None),
|
||||
Phase::Concrete);
|
||||
}
|
||||
|
||||
@@ -2074,8 +2076,8 @@ static auto TryEvalInstInContext(EvalContext& eval_context,
|
||||
|
||||
case CARBON_KIND(SemIR::RequireCompleteType require_complete): {
|
||||
auto phase = Phase::Concrete;
|
||||
auto witness_type_id = eval_context.context().GetSingletonType(
|
||||
SemIR::WitnessType::SingletonInstId);
|
||||
auto witness_type_id = GetSingletonType(
|
||||
eval_context.context(), SemIR::WitnessType::SingletonInstId);
|
||||
auto complete_type_id = GetConstantValue(
|
||||
eval_context, require_complete.complete_type_id, &phase);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user