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:
Richard Smith
2023-06-16 20:10:33 -07:00
committed by GitHub
parent 2ae8117d62
commit 1ea123cd94
13 changed files with 448 additions and 59 deletions
@@ -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();