mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 15:51:07 +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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user