mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 11:51:04 +01:00
Remove most of the metaprogramming in node.h in favor of listing all the members in the typed node structs. (#3310)
Split `node.h` into separate files for ID types (`id.h`) and for typed nodes (`typed_nodes.h`). The per-node-kind data is now specified as part of declaring the typed nodes, and is removed from the node kinds x-macros, which now simply enumerate the node kinds.
This commit is contained in:
@@ -29,7 +29,7 @@ auto HandleStructFieldType(Context& context, Parse::Node parse_node) -> bool {
|
||||
context.node_stack().PopWithParseNode<Parse::NodeKind::Name>();
|
||||
|
||||
context.AddNodeAndPush(
|
||||
parse_node, SemIR::StructTypeField(name_node, name_id, cast_type_id));
|
||||
parse_node, SemIR::StructTypeField{name_node, name_id, cast_type_id});
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -44,9 +44,9 @@ auto HandleStructFieldValue(Context& context, Parse::Node parse_node) -> bool {
|
||||
StringId name_id = context.node_stack().Pop<Parse::NodeKind::Name>();
|
||||
|
||||
// Store the name for the type.
|
||||
context.args_type_info_stack().AddNode(SemIR::StructTypeField(
|
||||
context.args_type_info_stack().AddNode(SemIR::StructTypeField{
|
||||
parse_node, name_id,
|
||||
context.semantics_ir().GetNode(value_node_id).type_id()));
|
||||
context.semantics_ir().GetNode(value_node_id).type_id()});
|
||||
|
||||
// Push the value back on the stack as an argument.
|
||||
context.node_stack().Push(parse_node, value_node_id);
|
||||
@@ -66,7 +66,7 @@ auto HandleStructLiteral(Context& context, Parse::Node parse_node) -> bool {
|
||||
auto type_id = context.CanonicalizeStructType(parse_node, type_block_id);
|
||||
|
||||
auto value_id =
|
||||
context.AddNode(SemIR::StructLiteral(parse_node, type_id, refs_id));
|
||||
context.AddNode(SemIR::StructLiteral{parse_node, type_id, refs_id});
|
||||
context.node_stack().Push(parse_node, value_id);
|
||||
return true;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ auto HandleStructTypeLiteral(Context& context, Parse::Node parse_node) -> bool {
|
||||
|
||||
context.AddNodeAndPush(
|
||||
parse_node,
|
||||
SemIR::StructType(parse_node, SemIR::TypeId::TypeType, refs_id));
|
||||
SemIR::StructType{parse_node, SemIR::TypeId::TypeType, refs_id});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user