| 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 | */ |
| 7 | |
| 8 | #ifndef SKSL_STATEMENT |
| 9 | #define SKSL_STATEMENT |
| 10 | |
| 11 | #include "src/sksl/ir/SkSLIRNode.h" |
| 12 | #include "src/sksl/ir/SkSLType.h" |
| 13 | |
| 14 | namespace SkSL { |
| 15 | |
| 16 | /** |
| 17 | * Abstract supertype of all statements. |
| 18 | */ |
| 19 | struct Statement : public IRNode { |
| 20 | enum Kind { |
| 21 | kBlock_Kind, |
| 22 | kBreak_Kind, |
| 23 | kContinue_Kind, |
| 24 | kDiscard_Kind, |
| 25 | kDo_Kind, |
| 26 | kExpression_Kind, |
| 27 | kFor_Kind, |
| 28 | kGroup_Kind, |
| 29 | kIf_Kind, |
| 30 | kNop_Kind, |
| 31 | kReturn_Kind, |
| 32 | kSwitch_Kind, |
| 33 | kVarDeclaration_Kind, |
| 34 | kVarDeclarations_Kind, |
| 35 | kWhile_Kind |
| 36 | }; |
| 37 | |
| 38 | Statement(int offset, Kind kind) |
| 39 | : INHERITED(offset) |
| 40 | , fKind(kind) {} |
| 41 | |
| 42 | virtual bool isEmpty() const { |
| 43 | return false; |
| 44 | } |
| 45 | |
| 46 | virtual std::unique_ptr<Statement> clone() const = 0; |
| 47 | |
| 48 | const Kind fKind; |
| 49 | |
| 50 | typedef IRNode INHERITED; |
| 51 | }; |
| 52 | |
| 53 | } // namespace |
| 54 | |
| 55 | #endif |
| 56 | |