OLD | NEW |
(Empty) | |
| 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_ASTINTERFACEBLOCK |
| 9 #define SKSL_ASTINTERFACEBLOCK |
| 10 |
| 11 #include "SkSLASTVarDeclaration.h" |
| 12 |
| 13 namespace SkSL { |
| 14 |
| 15 /** |
| 16 * An interface block, as in: |
| 17 * |
| 18 * out gl_PerVertex { |
| 19 * layout(builtin=0) vec4 gl_Position; |
| 20 * layout(builtin=1) float gl_PointSize; |
| 21 * }; |
| 22 */ |
| 23 struct ASTInterfaceBlock : public ASTDeclaration { |
| 24 // valueName is empty when it was not present in the source |
| 25 ASTInterfaceBlock(Position position, |
| 26 ASTModifiers modifiers, |
| 27 std::string interfaceName, |
| 28 std::string valueName, |
| 29 std::vector<std::unique_ptr<ASTVarDeclaration>> declaratio
ns) |
| 30 : INHERITED(position, kInterfaceBlock_Kind) |
| 31 , fModifiers(modifiers) |
| 32 , fInterfaceName(std::move(interfaceName)) |
| 33 , fValueName(std::move(valueName)) |
| 34 , fDeclarations(std::move(declarations)) {} |
| 35 |
| 36 std::string description() const override { |
| 37 std::string result = fModifiers.description() + fInterfaceName + " {\n"; |
| 38 for (size_t i = 0; i < fDeclarations.size(); i++) { |
| 39 result += fDeclarations[i]->description() + "\n"; |
| 40 } |
| 41 result += "}"; |
| 42 if (fValueName.length()) { |
| 43 result += " " + fValueName; |
| 44 } |
| 45 return result + ";"; |
| 46 } |
| 47 |
| 48 const ASTModifiers fModifiers; |
| 49 const std::string fInterfaceName; |
| 50 const std::string fValueName; |
| 51 const std::vector<std::unique_ptr<ASTVarDeclaration>> fDeclarations; |
| 52 |
| 53 typedef ASTDeclaration INHERITED; |
| 54 }; |
| 55 |
| 56 } // namespace |
| 57 |
| 58 #endif |
OLD | NEW |