mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Refactor NodeStack APIs to better handle the increase of distinct ID types. (#2864)
I'm looking at adding CallableId, so figured I'd do this API refactoring which should reduce code duplication. This increases the amount of cross-calls between APIs because it may not be an issue for performance after optimizations, and should simplify reading of the API. Also note the prior static_asserts on layout were missing a couple types, which is why I'm moving them into Entry where it's going to be more obvious when something's added.
This commit is contained in:
@@ -27,11 +27,13 @@ auto SemanticsHandleStructFieldDesignator(SemanticsContext& context,
|
||||
|
||||
auto SemanticsHandleStructFieldType(SemanticsContext& context,
|
||||
ParseTree::Node parse_node) -> bool {
|
||||
auto [type_node, type_id] = context.node_stack().PopForParseNodeAndNodeId();
|
||||
auto [type_node, type_id] =
|
||||
context.node_stack().PopWithParseNode<SemanticsNodeId>();
|
||||
SemanticsTypeId cast_type_id = context.ExpressionAsType(type_node, type_id);
|
||||
|
||||
auto [name_node, name_id] = context.node_stack().PopForParseNodeAndNameId(
|
||||
ParseNodeKind::DesignatedName);
|
||||
auto [name_node, name_id] =
|
||||
context.node_stack().PopWithParseNode<SemanticsStringId>(
|
||||
ParseNodeKind::DesignatedName);
|
||||
|
||||
context.AddNode(
|
||||
SemanticsNode::StructTypeField::Make(name_node, cast_type_id, name_id));
|
||||
@@ -47,8 +49,8 @@ auto SemanticsHandleStructFieldUnknown(SemanticsContext& context,
|
||||
auto SemanticsHandleStructFieldValue(SemanticsContext& context,
|
||||
ParseTree::Node parse_node) -> bool {
|
||||
auto [value_parse_node, value_node_id] =
|
||||
context.node_stack().PopForParseNodeAndNodeId();
|
||||
auto [_, name_id] = context.node_stack().PopForParseNodeAndNameId(
|
||||
context.node_stack().PopWithParseNode<SemanticsNodeId>();
|
||||
auto name_id = context.node_stack().Pop<SemanticsStringId>(
|
||||
ParseNodeKind::DesignatedName);
|
||||
|
||||
// Store the name for the type.
|
||||
|
||||
Reference in New Issue
Block a user