mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 07:24:42 +01:00
Introduce typed-inst accessors for ConstantValueStore (#6980)
Add `InstIs`, `GetInstAs`, and `TryGetInstAs` which act on the underlying constant instruction in a constant value, to save an explicit call to `GetInstId`. ```carbon context.insts().GetAs<InstT>(context.constant_values().GetInstId(const_id)) ``` can now be written as simply ```carbon context.constant_values().GetInstAs<InstT>(const_id) ``` For future work, we might provide `GetInst()` so that `context.insts().Get(context.constant_values().GetInstId(const_id)` can be shortened also.
This commit is contained in:
@@ -488,9 +488,8 @@ auto MatchContext::DoPreWork(Context& context,
|
||||
case SemIR::FormParamPattern::Kind: {
|
||||
auto form_param_pattern =
|
||||
context.insts().GetAs<SemIR::FormParamPattern>(entry.pattern_id);
|
||||
auto form_inst_id =
|
||||
context.constant_values().GetInstId(form_param_pattern.form_id);
|
||||
if (!context.insts().Is<SemIR::InitForm>(form_inst_id)) {
|
||||
if (!context.constant_values().InstIs<SemIR::InitForm>(
|
||||
form_param_pattern.form_id)) {
|
||||
break;
|
||||
}
|
||||
[[fallthrough]];
|
||||
|
||||
Reference in New Issue
Block a user