Track the list of blocks that form the body of a function. (#2941)

Use that list for lowering in lexical order, instead of rediscovering
the list based on which blocks are referenced as branch targets.
This commit is contained in:
Richard Smith
2023-06-23 08:36:13 -07:00
committed by GitHub
parent 5a90f660b9
commit b908c6e274
61 changed files with 145 additions and 176 deletions
@@ -30,12 +30,14 @@ auto SemanticsHandleIfExpressionIf(SemanticsContext& context,
SemanticsNode::BranchIf::Make(if_node, then_block_id, cond_value_id));
context.AddNodeToBlock(if_block_id,
SemanticsNode::Branch::Make(if_node, else_block_id));
context.AddCurrentCodeBlockToFunction();
return true;
}
auto SemanticsHandleIfExpressionThen(SemanticsContext& context,
ParseTree::Node then_node) -> bool {
context.node_stack().Push(then_node, context.node_block_stack().Pop());
context.AddCurrentCodeBlockToFunction();
return true;
}
@@ -65,6 +67,7 @@ auto SemanticsHandleIfExpressionElse(SemanticsContext& context,
context.AddNodeToBlock(else_end_block_id,
SemanticsNode::BranchWithArg::Make(
else_node, resume_block_id, else_value_id));
context.AddCurrentCodeBlockToFunction();
// Obtain the value in the resumption block and push it.
context.AddNodeAndPush(