aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/ast
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-02-16 14:49:57 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-16 20:27:43 +0000
commit50afc1765511a8d4850fe97aacf8714b609bfd5a (patch)
treefd7b6874542c53463b856f3ff8d1258dc389a21d /src/sksl/ast
parent3bf12c60e265b09f282c9cc0fea1219b0b1b1088 (diff)
Fixed a couple of spots where sksl didn't have proper array support.
vec2 x[3] worked, but vec2[3] x didn't. Interface blocks also did not work with array sizes. BUG=skia: Change-Id: I45b424891db46804f1e3c1f4793470b7b501a6de Reviewed-on: https://skia-review.googlesource.com/8523 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: Ben Wagner <benjaminwagner@google.com>
Diffstat (limited to 'src/sksl/ast')
-rw-r--r--src/sksl/ast/SkSLASTInterfaceBlock.h32
-rw-r--r--src/sksl/ast/SkSLASTType.h8
2 files changed, 27 insertions, 13 deletions
diff --git a/src/sksl/ast/SkSLASTInterfaceBlock.h b/src/sksl/ast/SkSLASTInterfaceBlock.h
index 9cd99d5a9d..7647fb5c00 100644
--- a/src/sksl/ast/SkSLASTInterfaceBlock.h
+++ b/src/sksl/ast/SkSLASTInterfaceBlock.h
@@ -25,31 +25,41 @@ struct ASTInterfaceBlock : public ASTDeclaration {
// valueName is empty when it was not present in the source
ASTInterfaceBlock(Position position,
Modifiers modifiers,
- SkString interfaceName,
- SkString valueName,
- std::vector<std::unique_ptr<ASTVarDeclarations>> declarations)
+ SkString typeName,
+ std::vector<std::unique_ptr<ASTVarDeclarations>> declarations,
+ SkString instanceName,
+ std::vector<std::unique_ptr<ASTExpression>> sizes)
: INHERITED(position, kInterfaceBlock_Kind)
, fModifiers(modifiers)
- , fInterfaceName(std::move(interfaceName))
- , fValueName(std::move(valueName))
- , fDeclarations(std::move(declarations)) {}
+ , fTypeName(std::move(typeName))
+ , fDeclarations(std::move(declarations))
+ , fInstanceName(std::move(instanceName))
+ , fSizes(std::move(sizes)) {}
SkString description() const override {
- SkString result = fModifiers.description() + fInterfaceName + " {\n";
+ SkString result = fModifiers.description() + fTypeName + " {\n";
for (size_t i = 0; i < fDeclarations.size(); i++) {
result += fDeclarations[i]->description() + "\n";
}
result += "}";
- if (fValueName.size()) {
- result += " " + fValueName;
+ if (fInstanceName.size()) {
+ result += " " + fInstanceName;
+ for (const auto& size : fSizes) {
+ result += "[";
+ if (size) {
+ result += size->description();
+ }
+ result += "]";
+ }
}
return result + ";";
}
const Modifiers fModifiers;
- const SkString fInterfaceName;
- const SkString fValueName;
+ const SkString fTypeName;
const std::vector<std::unique_ptr<ASTVarDeclarations>> fDeclarations;
+ const SkString fInstanceName;
+ const std::vector<std::unique_ptr<ASTExpression>> fSizes;
typedef ASTDeclaration INHERITED;
};
diff --git a/src/sksl/ast/SkSLASTType.h b/src/sksl/ast/SkSLASTType.h
index 9cbded1043..b95c3d7a0b 100644
--- a/src/sksl/ast/SkSLASTType.h
+++ b/src/sksl/ast/SkSLASTType.h
@@ -21,10 +21,11 @@ struct ASTType : public ASTPositionNode {
kStruct_Kind
};
- ASTType(Position position, SkString name, Kind kind)
+ ASTType(Position position, SkString name, Kind kind, std::vector<int> sizes)
: INHERITED(position)
, fName(std::move(name))
- , fKind(kind) {}
+ , fKind(kind)
+ , fSizes(std::move(sizes)) {}
SkString description() const override {
return fName;
@@ -34,6 +35,9 @@ struct ASTType : public ASTPositionNode {
const Kind fKind;
+ // array sizes, -1 meaning unspecified
+ const std::vector<int> fSizes;
+
typedef ASTPositionNode INHERITED;
};