mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
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:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user