mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-01 22:02:45 +01:00
Semantics IR building for if statements. (#2920)
This follows the same structure as `if` expressions, except that no result value is needed. Semantics IR building for code blocks is also added. Rather than popping all the node stack entries we push for statements within a code block, change statements and declarations to not push themselves onto the stack. We're not notionally performing work recursively within prior statements, and we don't need their value for anything, so it seems cleaner to not push them. This also allows statements and declarations to determine what syntactic context they're in by peeking at the top of the stack, though that's not used in this patch.
This commit is contained in:
@@ -13,11 +13,6 @@ auto SemanticsHandleFunctionDeclaration(SemanticsContext& context,
|
||||
|
||||
auto SemanticsHandleFunctionDefinition(SemanticsContext& context,
|
||||
ParseTree::Node /*parse_node*/) -> bool {
|
||||
// Merges code block children up under the FunctionDefinitionStart.
|
||||
while (context.parse_tree().node_kind(context.node_stack().PeekParseNode()) !=
|
||||
ParseNodeKind::FunctionDefinitionStart) {
|
||||
context.node_stack().PopAndIgnore();
|
||||
}
|
||||
context.node_stack().PopAndDiscardId(ParseNodeKind::FunctionDefinitionStart);
|
||||
context.return_scope_stack().pop_back();
|
||||
context.PopScope();
|
||||
|
||||
Reference in New Issue
Block a user