Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1696)

Unified Diff: src/sksl/ast/SkSLASTModifiers.h

Issue 1984363002: initial checkin of SkSL compiler (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: documentation and cleanups Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698