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_ASTMODIFIERS |
| 9 #define SKSL_ASTMODIFIERS |
| 10 |
| 11 #include "SkSLASTLayout.h" |
| 12 #include "SkSLASTNode.h" |
| 13 |
| 14 namespace SkSL { |
| 15 |
| 16 /** |
| 17 * A set of modifier keywords (in, out, uniform, etc.) appearing before a declar
ation. |
| 18 */ |
| 19 struct ASTModifiers : public ASTNode { |
| 20 static const int kNo_Bit = 0; |
| 21 static const int kConst_Bit = 1; |
| 22 static const int kIn_Bit = 2; |
| 23 static const int kOut_Bit = 4; |
| 24 static const int kLowp_Bit = 8; |
| 25 static const int kMediump_Bit = 16; |
| 26 static const int kHighp_Bit = 32; |
| 27 static const int kUniform_Bit = 64; |
| 28 |
| 29 ASTModifiers(ASTLayout layout, int bits) |
| 30 : fLayout(layout) |
| 31 , fBits(bits) {} |
| 32 |
| 33 std::string description() const override { |
| 34 std::string result = fLayout.description(); |
| 35 if (fBits & kUniform_Bit) { |
| 36 result += "uniform "; |
| 37 } |
| 38 if (fBits & kConst_Bit) { |
| 39 result += "const "; |
| 40 } |
| 41 if (fBits & kLowp_Bit) { |
| 42 result += "lowp "; |
| 43 } |
| 44 if (fBits & kMediump_Bit) { |
| 45 result += "mediump "; |
| 46 } |
| 47 if (fBits & kHighp_Bit) { |
| 48 result += "highp "; |
| 49 } |
| 50 |
| 51 if ((fBits & kIn_Bit) && (fBits & kOut_Bit)) { |
| 52 result += "inout "; |
| 53 } else if (fBits & kIn_Bit) { |
| 54 result += "in "; |
| 55 } else if (fBits & kOut_Bit) { |
| 56 result += "out "; |
| 57 } |
| 58 |
| 59 return result; |
| 60 } |
| 61 |
| 62 const ASTLayout fLayout; |
| 63 const int fBits; |
| 64 }; |
| 65 |
| 66 } // namespace |
| 67 |
| 68 #endif |
OLD | NEW |