Index: src/sksl/ast/SkSLASTModifiers.h |
diff --git a/src/sksl/ast/SkSLASTModifiers.h b/src/sksl/ast/SkSLASTModifiers.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f36a8418a119e0e86d3bbcc2f8e25a8f14900e9c |
--- /dev/null |
+++ b/src/sksl/ast/SkSLASTModifiers.h |
@@ -0,0 +1,68 @@ |
+/* |
+ * 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_ASTMODIFIERS |
+#define SKSL_ASTMODIFIERS |
+ |
+#include "SkSLASTLayout.h" |
+#include "SkSLASTNode.h" |
+ |
+namespace SkSL { |
+ |
+/** |
+ * A set of modifier keywords (in, out, uniform, etc.) appearing before a declaration. |
+ */ |
+struct ASTModifiers : public ASTNode { |
+ static const int kNo_Bit = 0; |
+ static const int kConst_Bit = 1; |
+ static const int kIn_Bit = 2; |
+ static const int kOut_Bit = 4; |
+ static const int kLowp_Bit = 8; |
+ static const int kMediump_Bit = 16; |
+ static const int kHighp_Bit = 32; |
+ static const int kUniform_Bit = 64; |
+ |
+ ASTModifiers(ASTLayout layout, int bits) |
+ : fLayout(layout) |
+ , fBits(bits) {} |
+ |
+ std::string description() const override { |
+ std::string result = fLayout.description(); |
+ if (fBits & kUniform_Bit) { |
+ result += "uniform "; |
+ } |
+ if (fBits & kConst_Bit) { |
+ result += "const "; |
+ } |
+ if (fBits & kLowp_Bit) { |
+ result += "lowp "; |
+ } |
+ if (fBits & kMediump_Bit) { |
+ result += "mediump "; |
+ } |
+ if (fBits & kHighp_Bit) { |
+ result += "highp "; |
+ } |
+ |
+ if ((fBits & kIn_Bit) && (fBits & kOut_Bit)) { |
+ result += "inout "; |
+ } else if (fBits & kIn_Bit) { |
+ result += "in "; |
+ } else if (fBits & kOut_Bit) { |
+ result += "out "; |
+ } |
+ |
+ return result; |
+ } |
+ |
+ const ASTLayout fLayout; |
+ const int fBits; |
+}; |
+ |
+} // namespace |
+ |
+#endif |