blob: f975d160a0626d040c1dde6c78fa0393846b9a36 [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 Nicholas9e1138d2016-11-21 10:39:35 -05007
ethannicholasb3058bd2016-07-01 08:22:01 -07008#ifndef SKSL_BLOCK
9#define SKSL_BLOCK
10
11#include "SkSLStatement.h"
ethannicholasd598f792016-07-25 10:08:54 -070012#include "SkSLSymbolTable.h"
ethannicholasb3058bd2016-07-01 08:22:01 -070013
14namespace SkSL {
15
16/**
17 * A block of multiple statements functioning as a single statement.
18 */
19struct Block : public Statement {
ethannicholasd598f792016-07-25 10:08:54 -070020 Block(Position position, std::vector<std::unique_ptr<Statement>> statements,
21 const std::shared_ptr<SymbolTable> symbols)
ethannicholasb3058bd2016-07-01 08:22:01 -070022 : INHERITED(position, kBlock_Kind)
ethannicholasd598f792016-07-25 10:08:54 -070023 , fStatements(std::move(statements))
24 , fSymbols(std::move(symbols)) {}
ethannicholasb3058bd2016-07-01 08:22:01 -070025
Ethan Nicholas9e1138d2016-11-21 10:39:35 -050026 SkString description() const override {
27 SkString result("{");
ethannicholasb3058bd2016-07-01 08:22:01 -070028 for (size_t i = 0; i < fStatements.size(); i++) {
29 result += "\n";
30 result += fStatements[i]->description();
31 }
32 result += "\n}\n";
Ethan Nicholas9e1138d2016-11-21 10:39:35 -050033 return result;
ethannicholasb3058bd2016-07-01 08:22:01 -070034 }
35
36 const std::vector<std::unique_ptr<Statement>> fStatements;
ethannicholasd598f792016-07-25 10:08:54 -070037 const std::shared_ptr<SymbolTable> fSymbols;
ethannicholasb3058bd2016-07-01 08:22:01 -070038
39 typedef Statement INHERITED;
40};
41
42} // namespace
43
44#endif