17 std::unique_ptr<SymbolTable> symbols) {
19 if (
kind == Kind::kBracedScope || (symbols && symbols->count())) {
20 return std::make_unique<Block>(
pos, std::move(statements),
kind, std::move(symbols));
24 if (statements.
empty()) {
28 if (statements.
size() > 1) {
32 std::unique_ptr<Statement>* foundStatement =
nullptr;
33 for (std::unique_ptr<Statement>& stmt : statements) {
34 if (!stmt->isEmpty()) {
35 if (!foundStatement) {
37 foundStatement = &stmt;
41 return std::make_unique<Block>(
pos, std::move(statements),
kind,
48 return std::move(*foundStatement);
56 return std::move(statements.
front());
68std::unique_ptr<Statement> Block::MakeCompoundStatement(std::unique_ptr<Statement> existing,
69 std::unique_ptr<Statement> additional) {
71 if (!existing || existing->isEmpty()) {
74 if (!additional || additional->isEmpty()) {
79 if (existing->is<
Block>()) {
81 if (block.
blockKind() == Block::Kind::kCompoundStatement) {
89 Position pos = existing->fPosition.rangeThrough(additional->fPosition);
94 return Block::Make(
pos, std::move(stmts), Block::Kind::kCompoundStatement);