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:
Richard Smith
2023-10-20 20:26:10 +00:00
committed by GitHub
parent e54deee525
commit a46e7dd967
31 changed files with 1240 additions and 957 deletions
+5 -5
View File
@@ -58,9 +58,9 @@ static auto BuildFunctionDeclaration(Context& context, bool is_definition)
.PopForSoloParseNode<Parse::NodeKind::FunctionIntroducer>();
// Add the function declaration.
auto function_decl = SemIR::FunctionDeclaration(
auto function_decl = SemIR::FunctionDeclaration{
fn_node, context.GetBuiltinType(SemIR::BuiltinKind::FunctionType),
SemIR::FunctionId::Invalid);
SemIR::FunctionId::Invalid};
auto function_decl_id = context.AddNode(function_decl);
// Check whether this is a redeclaration.
@@ -145,7 +145,7 @@ auto HandleFunctionDefinition(Context& context, Parse::Node parse_node)
"Missing `return` at end of function with declared return type.");
context.emitter().Emit(parse_node, MissingReturnStatement);
} else {
context.AddNode(SemIR::Return(parse_node));
context.AddNode(SemIR::Return{parse_node});
}
}
@@ -228,8 +228,8 @@ auto HandleReturnType(Context& context, Parse::Node parse_node) -> bool {
// TODO: Use a dedicated node rather than VarStorage here.
context.AddNodeAndPush(
parse_node,
SemIR::VarStorage(parse_node, type_id,
context.semantics_ir().strings().Add("return")));
SemIR::VarStorage{parse_node, type_id,
context.semantics_ir().strings().Add("return")});
return true;
}