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