mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 07:14:42 +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:
@@ -16,6 +16,7 @@
|
||||
#include "toolchain/check/impl_lookup.h"
|
||||
#include "toolchain/check/operator.h"
|
||||
#include "toolchain/check/pattern_match.h"
|
||||
#include "toolchain/check/type.h"
|
||||
#include "toolchain/check/type_completion.h"
|
||||
#include "toolchain/diagnostics/format_providers.h"
|
||||
#include "toolchain/sem_ir/copy_on_write_block.h"
|
||||
@@ -159,8 +160,8 @@ static auto MakeElementAccessInst(Context& context, SemIR::LocId loc_id,
|
||||
// index so that we don't need an integer literal instruction here, and
|
||||
// remove this special case.
|
||||
auto index_id = block.template AddInst<SemIR::IntValue>(
|
||||
loc_id, {.type_id = context.GetSingletonType(
|
||||
SemIR::IntLiteralType::SingletonInstId),
|
||||
loc_id, {.type_id = GetSingletonType(
|
||||
context, SemIR::IntLiteralType::SingletonInstId),
|
||||
.int_id = context.ints().Add(static_cast<int64_t>(i))});
|
||||
return block.template AddInst<AccessInstT>(
|
||||
loc_id, {elem_type_id, aggregate_id, index_id});
|
||||
@@ -964,7 +965,7 @@ static auto PerformBuiltinConversion(Context& context, SemIR::LocId loc_id,
|
||||
// iterative approach.
|
||||
type_ids.push_back(ExprAsType(context, loc_id, tuple_inst_id).type_id);
|
||||
}
|
||||
auto tuple_type_id = context.GetTupleType(type_ids);
|
||||
auto tuple_type_id = GetTupleType(context, type_ids);
|
||||
return sem_ir.types().GetInstId(tuple_type_id);
|
||||
}
|
||||
|
||||
@@ -1298,7 +1299,7 @@ auto ConvertToBoolValue(Context& context, SemIR::LocId loc_id,
|
||||
SemIR::InstId value_id) -> SemIR::InstId {
|
||||
return ConvertToValueOfType(
|
||||
context, loc_id, value_id,
|
||||
context.GetSingletonType(SemIR::BoolType::SingletonInstId));
|
||||
GetSingletonType(context, SemIR::BoolType::SingletonInstId));
|
||||
}
|
||||
|
||||
auto ConvertForExplicitAs(Context& context, Parse::NodeId as_node,
|
||||
@@ -1361,7 +1362,7 @@ auto ExprAsType(Context& context, SemIR::LocId loc_id, SemIR::InstId value_id)
|
||||
}
|
||||
|
||||
return {.inst_id = type_inst_id,
|
||||
.type_id = context.GetTypeIdForTypeConstant(type_const_id)};
|
||||
.type_id = context.types().GetTypeIdForTypeConstantId(type_const_id)};
|
||||
}
|
||||
|
||||
} // namespace Carbon::Check
|
||||
|
||||
Reference in New Issue
Block a user