Index: src/sksl/ir/SkSLModifiers.h |
diff --git a/src/sksl/ir/SkSLModifiers.h b/src/sksl/ir/SkSLModifiers.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b1a485fc8508b098243a9feb3621c12a927afcec |
--- /dev/null |
+++ b/src/sksl/ir/SkSLModifiers.h |
@@ -0,0 +1,72 @@ |
+/* |
+ * 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_MODIFIERS |
+#define SKSL_MODIFIERS |
+ |
+#include "../ast/SkSLASTModifiers.h" |
+#include "SkSLLayout.h" |
+ |
+namespace SkSL { |
+ |
+/** |
+ * A set of modifier keywords (in, out, uniform, etc.) appearing before a declaration. |
+ */ |
+struct Modifiers { |
+ static const int kNo_Bit = ASTModifiers::kNo_Bit; |
+ static const int kConst_Bit = ASTModifiers::kConst_Bit; |
+ static const int kIn_Bit = ASTModifiers::kIn_Bit; |
+ static const int kOut_Bit = ASTModifiers::kOut_Bit; |
+ static const int kLowp_Bit = ASTModifiers::kLowp_Bit; |
+ static const int kMediump_Bit = ASTModifiers::kMediump_Bit; |
+ static const int kHighp_Bit = ASTModifiers::kHighp_Bit; |
+ static const int kUniform_Bit = ASTModifiers::kUniform_Bit; |
+ |
+ Modifiers(const ASTModifiers& modifiers) |
+ : fLayout(modifiers.fLayout) |
+ , fBits(modifiers.fBits) {} |
+ |
+ Modifiers(Layout& layout, int bits) |
+ : fLayout(layout) |
+ , fBits(bits) {} |
+ |
+ std::string description() const { |
+ 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 Layout fLayout; |
+ const int fBits; |
+}; |
+ |
+} // namespace |
+ |
+#endif |