Rename parse_node -> node_id (#3760)

This was previously discussed at
https://discord.com/channels/655572317891461132/655578254970716160/1209975051588210729.
I'm initiating this mainly because we typically use "id" suffixes to
indicate an `IdBase` being passed around and the non-id suffix of
`parse_node` suggests at it carrying more data than it actually does.
There used to be more reason for avoiding `node_id` because
`SemIR::InstId` used to be named `NodeId`, but that's no longer
necessary. As a consequence, I'd like to rename `parse_node` to more
precisely reflect its type.

In full, this is doing:

```
parse_node_kind -> node_kind
parse_node -> node_id
ParseNodeCategory -> NodeCategory
ParseNodeKind -> NodeKind
ParseNode -> NodeId
```

This is primarily in check and sem_ir, but with some `parse_node_kind`
references in parse too.

Pluralization is consistent with name forms on both sides, so that
wasn't part of my replacements.
This commit is contained in:
Jon Ross-Perkins
2024-03-09 00:21:29 +00:00
committed by GitHub
parent a1317e61e0
commit 86a7c9ff45
57 changed files with 1050 additions and 1115 deletions
+22 -22
View File
@@ -8,10 +8,10 @@
namespace Carbon::Check {
auto HandleStructLiteralOrStructTypeLiteralStart(
Context& context, Parse::StructLiteralOrStructTypeLiteralStartId parse_node)
Context& context, Parse::StructLiteralOrStructTypeLiteralStartId node_id)
-> bool {
context.scope_stack().Push();
context.node_stack().Push(parse_node);
context.node_stack().Push(node_id);
// At this point we aren't sure whether this will be a value or type literal,
// so we push onto args irrespective. It just won't be used for a type
// literal.
@@ -21,23 +21,23 @@ auto HandleStructLiteralOrStructTypeLiteralStart(
}
auto HandleStructFieldDesignator(Context& context,
Parse::StructFieldDesignatorId /*parse_node*/)
Parse::StructFieldDesignatorId /*node_id*/)
-> bool {
// This leaves the designated name on top because the `.` isn't interesting.
CARBON_CHECK(context.node_stack().PeekIsName());
return true;
}
auto HandleStructComma(Context& context, Parse::StructCommaId /*parse_node*/)
auto HandleStructComma(Context& context, Parse::StructCommaId /*node_id*/)
-> bool {
context.param_and_arg_refs_stack().ApplyComma();
return true;
}
auto HandleStructFieldValue(Context& context,
Parse::StructFieldValueId parse_node) -> bool {
auto HandleStructFieldValue(Context& context, Parse::StructFieldValueId node_id)
-> bool {
auto value_inst_id = context.node_stack().PopExpr();
auto [name_node, name_id] = context.node_stack().PopNameWithParseNode();
auto [name_node, name_id] = context.node_stack().PopNameWithNodeId();
// Store the name for the type.
context.args_type_info_stack().AddInstId(context.AddInstInNoBlock(
@@ -45,20 +45,20 @@ auto HandleStructFieldValue(Context& context,
name_id, context.insts().Get(value_inst_id).type_id()}}));
// Push the value back on the stack as an argument.
context.node_stack().Push(parse_node, value_inst_id);
context.node_stack().Push(node_id, value_inst_id);
return true;
}
auto HandleStructFieldType(Context& context,
Parse::StructFieldTypeId parse_node) -> bool {
auto [type_node, type_id] = context.node_stack().PopExprWithParseNode();
auto HandleStructFieldType(Context& context, Parse::StructFieldTypeId node_id)
-> bool {
auto [type_node, type_id] = context.node_stack().PopExprWithNodeId();
SemIR::TypeId cast_type_id = ExprAsType(context, type_node, type_id);
auto [name_node, name_id] = context.node_stack().PopNameWithParseNode();
auto [name_node, name_id] = context.node_stack().PopNameWithNodeId();
auto inst_id = context.AddInst(
{name_node, SemIR::StructTypeField{name_id, cast_type_id}});
context.node_stack().Push(parse_node, inst_id);
context.node_stack().Push(node_id, inst_id);
return true;
}
@@ -89,37 +89,37 @@ static auto DiagnoseDuplicateNames(Context& context,
return false;
}
auto HandleStructLiteral(Context& context, Parse::StructLiteralId parse_node)
auto HandleStructLiteral(Context& context, Parse::StructLiteralId node_id)
-> bool {
auto refs_id = context.param_and_arg_refs_stack().EndAndPop(
Parse::NodeKind::StructLiteralOrStructTypeLiteralStart);
context.scope_stack().Pop();
context.node_stack()
.PopAndDiscardSoloParseNode<
.PopAndDiscardSoloNodeId<
Parse::NodeKind::StructLiteralOrStructTypeLiteralStart>();
auto type_block_id = context.args_type_info_stack().Pop();
if (DiagnoseDuplicateNames(context, type_block_id, "struct literal")) {
context.node_stack().Push(parse_node, SemIR::InstId::BuiltinError);
context.node_stack().Push(node_id, SemIR::InstId::BuiltinError);
return true;
}
auto type_id = context.GetStructType(type_block_id);
auto value_id =
context.AddInst({parse_node, SemIR::StructLiteral{type_id, refs_id}});
context.node_stack().Push(parse_node, value_id);
context.AddInst({node_id, SemIR::StructLiteral{type_id, refs_id}});
context.node_stack().Push(node_id, value_id);
return true;
}
auto HandleStructTypeLiteral(Context& context,
Parse::StructTypeLiteralId parse_node) -> bool {
Parse::StructTypeLiteralId node_id) -> bool {
auto refs_id = context.param_and_arg_refs_stack().EndAndPop(
Parse::NodeKind::StructLiteralOrStructTypeLiteralStart);
context.scope_stack().Pop();
context.node_stack()
.PopAndDiscardSoloParseNode<
.PopAndDiscardSoloNodeId<
Parse::NodeKind::StructLiteralOrStructTypeLiteralStart>();
// This is only used for value literals.
context.args_type_info_stack().Pop();
@@ -128,11 +128,11 @@ auto HandleStructTypeLiteral(Context& context,
<< "{} is handled by StructLiteral.";
if (DiagnoseDuplicateNames(context, refs_id, "struct type literal")) {
context.node_stack().Push(parse_node, SemIR::InstId::BuiltinError);
context.node_stack().Push(node_id, SemIR::InstId::BuiltinError);
return true;
}
context.AddInstAndPush(
{parse_node, SemIR::StructType{SemIR::TypeId::TypeType, refs_id}});
{node_id, SemIR::StructType{SemIR::TypeId::TypeType, refs_id}});
return true;
}