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 */ | |
dogben
2016/06/20 16:23:18
nit: mention that fValueName can be empty.
| |
23 struct ASTInterfaceBlock : public ASTDeclaration { | |
24 ASTInterfaceBlock(Position position, | |
25 ASTModifiers modifiers, | |
dogben
2016/06/20 16:23:18
nit: seems inconsistent that this is not std::uniq
ethannicholas
2016/06/20 17:45:49
Statements and expressions are both recursive stru
| |
26 std::string interfaceName, | |
27 std::string valueName, | |
28 std::vector<std::unique_ptr<ASTVarDeclaration>> declaratio ns) | |
29 : INHERITED(position, kInterfaceBlock_Kind) | |
30 , fModifiers(modifiers) | |
31 , fInterfaceName(interfaceName) | |
32 , fValueName(valueName) | |
33 , fDeclarations(std::move(declarations)) {} | |
34 | |
35 std::string description() const override { | |
36 std::string result = fModifiers.description() + fInterfaceName + " {\n"; | |
37 for (size_t i = 0; i < fDeclarations.size(); i++) { | |
38 result += fDeclarations[i]->description() + "\n"; | |
39 } | |
40 result += "}"; | |
41 if (fValueName.length()) { | |
42 result += " " + fValueName; | |
43 } | |
44 return result + ";"; | |
45 } | |
46 | |
47 const ASTModifiers fModifiers; | |
48 const std::string fInterfaceName; | |
49 const std::string fValueName; | |
50 const std::vector<std::unique_ptr<ASTVarDeclaration>> fDeclarations; | |
51 | |
52 typedef ASTDeclaration INHERITED; | |
53 }; | |
54 | |
55 } // namespace | |
56 | |
57 #endif | |
OLD | NEW |