mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 10:54:49 +01:00
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:
@@ -37,7 +37,7 @@ auto SemanticsHandleIfCondition(SemanticsContext& context,
|
||||
|
||||
auto SemanticsHandleIfStatementElse(SemanticsContext& context,
|
||||
ParseTree::Node parse_node) -> bool {
|
||||
context.node_stack().PopAndDiscardSoloParseNode(ParseNodeKind::IfCondition);
|
||||
context.node_stack().PopAndDiscardSoloParseNode<ParseNodeKind::IfCondition>();
|
||||
|
||||
// Switch to emitting the else block.
|
||||
auto then_block_id = context.node_block_stack().PopForAdd();
|
||||
@@ -56,8 +56,8 @@ auto SemanticsHandleIfStatement(SemanticsContext& context,
|
||||
context.node_stack().PeekParseNode())) {
|
||||
case ParseNodeKind::IfCondition: {
|
||||
// Branch from then block to else block.
|
||||
context.node_stack().PopAndDiscardSoloParseNode(
|
||||
ParseNodeKind::IfCondition);
|
||||
context.node_stack()
|
||||
.PopAndDiscardSoloParseNode<ParseNodeKind::IfCondition>();
|
||||
context.AddNodeToBlock(
|
||||
sub_block_id,
|
||||
SemanticsNode::Branch::Make(parse_node,
|
||||
@@ -67,8 +67,8 @@ auto SemanticsHandleIfStatement(SemanticsContext& context,
|
||||
|
||||
case ParseNodeKind::IfStatementElse: {
|
||||
// Branch from the then and else blocks to a new resumption block.
|
||||
auto then_block_id = context.node_stack().Pop<SemanticsNodeBlockId>(
|
||||
ParseNodeKind::IfStatementElse);
|
||||
SemanticsNodeBlockId then_block_id =
|
||||
context.node_stack().Pop<ParseNodeKind::IfStatementElse>();
|
||||
context.AddConvergenceBlockAndPush(parse_node,
|
||||
{then_block_id, sub_block_id});
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user