blob: a53d13d1690934dd83853f07c1091304e71fd723 [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 */
Greg Daniel792d0f12016-11-20 14:53:35 +00007
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
Greg Daniel792d0f12016-11-20 14:53:35 +000026 std::string description() const override {
27 std::string 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";
Greg Daniel792d0f12016-11-20 14:53:35 +000033 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