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
+5 -5
View File
@@ -32,12 +32,12 @@ auto HandlePatternBinding(Context& context, Parse::Node parse_node) -> bool {
switch (auto context_parse_node_kind = context.parse_tree().node_kind(
context.node_stack().PeekParseNode())) {
case Parse::NodeKind::VariableIntroducer:
context.AddNodeAndPush(parse_node, SemIR::Node::VarStorage::Make(
name_node, cast_type_id, name_id));
context.AddNodeAndPush(
parse_node, SemIR::VarStorage(name_node, cast_type_id, name_id));
break;
case Parse::NodeKind::ParameterListStart:
context.AddNodeAndPush(parse_node, SemIR::Node::Parameter::Make(
name_node, cast_type_id, name_id));
context.AddNodeAndPush(
parse_node, SemIR::Parameter(name_node, cast_type_id, name_id));
break;
case Parse::NodeKind::LetIntroducer:
// Create the node, but don't add it to a block until after we've formed
@@ -46,7 +46,7 @@ auto HandlePatternBinding(Context& context, Parse::Node parse_node) -> bool {
// the `let` pattern before we see the initializer.
context.node_stack().Push(
parse_node,
context.semantics_ir().AddNodeInNoBlock(SemIR::Node::BindName::Make(
context.semantics_ir().AddNodeInNoBlock(SemIR::BindName(
name_node, cast_type_id, name_id, SemIR::NodeId::Invalid)));
break;
default: