aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/ast
diff options
context:
space:
mode:
authorGravatar ethannicholas <ethannicholas@google.com>2016-10-11 08:47:04 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-10-11 08:47:06 -0700
commitccb1dd8f267f9d7fe7c9d0ce222ebc81b41853b3 (patch)
tree8ba52d3b32da6ed9c3feefb30abd2c9ee66f4a3e /src/sksl/ast
parent568c98606fee6ad1b8a0714dd4dffbd4aa1d11d0 (diff)
Turned on SkSL->GLSL compiler
Diffstat (limited to 'src/sksl/ast')
-rw-r--r--src/sksl/ast/SkSLASTDeclaration.h4
-rw-r--r--src/sksl/ast/SkSLASTIndexSuffix.h16
-rw-r--r--src/sksl/ast/SkSLASTLayout.h17
-rw-r--r--src/sksl/ast/SkSLASTModifiersDeclaration.h37
-rw-r--r--src/sksl/ast/SkSLASTPrecision.h45
5 files changed, 113 insertions, 6 deletions
diff --git a/src/sksl/ast/SkSLASTDeclaration.h b/src/sksl/ast/SkSLASTDeclaration.h
index 8b55ecf832..70f0ebc72d 100644
--- a/src/sksl/ast/SkSLASTDeclaration.h
+++ b/src/sksl/ast/SkSLASTDeclaration.h
@@ -20,7 +20,9 @@ struct ASTDeclaration : public ASTPositionNode {
kVar_Kind,
kFunction_Kind,
kInterfaceBlock_Kind,
- kExtension_Kind
+ kExtension_Kind,
+ kPrecision_Kind,
+ kModifiers_Kind
};
ASTDeclaration(Position position, Kind kind)
diff --git a/src/sksl/ast/SkSLASTIndexSuffix.h b/src/sksl/ast/SkSLASTIndexSuffix.h
index 44d91fa4c4..755029b0a2 100644
--- a/src/sksl/ast/SkSLASTIndexSuffix.h
+++ b/src/sksl/ast/SkSLASTIndexSuffix.h
@@ -14,17 +14,27 @@
namespace SkSL {
/**
- * A bracketed expression, as in '[0]', indicating an array access.
+ * A bracketed expression, as in '[0]', indicating an array access. Empty brackets (as occur in
+ * 'float[](5, 6)' are represented with a null fExpression.
*/
struct ASTIndexSuffix : public ASTSuffix {
+ ASTIndexSuffix(Position position)
+ : INHERITED(position, ASTSuffix::kIndex_Kind)
+ , fExpression(nullptr) {}
+
ASTIndexSuffix(std::unique_ptr<ASTExpression> expression)
- : INHERITED(expression->fPosition, ASTSuffix::kIndex_Kind)
+ : INHERITED(expression ? expression->fPosition : Position(), ASTSuffix::kIndex_Kind)
, fExpression(std::move(expression)) {}
std::string description() const override {
- return "[" + fExpression->description() + "]";
+ if (fExpression) {
+ return "[" + fExpression->description() + "]";
+ } else {
+ return "[]";
+ }
}
+ // may be null
std::unique_ptr<ASTExpression> fExpression;
typedef ASTSuffix INHERITED;
diff --git a/src/sksl/ast/SkSLASTLayout.h b/src/sksl/ast/SkSLASTLayout.h
index 08d67531c3..515eb2bdbb 100644
--- a/src/sksl/ast/SkSLASTLayout.h
+++ b/src/sksl/ast/SkSLASTLayout.h
@@ -20,13 +20,16 @@ namespace SkSL {
*/
struct ASTLayout : public ASTNode {
// For all parameters, a -1 means no value
- ASTLayout(int location, int binding, int index, int set, int builtin, bool originUpperLeft)
+ ASTLayout(int location, int binding, int index, int set, int builtin, bool originUpperLeft,
+ bool overrideCoverage, bool blendSupportAllEquations)
: fLocation(location)
, fBinding(binding)
, fIndex(index)
, fSet(set)
, fBuiltin(builtin)
- , fOriginUpperLeft(originUpperLeft) {}
+ , fOriginUpperLeft(originUpperLeft)
+ , fOverrideCoverage(overrideCoverage)
+ , fBlendSupportAllEquations(blendSupportAllEquations) {}
std::string description() const {
std::string result;
@@ -55,6 +58,14 @@ struct ASTLayout : public ASTNode {
result += separator + "origin_upper_left";
separator = ", ";
}
+ if (fOverrideCoverage) {
+ result += separator + "override_coverage";
+ separator = ", ";
+ }
+ if (fBlendSupportAllEquations) {
+ result += separator + "blend_support_all_equations";
+ separator = ", ";
+ }
if (result.length() > 0) {
result = "layout (" + result + ")";
}
@@ -67,6 +78,8 @@ struct ASTLayout : public ASTNode {
const int fSet;
const int fBuiltin;
const bool fOriginUpperLeft;
+ const bool fOverrideCoverage;
+ const bool fBlendSupportAllEquations;
};
} // namespace
diff --git a/src/sksl/ast/SkSLASTModifiersDeclaration.h b/src/sksl/ast/SkSLASTModifiersDeclaration.h
new file mode 100644
index 0000000000..f5cc620899
--- /dev/null
+++ b/src/sksl/ast/SkSLASTModifiersDeclaration.h
@@ -0,0 +1,37 @@
+/*
+ * 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_ASTMODIFIERDECLARATION
+#define SKSL_ASTMODIFIERDECLARATION
+
+#include "SkSLASTDeclaration.h"
+#include "SkSLASTModifiers.h"
+
+namespace SkSL {
+
+/**
+ * A declaration that consists only of modifiers, e.g.:
+ *
+ * layout(blend_support_all_equations) out;
+ */
+struct ASTModifiersDeclaration : public ASTDeclaration {
+ ASTModifiersDeclaration(ASTModifiers modifiers)
+ : INHERITED(Position(), kModifiers_Kind)
+ , fModifiers(modifiers) {}
+
+ std::string description() const {
+ return fModifiers.description() + ";";
+ }
+
+ ASTModifiers fModifiers;
+
+ typedef ASTDeclaration INHERITED;
+};
+
+} // namespace
+
+#endif
diff --git a/src/sksl/ast/SkSLASTPrecision.h b/src/sksl/ast/SkSLASTPrecision.h
new file mode 100644
index 0000000000..a7df57948e
--- /dev/null
+++ b/src/sksl/ast/SkSLASTPrecision.h
@@ -0,0 +1,45 @@
+/*
+ * 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_ASTPRECISION
+#define SKSL_ASTPRECISION
+
+#include "SkSLASTDeclaration.h"
+#include "../ir/SkSLModifiers.h"
+
+namespace SkSL {
+
+/**
+ * Represents a precision declaration (e.g. 'precision mediump float;').
+ */
+struct ASTPrecision : public ASTDeclaration {
+ // FIXME handle the type
+ ASTPrecision(Position position, Modifiers::Flag precision)
+ : INHERITED(position, kPrecision_Kind)
+ , fPrecision(precision) {}
+
+ std::string description() const {
+ switch (fPrecision) {
+ case Modifiers::kLowp_Flag: return "precision lowp float;";
+ case Modifiers::kMediump_Flag: return "precision mediump float;";
+ case Modifiers::kHighp_Flag: return "precision highp float;";
+ default:
+ ASSERT(false);
+ return "<error>";
+ }
+ ASSERT(false);
+ return "<error>";
+ }
+
+ const Modifiers::Flag fPrecision;
+
+ typedef ASTDeclaration INHERITED;
+};
+
+} // namespace
+
+#endif