Start node stack push/pop setting IdT based on ParseNodeKind. (#2985)

I think there's more we can do here, but this seemed like a good
checkpoint to make sure the path I'm going down is roughly what you
expected. There's one actual edit in if expression structure to match
the increased enforcement.
This commit is contained in:
Jon Ross-Perkins
2023-07-12 23:26:53 +00:00
committed by GitHub
parent c0d18a62eb
commit 9751b4701d
16 changed files with 167 additions and 66 deletions
@@ -32,8 +32,7 @@ auto SemanticsHandleStructFieldType(SemanticsContext& context,
SemanticsTypeId cast_type_id = context.ExpressionAsType(type_node, type_id);
auto [name_node, name_id] =
context.node_stack().PopWithParseNode<SemanticsStringId>(
ParseNodeKind::Name);
context.node_stack().PopWithParseNode<ParseNodeKind::Name>();
context.AddNode(
SemanticsNode::StructTypeField::Make(name_node, cast_type_id, name_id));
@@ -50,8 +49,7 @@ auto SemanticsHandleStructFieldValue(SemanticsContext& context,
ParseTree::Node parse_node) -> bool {
auto [value_parse_node, value_node_id] =
context.node_stack().PopWithParseNode<SemanticsNodeId>();
auto name_id =
context.node_stack().Pop<SemanticsStringId>(ParseNodeKind::Name);
SemanticsStringId name_id = context.node_stack().Pop<ParseNodeKind::Name>();
// Store the name for the type.
auto type_block_id = context.args_type_info_stack().PeekForAdd();
@@ -72,8 +70,9 @@ auto SemanticsHandleStructLiteral(SemanticsContext& context,
/*for_args=*/true, ParseNodeKind::StructLiteralOrStructTypeLiteralStart);
context.PopScope();
context.node_stack().PopAndDiscardSoloParseNode(
ParseNodeKind::StructLiteralOrStructTypeLiteralStart);
context.node_stack()
.PopAndDiscardSoloParseNode<
ParseNodeKind::StructLiteralOrStructTypeLiteralStart>();
auto type_block_id = context.args_type_info_stack().Pop();
auto type_id = context.CanonicalizeStructType(parse_node, type_block_id);
@@ -102,8 +101,9 @@ auto SemanticsHandleStructTypeLiteral(SemanticsContext& context,
/*for_args=*/false, ParseNodeKind::StructLiteralOrStructTypeLiteralStart);
context.PopScope();
context.node_stack().PopAndDiscardSoloParseNode(
ParseNodeKind::StructLiteralOrStructTypeLiteralStart);
context.node_stack()
.PopAndDiscardSoloParseNode<
ParseNodeKind::StructLiteralOrStructTypeLiteralStart>();
// This is only used for value literals.
context.args_type_info_stack().Pop();