aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/ast/SkSLASTIndexSuffix.h
diff options
context:
space:
mode:
authorGravatar ethannicholas <ethannicholas@google.com>2016-10-10 06:40:23 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-10-10 06:40:24 -0700
commit08b2ccf398e2b81bc05d2c105837e5419899469b (patch)
treef9338540266391ee920965581d44541b398487aa /src/sksl/ast/SkSLASTIndexSuffix.h
parent3f748606d8dcac21c7fcdd07c2083f611c633ad5 (diff)
Turned on SkSL->GLSL compiler
Diffstat (limited to 'src/sksl/ast/SkSLASTIndexSuffix.h')
-rw-r--r--src/sksl/ast/SkSLASTIndexSuffix.h16
1 files changed, 13 insertions, 3 deletions
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;