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
@@ -37,11 +37,10 @@ auto SemanticsHandleIfExpressionElse(SemanticsContext& context,
ParseTree::Node else_node) -> bool {
auto else_value_id = context.node_stack().Pop<SemanticsNodeId>();
auto [then_node, then_end_block_id] =
context.node_stack().PopWithParseNode<SemanticsNodeBlockId>(
ParseNodeKind::IfExpressionThen);
context.node_stack().PopWithParseNode<ParseNodeKind::IfExpressionThen>();
auto then_value_id = context.node_stack().Pop<SemanticsNodeId>();
auto if_node =
context.node_stack().PopForSoloParseNode(ParseNodeKind::IfExpressionIf);
context.node_stack().PopForSoloParseNode<ParseNodeKind::IfExpressionIf>();
// Convert the `else` value to the `then` value's type, and finish the `else`
// block.
@@ -58,7 +57,7 @@ auto SemanticsHandleIfExpressionElse(SemanticsContext& context,
context.AddCurrentCodeBlockToFunction();
// Push the result value.
context.node_stack().Push(if_node, chosen_value_id);
context.node_stack().Push(else_node, chosen_value_id);
return true;
}