mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
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:
@@ -24,15 +24,14 @@ auto HandleVariableDeclaration(Context& context, Parse::Node parse_node)
|
||||
// Get the storage and add it to name lookup.
|
||||
SemIR::NodeId var_id =
|
||||
context.node_stack().Pop<Parse::NodeKind::PatternBinding>();
|
||||
auto var = context.semantics_ir().GetNode(var_id);
|
||||
auto name_id = var.GetAsVarStorage();
|
||||
context.AddNameToLookup(var.parse_node(), name_id, var_id);
|
||||
auto var = context.semantics_ir().GetNodeAs<SemIR::VarStorage>(var_id);
|
||||
context.AddNameToLookup(var.parse_node, var.name_id, var_id);
|
||||
// If there was an initializer, assign it to storage.
|
||||
if (has_init) {
|
||||
init_id = Initialize(context, parse_node, var_id, init_id);
|
||||
// TODO: Consider using different node kinds for assignment versus
|
||||
// initialization.
|
||||
context.AddNode(SemIR::Node::Assign::Make(parse_node, var_id, init_id));
|
||||
context.AddNode(SemIR::Assign(parse_node, var_id, init_id));
|
||||
}
|
||||
|
||||
context.node_stack()
|
||||
|
||||
Reference in New Issue
Block a user