blob: df01f62a15ca86b7d926ea2cebce7f605ce08488 [file] [log] [blame]
ethannicholasb3058bd2016-07-01 08:22:01 -07001/*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
Ethan Nicholas0df1b042017-03-31 13:56:23 -04007
ethannicholasb3058bd2016-07-01 08:22:01 -07008#ifndef SKSL_ASTBLOCK
9#define SKSL_ASTBLOCK
10
11#include "SkSLASTStatement.h"
12
13namespace SkSL {
14
15/**
Ethan Nicholas0df1b042017-03-31 13:56:23 -040016 * Represents a curly-braced block of statements.
ethannicholasb3058bd2016-07-01 08:22:01 -070017 */
18struct ASTBlock : public ASTStatement {
Ethan Nicholas5b5f0962017-09-11 13:50:14 -070019 ASTBlock(int offset, std::vector<std::unique_ptr<ASTStatement>> statements)
20 : INHERITED(offset, kBlock_Kind)
ethannicholasb3058bd2016-07-01 08:22:01 -070021 , fStatements(std::move(statements)) {}
22
Ethan Nicholas0df1b042017-03-31 13:56:23 -040023 String description() const override {
24 String result("{");
ethannicholasb3058bd2016-07-01 08:22:01 -070025 for (size_t i = 0; i < fStatements.size(); i++) {
26 result += "\n";
27 result += fStatements[i]->description();
28 }
29 result += "\n}\n";
Ethan Nicholas0df1b042017-03-31 13:56:23 -040030 return result;
ethannicholasb3058bd2016-07-01 08:22:01 -070031 }
32
33 const std::vector<std::unique_ptr<ASTStatement>> fStatements;
34
35 typedef ASTStatement INHERITED;
36};
37
38} // namespace
39
40#endif