mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user