ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 1 | /* |
| 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 Daniel | 792d0f1 | 2016-11-20 14:53:35 +0000 | [diff] [blame^] | 7 | |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 8 | #ifndef SKSL_BLOCK |
| 9 | #define SKSL_BLOCK |
| 10 | |
| 11 | #include "SkSLStatement.h" |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 12 | #include "SkSLSymbolTable.h" |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 13 | |
| 14 | namespace SkSL { |
| 15 | |
| 16 | /** |
| 17 | * A block of multiple statements functioning as a single statement. |
| 18 | */ |
| 19 | struct Block : public Statement { |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 20 | Block(Position position, std::vector<std::unique_ptr<Statement>> statements, |
| 21 | const std::shared_ptr<SymbolTable> symbols) |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 22 | : INHERITED(position, kBlock_Kind) |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 23 | , fStatements(std::move(statements)) |
| 24 | , fSymbols(std::move(symbols)) {} |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 25 | |
Greg Daniel | 792d0f1 | 2016-11-20 14:53:35 +0000 | [diff] [blame^] | 26 | std::string description() const override { |
| 27 | std::string result = "{"; |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 28 | for (size_t i = 0; i < fStatements.size(); i++) { |
| 29 | result += "\n"; |
| 30 | result += fStatements[i]->description(); |
| 31 | } |
| 32 | result += "\n}\n"; |
Greg Daniel | 792d0f1 | 2016-11-20 14:53:35 +0000 | [diff] [blame^] | 33 | return result; |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | const std::vector<std::unique_ptr<Statement>> fStatements; |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 37 | const std::shared_ptr<SymbolTable> fSymbols; |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 38 | |
| 39 | typedef Statement INHERITED; |
| 40 | }; |
| 41 | |
| 42 | } // namespace |
| 43 | |
| 44 | #endif |