mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 21:31:24 +01:00
Rename Parse::Node -> Parse::NodeId. (#3432)
As discussed [on discord](https://discord.com/channels/655572317891461132/655578254970716160/1178878128714678282) and today's toolchain discussion.
This commit is contained in:
@@ -38,7 +38,7 @@ class NodeStack {
|
||||
|
||||
// Pushes a solo parse tree node onto the stack. Used when there is no
|
||||
// IR generated by the node.
|
||||
auto Push(Parse::Node parse_node) -> void {
|
||||
auto Push(Parse::NodeId parse_node) -> void {
|
||||
CARBON_CHECK(ParseNodeKindToIdKind(parse_tree_->node_kind(parse_node)) ==
|
||||
IdKind::SoloParseNode)
|
||||
<< "Parse kind expects an Id: " << parse_tree_->node_kind(parse_node);
|
||||
@@ -51,7 +51,7 @@ class NodeStack {
|
||||
|
||||
// Pushes a parse tree node onto the stack with an ID.
|
||||
template <typename IdT>
|
||||
auto Push(Parse::Node parse_node, IdT id) -> void {
|
||||
auto Push(Parse::NodeId parse_node, IdT id) -> void {
|
||||
CARBON_CHECK(ParseNodeKindToIdKind(parse_tree_->node_kind(parse_node)) ==
|
||||
IdTypeToIdKind<IdT>())
|
||||
<< "Parse kind expected a different IdT: "
|
||||
@@ -76,7 +76,7 @@ class NodeStack {
|
||||
|
||||
// Pops the top of the stack and returns the parse_node.
|
||||
template <Parse::NodeKind::RawEnumType RequiredParseKind>
|
||||
auto PopForSoloParseNode() -> Parse::Node {
|
||||
auto PopForSoloParseNode() -> Parse::NodeId {
|
||||
Entry back = PopEntry<SemIR::InstId>();
|
||||
RequireIdKind(Parse::NodeKind::Create(RequiredParseKind),
|
||||
IdKind::SoloParseNode);
|
||||
@@ -87,7 +87,7 @@ class NodeStack {
|
||||
// Pops the top of the stack if it is the given kind, and returns the
|
||||
// parse_node. Otherwise, returns std::nullopt.
|
||||
template <Parse::NodeKind::RawEnumType RequiredParseKind>
|
||||
auto PopForSoloParseNodeIf() -> std::optional<Parse::Node> {
|
||||
auto PopForSoloParseNodeIf() -> std::optional<Parse::NodeId> {
|
||||
if (PeekIs<RequiredParseKind>()) {
|
||||
return PopForSoloParseNode<RequiredParseKind>();
|
||||
}
|
||||
@@ -113,7 +113,7 @@ class NodeStack {
|
||||
|
||||
// Pops an expression from the top of the stack and returns the parse_node and
|
||||
// the ID.
|
||||
auto PopExprWithParseNode() -> std::pair<Parse::Node, SemIR::InstId> {
|
||||
auto PopExprWithParseNode() -> std::pair<Parse::NodeId, SemIR::InstId> {
|
||||
return PopWithParseNode<SemIR::InstId>();
|
||||
}
|
||||
|
||||
@@ -178,7 +178,9 @@ class NodeStack {
|
||||
}
|
||||
|
||||
// Peeks at the parse node of the top of the name stack.
|
||||
auto PeekParseNode() const -> Parse::Node { return stack_.back().parse_node; }
|
||||
auto PeekParseNode() const -> Parse::NodeId {
|
||||
return stack_.back().parse_node;
|
||||
}
|
||||
|
||||
// Peeks at the ID associated with the top of the name stack.
|
||||
template <Parse::NodeKind::RawEnumType RequiredParseKind>
|
||||
@@ -233,17 +235,17 @@ class NodeStack {
|
||||
|
||||
// An entry in stack_.
|
||||
struct Entry {
|
||||
explicit Entry(Parse::Node parse_node, SemIR::InstId inst_id)
|
||||
explicit Entry(Parse::NodeId parse_node, SemIR::InstId inst_id)
|
||||
: parse_node(parse_node), inst_id(inst_id) {}
|
||||
explicit Entry(Parse::Node parse_node, SemIR::InstBlockId inst_block_id)
|
||||
explicit Entry(Parse::NodeId parse_node, SemIR::InstBlockId inst_block_id)
|
||||
: parse_node(parse_node), inst_block_id(inst_block_id) {}
|
||||
explicit Entry(Parse::Node parse_node, SemIR::FunctionId function_id)
|
||||
explicit Entry(Parse::NodeId parse_node, SemIR::FunctionId function_id)
|
||||
: parse_node(parse_node), function_id(function_id) {}
|
||||
explicit Entry(Parse::Node parse_node, SemIR::ClassId class_id)
|
||||
explicit Entry(Parse::NodeId parse_node, SemIR::ClassId class_id)
|
||||
: parse_node(parse_node), class_id(class_id) {}
|
||||
explicit Entry(Parse::Node parse_node, SemIR::NameId name_id)
|
||||
explicit Entry(Parse::NodeId parse_node, SemIR::NameId name_id)
|
||||
: parse_node(parse_node), name_id(name_id) {}
|
||||
explicit Entry(Parse::Node parse_node, SemIR::TypeId type_id)
|
||||
explicit Entry(Parse::NodeId parse_node, SemIR::TypeId type_id)
|
||||
: parse_node(parse_node), type_id(type_id) {}
|
||||
|
||||
// Returns the appropriate ID basaed on type.
|
||||
@@ -270,7 +272,7 @@ class NodeStack {
|
||||
}
|
||||
|
||||
// The parse node associated with the stack entry.
|
||||
Parse::Node parse_node;
|
||||
Parse::NodeId parse_node;
|
||||
|
||||
// The entries will evaluate as invalid if and only if they're a solo
|
||||
// parse_node. Invalid is used instead of optional to save space.
|
||||
@@ -393,7 +395,7 @@ class NodeStack {
|
||||
|
||||
// Pops the top of the stack and returns the parse_node and the ID.
|
||||
template <typename IdT>
|
||||
auto PopWithParseNode() -> std::pair<Parse::Node, IdT> {
|
||||
auto PopWithParseNode() -> std::pair<Parse::NodeId, IdT> {
|
||||
Entry back = PopEntry<IdT>();
|
||||
RequireIdKind(parse_tree_->node_kind(back.parse_node),
|
||||
IdTypeToIdKind<IdT>());
|
||||
@@ -408,7 +410,7 @@ class NodeStack {
|
||||
|
||||
// Require an entry to have the given Parse::NodeKind.
|
||||
template <Parse::NodeKind::RawEnumType RequiredParseKind>
|
||||
auto RequireParseKind(Parse::Node parse_node) const -> void {
|
||||
auto RequireParseKind(Parse::NodeId parse_node) const -> void {
|
||||
auto actual_kind = parse_tree_->node_kind(parse_node);
|
||||
CARBON_CHECK(RequiredParseKind == actual_kind)
|
||||
<< "Expected " << Parse::NodeKind::Create(RequiredParseKind)
|
||||
|
||||
Reference in New Issue
Block a user