mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-25 06:10:14 +01:00
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.
25 lines
797 B
C++
25 lines
797 B
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#include "toolchain/semantics/semantics_context.h"
|
|
#include "toolchain/semantics/semantics_node.h"
|
|
|
|
namespace Carbon {
|
|
|
|
auto SemanticsHandleCodeBlockStart(SemanticsContext& context,
|
|
ParseTree::Node parse_node) -> bool {
|
|
context.node_stack().Push(parse_node);
|
|
context.PushScope();
|
|
return true;
|
|
}
|
|
|
|
auto SemanticsHandleCodeBlock(SemanticsContext& context,
|
|
ParseTree::Node /*parse_node*/) -> bool {
|
|
context.PopScope();
|
|
context.node_stack().PopForSoloParseNode(ParseNodeKind::CodeBlockStart);
|
|
return true;
|
|
}
|
|
|
|
} // namespace Carbon
|