17 std::unique_ptr<SymbolTable>
symbols) {
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());
62 std::unique_ptr<SymbolTable>
symbols) {
65 return std::make_unique<Block>(
pos, std::move(statements),
kind, std::move(
symbols));
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);
106 for (
const std::unique_ptr<Statement>& stmt : this->
children()) {
108 result += stmt->description();
bool isEmpty() const override
static std::unique_ptr< Statement > MakeCompoundStatement(std::unique_ptr< Statement > existing, std::unique_ptr< Statement > additional)
const StatementArray & children() const
std::string description() const override
static std::unique_ptr< Statement > Make(Position pos, StatementArray statements, Kind kind=Kind::kBracedScope, std::unique_ptr< SymbolTable > symbols=nullptr)
static std::unique_ptr< Block > MakeBlock(Position pos, StatementArray statements, Kind kind=Kind::kBracedScope, std::unique_ptr< SymbolTable > symbols=nullptr)
static std::unique_ptr< Statement > Make()
void reserve_exact(int n)