mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-21 02:36:42 +00:00
Restructure ArgAndKind as a type-safe generic ID. (#7172)
The key changes here are: - Relocating and renaming it to align with `IdKind` (and relocating `ToRaw` and `FromRaw` to follow it). - Adding a `Dispatch` method that provides a generic overload-based API for expressing per-ID-kind dispatch, and rewriting existing code to use it. Note in particular that using overloads instead of switch cases makes it possible to generically handle all specializations of a templated ID type, e.g. `SomeIdType<T>` for all `T`. We have no such templated ID types yet, but I'm introducing one in a follow-up PR that needs this capability.
This commit is contained in:
1 parent
db24042fe5
commit
daebbf32fa
10 files changed
+236
-218
No files matched your search
@@ -15,7 +15,7 @@
|
||||
namespace Carbon::SemIR {
|
||||
|
||||
// Returns the InstId represented by an instruction operand.
|
||||
static auto AsAnyInstId(Inst::ArgAndKind arg) -> InstId {
|
||||
static auto AsAnyInstId(IdAndKind arg) -> InstId {
|
||||
if (auto inst_id = arg.TryAs<SemIR::InstId>()) {
|
||||
return *inst_id;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user