Chromium Code Reviews| Index: src/sksl/ast/SkSLASTLayout.h |
| diff --git a/src/sksl/ast/SkSLASTLayout.h b/src/sksl/ast/SkSLASTLayout.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d59f6bf7183c00eb0a09265f7b10f2a5448ef39a |
| --- /dev/null |
| +++ b/src/sksl/ast/SkSLASTLayout.h |
| @@ -0,0 +1,67 @@ |
| +/* |
| + * Copyright 2016 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#ifndef SKSL_ASTLAYOUT |
| +#define SKSL_ASTLAYOUT |
| + |
| +#include "SkSLASTNode.h" |
| +#include "SkSLUtil.h" |
| + |
| +namespace SkSL { |
| + |
| +/** |
| + * Represents a layout block appearing before a variable declaration, as in: |
| + * |
| + * layout (location = 0) int x; |
| + */ |
|
dogben
2016/06/20 16:23:18
nit: mention -1 means missing.
|
| +struct ASTLayout : public ASTNode { |
| + ASTLayout(int location, int binding, int index, int set, int builtin) |
| + : fLocation(location) |
| + , fBinding(binding) |
| + , fIndex(index) |
| + , fSet(set) |
| + , fBuiltin(builtin) {} |
| + |
| + std::string description() const { |
| + std::string result; |
| + std::string separator; |
| + if (fLocation >= 0) { |
| + result += separator + "location = " + to_string(fLocation); |
| + separator = ", "; |
| + } |
| + if (fBinding >= 0) { |
| + result += separator + "binding = " + to_string(fBinding); |
| + separator = ", "; |
| + } |
| + if (fIndex >= 0) { |
| + result += separator + "index = " + to_string(fIndex); |
| + separator = ", "; |
| + } |
| + if (fSet >= 0) { |
| + result += separator + "set = " + to_string(fSet); |
| + separator = ", "; |
| + } |
| + if (fBuiltin >= 0) { |
| + result += separator + "builtin = " + to_string(fBuiltin); |
| + separator = ", "; |
| + } |
| + if (result.length() > 0) { |
| + result = "layout (" + result + ")"; |
| + } |
| + return result; |
| + } |
| + |
| + const int fLocation; |
| + const int fBinding; |
| + const int fIndex; |
| + const int fSet; |
| + const int fBuiltin; |
| +}; |
| + |
| +} // namespace |
| + |
| +#endif |