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
+13
View File
@@ -130,6 +130,19 @@ auto SemanticsContext::PopScope() -> void {
}
}
// Add the current code block to the enclosing function.
auto SemanticsContext::AddCurrentCodeBlockToFunction() -> void {
CARBON_CHECK(!node_block_stack().empty()) << "no current code block";
CARBON_CHECK(!return_scope_stack().empty()) << "no current function";
auto function_id = semantics_ir()
.GetNode(return_scope_stack().back())
.GetAsFunctionDeclaration();
semantics_ir()
.GetFunction(function_id)
.body_block_ids.push_back(node_block_stack().PeekForAdd());
}
auto SemanticsContext::ImplicitAsForArgs(
SemanticsNodeBlockId arg_refs_id, ParseTree::Node param_parse_node,
SemanticsNodeBlockId param_refs_id,