Add typed nodes to SemIR. (#3280)

Replace `SemIR::Node::GetAsFoo` and `SemIR::Node::Foo::Make` with
`SemIR::Foo` class that represents a particular kind of node, with named
fields.

Rename `SemIR::IntegerLiteral` and `SemIR::RealLiteral` to
`IntegerValue` / `RealValue` to better reflect their purpose and avoid a
name collision with the corresponding `SemIR` node kinds.

Remove `NodeKind::Invalid` and the `SemIR::Node` default constructor
entirely, as they were not used for anything.
This commit is contained in:
Richard Smith
2023-10-11 05:39:59 +00:00
committed by GitHub
parent 0e8e94d8bf
commit c7a9e29a89
41 changed files with 1445 additions and 954 deletions
+2 -1
View File
@@ -120,7 +120,8 @@ auto DeclarationNameStack::UpdateScopeIfNeeded(NameContext& name_context)
switch (resolved_node.kind()) {
case SemIR::NodeKind::Namespace:
name_context.state = NameContext::State::Resolved;
name_context.target_scope_id = resolved_node.GetAsNamespace();
name_context.target_scope_id =
resolved_node.As<SemIR::Namespace>().name_scope_id;
break;
default:
name_context.state = NameContext::State::ResolvedNonScope;