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_ASTLAYOUT | |
9 #define SKSL_ASTLAYOUT | |
10 | |
11 #include "SkSLASTNode.h" | |
12 #include "SkSLUtil.h" | |
13 | |
14 namespace SkSL { | |
15 | |
16 /** | |
17 * Represents a layout block appearing before a variable declaration, as in: | |
18 * | |
19 * layout (location = 0) int x; | |
20 */ | |
dogben
2016/06/20 16:23:18
nit: mention -1 means missing.
| |
21 struct ASTLayout : public ASTNode { | |
22 ASTLayout(int location, int binding, int index, int set, int builtin) | |
23 : fLocation(location) | |
24 , fBinding(binding) | |
25 , fIndex(index) | |
26 , fSet(set) | |
27 , fBuiltin(builtin) {} | |
28 | |
29 std::string description() const { | |
30 std::string result; | |
31 std::string separator; | |
32 if (fLocation >= 0) { | |
33 result += separator + "location = " + to_string(fLocation); | |
34 separator = ", "; | |
35 } | |
36 if (fBinding >= 0) { | |
37 result += separator + "binding = " + to_string(fBinding); | |
38 separator = ", "; | |
39 } | |
40 if (fIndex >= 0) { | |
41 result += separator + "index = " + to_string(fIndex); | |
42 separator = ", "; | |
43 } | |
44 if (fSet >= 0) { | |
45 result += separator + "set = " + to_string(fSet); | |
46 separator = ", "; | |
47 } | |
48 if (fBuiltin >= 0) { | |
49 result += separator + "builtin = " + to_string(fBuiltin); | |
50 separator = ", "; | |
51 } | |
52 if (result.length() > 0) { | |
53 result = "layout (" + result + ")"; | |
54 } | |
55 return result; | |
56 } | |
57 | |
58 const int fLocation; | |
59 const int fBinding; | |
60 const int fIndex; | |
61 const int fSet; | |
62 const int fBuiltin; | |
63 }; | |
64 | |
65 } // namespace | |
66 | |
67 #endif | |
OLD | NEW |