aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/ast
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2016-11-17 16:13:37 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-18 14:34:08 +0000
commitd8df21a1e08b5b3380261f4b90acfbdc538ef93c (patch)
treed0d9454eec7c469335c40938aa497c055f89297b /src/sksl/ast
parent833dcf48844dd053ddf7ecea20e3e1c2b6b47e01 (diff)
switched skslc from std::string to SkString
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4977 Change-Id: I15e24963b09b719a2c07da67745114f5ac66cee8 Reviewed-on: https://skia-review.googlesource.com/4977 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/ast')
-rw-r--r--src/sksl/ast/SkSLASTBinaryExpression.h3
-rw-r--r--src/sksl/ast/SkSLASTBlock.h4
-rw-r--r--src/sksl/ast/SkSLASTBoolLiteral.h4
-rw-r--r--src/sksl/ast/SkSLASTBreakStatement.h4
-rw-r--r--src/sksl/ast/SkSLASTCallSuffix.h7
-rw-r--r--src/sksl/ast/SkSLASTContinueStatement.h4
-rw-r--r--src/sksl/ast/SkSLASTDiscardStatement.h4
-rw-r--r--src/sksl/ast/SkSLASTDoStatement.h2
-rw-r--r--src/sksl/ast/SkSLASTExpressionStatement.h2
-rw-r--r--src/sksl/ast/SkSLASTExtension.h6
-rw-r--r--src/sksl/ast/SkSLASTFieldSuffix.h6
-rw-r--r--src/sksl/ast/SkSLASTFloatLiteral.h2
-rw-r--r--src/sksl/ast/SkSLASTForStatement.h4
-rw-r--r--src/sksl/ast/SkSLASTFunction.h8
-rw-r--r--src/sksl/ast/SkSLASTIdentifier.h6
-rw-r--r--src/sksl/ast/SkSLASTIfStatement.h4
-rw-r--r--src/sksl/ast/SkSLASTIndexSuffix.h4
-rw-r--r--src/sksl/ast/SkSLASTIntLiteral.h2
-rw-r--r--src/sksl/ast/SkSLASTInterfaceBlock.h14
-rw-r--r--src/sksl/ast/SkSLASTLayout.h10
-rw-r--r--src/sksl/ast/SkSLASTModifiers.h4
-rw-r--r--src/sksl/ast/SkSLASTModifiersDeclaration.h2
-rw-r--r--src/sksl/ast/SkSLASTNode.h5
-rw-r--r--src/sksl/ast/SkSLASTParameter.h8
-rw-r--r--src/sksl/ast/SkSLASTPrecision.h12
-rw-r--r--src/sksl/ast/SkSLASTPrefixExpression.h2
-rw-r--r--src/sksl/ast/SkSLASTReturnStatement.h4
-rw-r--r--src/sksl/ast/SkSLASTSuffix.h6
-rw-r--r--src/sksl/ast/SkSLASTSuffixExpression.h2
-rw-r--r--src/sksl/ast/SkSLASTTernaryExpression.h2
-rw-r--r--src/sksl/ast/SkSLASTType.h6
-rw-r--r--src/sksl/ast/SkSLASTVarDeclaration.h14
-rw-r--r--src/sksl/ast/SkSLASTVarDeclarationStatement.h2
-rw-r--r--src/sksl/ast/SkSLASTWhileStatement.h2
34 files changed, 84 insertions, 87 deletions
diff --git a/src/sksl/ast/SkSLASTBinaryExpression.h b/src/sksl/ast/SkSLASTBinaryExpression.h
index 88feba66a7..c4b6e3a45b 100644
--- a/src/sksl/ast/SkSLASTBinaryExpression.h
+++ b/src/sksl/ast/SkSLASTBinaryExpression.h
@@ -10,7 +10,6 @@
#include "SkSLASTExpression.h"
#include "../SkSLToken.h"
-#include <sstream>
namespace SkSL {
@@ -25,7 +24,7 @@ struct ASTBinaryExpression : public ASTExpression {
, fOperator(op.fKind)
, fRight(std::move(right)) {}
- std::string description() const override {
+ SkString description() const override {
return "(" + fLeft->description() + " " + Token::OperatorName(fOperator) + " " +
fRight->description() + ")";
}
diff --git a/src/sksl/ast/SkSLASTBlock.h b/src/sksl/ast/SkSLASTBlock.h
index 09450a3db8..6b1e9c5551 100644
--- a/src/sksl/ast/SkSLASTBlock.h
+++ b/src/sksl/ast/SkSLASTBlock.h
@@ -20,8 +20,8 @@ struct ASTBlock : public ASTStatement {
: INHERITED(position, kBlock_Kind)
, fStatements(std::move(statements)) {}
- std::string description() const override {
- std::string result("{");
+ SkString description() const override {
+ SkString result("{");
for (size_t i = 0; i < fStatements.size(); i++) {
result += "\n";
result += fStatements[i]->description();
diff --git a/src/sksl/ast/SkSLASTBoolLiteral.h b/src/sksl/ast/SkSLASTBoolLiteral.h
index ff58822952..02f4bac0da 100644
--- a/src/sksl/ast/SkSLASTBoolLiteral.h
+++ b/src/sksl/ast/SkSLASTBoolLiteral.h
@@ -20,8 +20,8 @@ struct ASTBoolLiteral : public ASTExpression {
: INHERITED(position, kBool_Kind)
, fValue(value) {}
- std::string description() const override {
- return fValue ? "true" : "false";
+ SkString description() const override {
+ return SkString(fValue ? "true" : "false");
}
const bool fValue;
diff --git a/src/sksl/ast/SkSLASTBreakStatement.h b/src/sksl/ast/SkSLASTBreakStatement.h
index ede548cc24..dad2a85c0a 100644
--- a/src/sksl/ast/SkSLASTBreakStatement.h
+++ b/src/sksl/ast/SkSLASTBreakStatement.h
@@ -19,8 +19,8 @@ struct ASTBreakStatement : public ASTStatement {
ASTBreakStatement(Position position)
: INHERITED(position, kBreak_Kind) {}
- std::string description() const override {
- return "break;";
+ SkString description() const override {
+ return SkString("break;");
}
typedef ASTStatement INHERITED;
diff --git a/src/sksl/ast/SkSLASTCallSuffix.h b/src/sksl/ast/SkSLASTCallSuffix.h
index 5cff6f6c93..356ac850f9 100644
--- a/src/sksl/ast/SkSLASTCallSuffix.h
+++ b/src/sksl/ast/SkSLASTCallSuffix.h
@@ -8,7 +8,6 @@
#ifndef SKSL_ASTCALLSUFFIX
#define SKSL_ASTCALLSUFFIX
-#include <sstream>
#include <vector>
#include "SkSLASTSuffix.h"
@@ -22,9 +21,9 @@ struct ASTCallSuffix : public ASTSuffix {
: INHERITED(position, ASTSuffix::kCall_Kind)
, fArguments(std::move(arguments)) {}
- std::string description() const override {
- std::string result("(");
- std::string separator = "";
+ SkString description() const override {
+ SkString result("(");
+ SkString separator;
for (size_t i = 0; i < fArguments.size(); ++i) {
result += separator;
separator = ", ";
diff --git a/src/sksl/ast/SkSLASTContinueStatement.h b/src/sksl/ast/SkSLASTContinueStatement.h
index d5ab7a5c74..4cded3b16b 100644
--- a/src/sksl/ast/SkSLASTContinueStatement.h
+++ b/src/sksl/ast/SkSLASTContinueStatement.h
@@ -19,8 +19,8 @@ struct ASTContinueStatement : public ASTStatement {
ASTContinueStatement(Position position)
: INHERITED(position, kContinue_Kind) {}
- std::string description() const override {
- return "continue;";
+ SkString description() const override {
+ return SkString("continue;");
}
typedef ASTStatement INHERITED;
diff --git a/src/sksl/ast/SkSLASTDiscardStatement.h b/src/sksl/ast/SkSLASTDiscardStatement.h
index 4eaeec9ea4..754bf95efe 100644
--- a/src/sksl/ast/SkSLASTDiscardStatement.h
+++ b/src/sksl/ast/SkSLASTDiscardStatement.h
@@ -19,8 +19,8 @@ struct ASTDiscardStatement : public ASTStatement {
ASTDiscardStatement(Position position)
: INHERITED(position, kDiscard_Kind) {}
- std::string description() const override {
- return "discard;";
+ SkString description() const override {
+ return SkString("discard;");
}
typedef ASTStatement INHERITED;
diff --git a/src/sksl/ast/SkSLASTDoStatement.h b/src/sksl/ast/SkSLASTDoStatement.h
index a952d62eb5..9a0caced1c 100644
--- a/src/sksl/ast/SkSLASTDoStatement.h
+++ b/src/sksl/ast/SkSLASTDoStatement.h
@@ -22,7 +22,7 @@ struct ASTDoStatement : public ASTStatement {
, fStatement(std::move(statement))
, fTest(std::move(test)) {}
- std::string description() const override {
+ SkString description() const override {
return "do " + fStatement->description() + " while (" + fTest->description() + ");";
}
diff --git a/src/sksl/ast/SkSLASTExpressionStatement.h b/src/sksl/ast/SkSLASTExpressionStatement.h
index 450cca29fc..2dbd20940d 100644
--- a/src/sksl/ast/SkSLASTExpressionStatement.h
+++ b/src/sksl/ast/SkSLASTExpressionStatement.h
@@ -20,7 +20,7 @@ struct ASTExpressionStatement : public ASTStatement {
: INHERITED(expression->fPosition, kExpression_Kind)
, fExpression(std::move(expression)) {}
- std::string description() const override {
+ SkString description() const override {
return fExpression->description() + ";";
}
diff --git a/src/sksl/ast/SkSLASTExtension.h b/src/sksl/ast/SkSLASTExtension.h
index 896ac46c58..b9df3c52e9 100644
--- a/src/sksl/ast/SkSLASTExtension.h
+++ b/src/sksl/ast/SkSLASTExtension.h
@@ -16,15 +16,15 @@ namespace SkSL {
* An extension declaration.
*/
struct ASTExtension : public ASTDeclaration {
- ASTExtension(Position position, std::string name)
+ ASTExtension(Position position, SkString name)
: INHERITED(position, kExtension_Kind)
, fName(std::move(name)) {}
- std::string description() const override {
+ SkString description() const override {
return "#extension " + fName + " : enable";
}
- const std::string fName;
+ const SkString fName;
typedef ASTDeclaration INHERITED;
};
diff --git a/src/sksl/ast/SkSLASTFieldSuffix.h b/src/sksl/ast/SkSLASTFieldSuffix.h
index cf141d822f..9ee8531bf1 100644
--- a/src/sksl/ast/SkSLASTFieldSuffix.h
+++ b/src/sksl/ast/SkSLASTFieldSuffix.h
@@ -17,15 +17,15 @@ namespace SkSL {
* actually vector swizzle (which looks the same to the parser).
*/
struct ASTFieldSuffix : public ASTSuffix {
- ASTFieldSuffix(Position position, std::string field)
+ ASTFieldSuffix(Position position, SkString field)
: INHERITED(position, ASTSuffix::kField_Kind)
, fField(std::move(field)) {}
- std::string description() const override {
+ SkString description() const override {
return "." + fField;
}
- std::string fField;
+ SkString fField;
typedef ASTSuffix INHERITED;
};
diff --git a/src/sksl/ast/SkSLASTFloatLiteral.h b/src/sksl/ast/SkSLASTFloatLiteral.h
index 89d43cc003..ea0f595abc 100644
--- a/src/sksl/ast/SkSLASTFloatLiteral.h
+++ b/src/sksl/ast/SkSLASTFloatLiteral.h
@@ -20,7 +20,7 @@ struct ASTFloatLiteral : public ASTExpression {
: INHERITED(position, kFloat_Kind)
, fValue(value) {}
- std::string description() const override {
+ SkString description() const override {
return to_string(fValue);
}
diff --git a/src/sksl/ast/SkSLASTForStatement.h b/src/sksl/ast/SkSLASTForStatement.h
index f4f68c8f40..2706a39954 100644
--- a/src/sksl/ast/SkSLASTForStatement.h
+++ b/src/sksl/ast/SkSLASTForStatement.h
@@ -25,8 +25,8 @@ struct ASTForStatement : public ASTStatement {
, fNext(std::move(next))
, fStatement(std::move(statement)) {}
- std::string description() const override {
- std::string result = "for (";
+ SkString description() const override {
+ SkString result("for (");
if (fInitializer) {
result.append(fInitializer->description());
}
diff --git a/src/sksl/ast/SkSLASTFunction.h b/src/sksl/ast/SkSLASTFunction.h
index c5c3b9ad83..32f4da71f2 100644
--- a/src/sksl/ast/SkSLASTFunction.h
+++ b/src/sksl/ast/SkSLASTFunction.h
@@ -19,7 +19,7 @@ namespace SkSL {
* A function declaration or definition. The fBody field will be null for declarations.
*/
struct ASTFunction : public ASTDeclaration {
- ASTFunction(Position position, std::unique_ptr<ASTType> returnType, std::string name,
+ ASTFunction(Position position, std::unique_ptr<ASTType> returnType, SkString name,
std::vector<std::unique_ptr<ASTParameter>> parameters,
std::unique_ptr<ASTBlock> body)
: INHERITED(position, kFunction_Kind)
@@ -28,8 +28,8 @@ struct ASTFunction : public ASTDeclaration {
, fParameters(std::move(parameters))
, fBody(std::move(body)) {}
- std::string description() const override {
- std::string result = fReturnType->description() + " " + fName + "(";
+ SkString description() const override {
+ SkString result = fReturnType->description() + " " + fName + "(";
for (size_t i = 0; i < fParameters.size(); i++) {
if (i > 0) {
result += ", ";
@@ -45,7 +45,7 @@ struct ASTFunction : public ASTDeclaration {
}
const std::unique_ptr<ASTType> fReturnType;
- const std::string fName;
+ const SkString fName;
const std::vector<std::unique_ptr<ASTParameter>> fParameters;
const std::unique_ptr<ASTBlock> fBody;
diff --git a/src/sksl/ast/SkSLASTIdentifier.h b/src/sksl/ast/SkSLASTIdentifier.h
index d67f64d39b..aa0179a18f 100644
--- a/src/sksl/ast/SkSLASTIdentifier.h
+++ b/src/sksl/ast/SkSLASTIdentifier.h
@@ -16,15 +16,15 @@ namespace SkSL {
* An identifier in an expression context.
*/
struct ASTIdentifier : public ASTExpression {
- ASTIdentifier(Position position, std::string text)
+ ASTIdentifier(Position position, SkString text)
: INHERITED(position, kIdentifier_Kind)
, fText(std::move(text)) {}
- std::string description() const override {
+ SkString description() const override {
return fText;
}
- const std::string fText;
+ const SkString fText;
typedef ASTExpression INHERITED;
};
diff --git a/src/sksl/ast/SkSLASTIfStatement.h b/src/sksl/ast/SkSLASTIfStatement.h
index 06f663d5fb..d169702710 100644
--- a/src/sksl/ast/SkSLASTIfStatement.h
+++ b/src/sksl/ast/SkSLASTIfStatement.h
@@ -23,8 +23,8 @@ struct ASTIfStatement : public ASTStatement {
, fIfTrue(std::move(ifTrue))
, fIfFalse(std::move(ifFalse)) {}
- std::string description() const override {
- std::string result("if (");
+ SkString description() const override {
+ SkString result("if (");
result += fTest->description();
result += ") ";
result += fIfTrue->description();
diff --git a/src/sksl/ast/SkSLASTIndexSuffix.h b/src/sksl/ast/SkSLASTIndexSuffix.h
index 755029b0a2..2b7cd48417 100644
--- a/src/sksl/ast/SkSLASTIndexSuffix.h
+++ b/src/sksl/ast/SkSLASTIndexSuffix.h
@@ -26,11 +26,11 @@ struct ASTIndexSuffix : public ASTSuffix {
: INHERITED(expression ? expression->fPosition : Position(), ASTSuffix::kIndex_Kind)
, fExpression(std::move(expression)) {}
- std::string description() const override {
+ SkString description() const override {
if (fExpression) {
return "[" + fExpression->description() + "]";
} else {
- return "[]";
+ return SkString("[]");
}
}
diff --git a/src/sksl/ast/SkSLASTIntLiteral.h b/src/sksl/ast/SkSLASTIntLiteral.h
index 2598847534..f524bc04ad 100644
--- a/src/sksl/ast/SkSLASTIntLiteral.h
+++ b/src/sksl/ast/SkSLASTIntLiteral.h
@@ -21,7 +21,7 @@ struct ASTIntLiteral : public ASTExpression {
: INHERITED(position, kInt_Kind)
, fValue(value) {}
- std::string description() const override {
+ SkString description() const override {
return to_string(fValue);
}
diff --git a/src/sksl/ast/SkSLASTInterfaceBlock.h b/src/sksl/ast/SkSLASTInterfaceBlock.h
index c271362071..8d86c7c4f1 100644
--- a/src/sksl/ast/SkSLASTInterfaceBlock.h
+++ b/src/sksl/ast/SkSLASTInterfaceBlock.h
@@ -24,8 +24,8 @@ struct ASTInterfaceBlock : public ASTDeclaration {
// valueName is empty when it was not present in the source
ASTInterfaceBlock(Position position,
ASTModifiers modifiers,
- std::string interfaceName,
- std::string valueName,
+ SkString interfaceName,
+ SkString valueName,
std::vector<std::unique_ptr<ASTVarDeclarations>> declarations)
: INHERITED(position, kInterfaceBlock_Kind)
, fModifiers(modifiers)
@@ -33,21 +33,21 @@ struct ASTInterfaceBlock : public ASTDeclaration {
, fValueName(std::move(valueName))
, fDeclarations(std::move(declarations)) {}
- std::string description() const override {
- std::string result = fModifiers.description() + fInterfaceName + " {\n";
+ SkString description() const override {
+ SkString result = fModifiers.description() + fInterfaceName + " {\n";
for (size_t i = 0; i < fDeclarations.size(); i++) {
result += fDeclarations[i]->description() + "\n";
}
result += "}";
- if (fValueName.length()) {
+ if (fValueName.size()) {
result += " " + fValueName;
}
return result + ";";
}
const ASTModifiers fModifiers;
- const std::string fInterfaceName;
- const std::string fValueName;
+ const SkString fInterfaceName;
+ const SkString fValueName;
const std::vector<std::unique_ptr<ASTVarDeclarations>> fDeclarations;
typedef ASTDeclaration INHERITED;
diff --git a/src/sksl/ast/SkSLASTLayout.h b/src/sksl/ast/SkSLASTLayout.h
index ae3c3b6168..cb7f3c175c 100644
--- a/src/sksl/ast/SkSLASTLayout.h
+++ b/src/sksl/ast/SkSLASTLayout.h
@@ -48,7 +48,7 @@ struct ASTLayout : public ASTNode {
return "";
}
- static bool ReadFormat(std::string str, Format* format) {
+ static bool ReadFormat(SkString str, Format* format) {
if (str == "rgba32f") {
*format = Format::kRGBA32F;
return true;
@@ -90,9 +90,9 @@ struct ASTLayout : public ASTNode {
, fBlendSupportAllEquations(blendSupportAllEquations)
, fFormat(format) {}
- std::string description() const {
- std::string result;
- std::string separator;
+ SkString description() const {
+ SkString result;
+ SkString separator;
if (fLocation >= 0) {
result += separator + "location = " + to_string(fLocation);
separator = ", ";
@@ -129,7 +129,7 @@ struct ASTLayout : public ASTNode {
result += separator + FormatToStr(fFormat);
separator = ", ";
}
- if (result.length() > 0) {
+ if (result.size() > 0) {
result = "layout (" + result + ")";
}
return result;
diff --git a/src/sksl/ast/SkSLASTModifiers.h b/src/sksl/ast/SkSLASTModifiers.h
index 61d2e9f25d..734169267c 100644
--- a/src/sksl/ast/SkSLASTModifiers.h
+++ b/src/sksl/ast/SkSLASTModifiers.h
@@ -34,8 +34,8 @@ struct ASTModifiers : public ASTNode {
: fLayout(layout)
, fFlags(flags) {}
- std::string description() const override {
- std::string result = fLayout.description();
+ SkString description() const override {
+ SkString result = fLayout.description();
if (fFlags & kUniform_Flag) {
result += "uniform ";
}
diff --git a/src/sksl/ast/SkSLASTModifiersDeclaration.h b/src/sksl/ast/SkSLASTModifiersDeclaration.h
index f5cc620899..07efdf6024 100644
--- a/src/sksl/ast/SkSLASTModifiersDeclaration.h
+++ b/src/sksl/ast/SkSLASTModifiersDeclaration.h
@@ -23,7 +23,7 @@ struct ASTModifiersDeclaration : public ASTDeclaration {
: INHERITED(Position(), kModifiers_Kind)
, fModifiers(modifiers) {}
- std::string description() const {
+ SkString description() const {
return fModifiers.description() + ";";
}
diff --git a/src/sksl/ast/SkSLASTNode.h b/src/sksl/ast/SkSLASTNode.h
index 4305011fa5..af065955f8 100644
--- a/src/sksl/ast/SkSLASTNode.h
+++ b/src/sksl/ast/SkSLASTNode.h
@@ -8,8 +8,7 @@
#ifndef SKSL_ASTNODE
#define SKSL_ASTNODE
-#include <memory>
-#include <string>
+#include "SkString.h"
namespace SkSL {
@@ -20,7 +19,7 @@ namespace SkSL {
struct ASTNode {
virtual ~ASTNode() {}
- virtual std::string description() const = 0;
+ virtual SkString description() const = 0;
};
} // namespace
diff --git a/src/sksl/ast/SkSLASTParameter.h b/src/sksl/ast/SkSLASTParameter.h
index 8f1b4535f2..b1fd658434 100644
--- a/src/sksl/ast/SkSLASTParameter.h
+++ b/src/sksl/ast/SkSLASTParameter.h
@@ -20,15 +20,15 @@ struct ASTParameter : public ASTPositionNode {
// 'sizes' is a list of the array sizes appearing on a parameter, in source order.
// e.g. int x[3][1] would have sizes [3, 1].
ASTParameter(Position position, ASTModifiers modifiers, std::unique_ptr<ASTType> type,
- std::string name, std::vector<int> sizes)
+ SkString name, std::vector<int> sizes)
: INHERITED(position)
, fModifiers(modifiers)
, fType(std::move(type))
, fName(std::move(name))
, fSizes(std::move(sizes)) {}
- std::string description() const override {
- std::string result = fModifiers.description() + fType->description() + " " + fName;
+ SkString description() const override {
+ SkString result = fModifiers.description() + fType->description() + " " + fName;
for (int size : fSizes) {
result += "[" + to_string(size) + "]";
}
@@ -37,7 +37,7 @@ struct ASTParameter : public ASTPositionNode {
const ASTModifiers fModifiers;
const std::unique_ptr<ASTType> fType;
- const std::string fName;
+ const SkString fName;
const std::vector<int> fSizes;
typedef ASTPositionNode INHERITED;
diff --git a/src/sksl/ast/SkSLASTPrecision.h b/src/sksl/ast/SkSLASTPrecision.h
index a7df57948e..a2f427c9ce 100644
--- a/src/sksl/ast/SkSLASTPrecision.h
+++ b/src/sksl/ast/SkSLASTPrecision.h
@@ -22,17 +22,17 @@ struct ASTPrecision : public ASTDeclaration {
: INHERITED(position, kPrecision_Kind)
, fPrecision(precision) {}
- std::string description() const {
+ SkString 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;";
+ case Modifiers::kLowp_Flag: return SkString("precision lowp float;");
+ case Modifiers::kMediump_Flag: return SkString("precision mediump float;");
+ case Modifiers::kHighp_Flag: return SkString("precision highp float;");
default:
ASSERT(false);
- return "<error>";
+ return SkString("<error>");
}
ASSERT(false);
- return "<error>";
+ return SkString("<error>");
}
const Modifiers::Flag fPrecision;
diff --git a/src/sksl/ast/SkSLASTPrefixExpression.h b/src/sksl/ast/SkSLASTPrefixExpression.h
index 0d326e2aab..e06ec41f9e 100644
--- a/src/sksl/ast/SkSLASTPrefixExpression.h
+++ b/src/sksl/ast/SkSLASTPrefixExpression.h
@@ -22,7 +22,7 @@ struct ASTPrefixExpression : public ASTExpression {
, fOperator(op.fKind)
, fOperand(std::move(operand)) {}
- std::string description() const override {
+ SkString description() const override {
return Token::OperatorName(fOperator) + fOperand->description();
}
diff --git a/src/sksl/ast/SkSLASTReturnStatement.h b/src/sksl/ast/SkSLASTReturnStatement.h
index 3aac783a8c..ed24d4a153 100644
--- a/src/sksl/ast/SkSLASTReturnStatement.h
+++ b/src/sksl/ast/SkSLASTReturnStatement.h
@@ -21,8 +21,8 @@ struct ASTReturnStatement : public ASTStatement {
: INHERITED(position, kReturn_Kind)
, fExpression(std::move(expression)) {}
- std::string description() const override {
- std::string result("return");
+ SkString description() const override {
+ SkString result("return");
if (fExpression) {
result += " " + fExpression->description();
}
diff --git a/src/sksl/ast/SkSLASTSuffix.h b/src/sksl/ast/SkSLASTSuffix.h
index 18f79f01ea..64178c7682 100644
--- a/src/sksl/ast/SkSLASTSuffix.h
+++ b/src/sksl/ast/SkSLASTSuffix.h
@@ -30,12 +30,12 @@ struct ASTSuffix : public ASTPositionNode {
: INHERITED(position)
, fKind(kind) {}
- std::string description() const override {
+ SkString description() const override {
switch (fKind) {
case kPostIncrement_Kind:
- return "++";
+ return SkString("++");
case kPostDecrement_Kind:
- return "--";
+ return SkString("--");
default:
ABORT("unsupported suffix operator");
}
diff --git a/src/sksl/ast/SkSLASTSuffixExpression.h b/src/sksl/ast/SkSLASTSuffixExpression.h
index c0fda294b9..7ee200fd43 100644
--- a/src/sksl/ast/SkSLASTSuffixExpression.h
+++ b/src/sksl/ast/SkSLASTSuffixExpression.h
@@ -22,7 +22,7 @@ struct ASTSuffixExpression : public ASTExpression {
, fBase(std::move(base))
, fSuffix(std::move(suffix)) {}
- std::string description() const override {
+ SkString description() const override {
return fBase->description() + fSuffix->description();
}
diff --git a/src/sksl/ast/SkSLASTTernaryExpression.h b/src/sksl/ast/SkSLASTTernaryExpression.h
index 20b827a049..ddf8e3d120 100644
--- a/src/sksl/ast/SkSLASTTernaryExpression.h
+++ b/src/sksl/ast/SkSLASTTernaryExpression.h
@@ -24,7 +24,7 @@ struct ASTTernaryExpression : public ASTExpression {
, fIfTrue(std::move(ifTrue))
, fIfFalse(std::move(ifFalse)) {}
- std::string description() const override {
+ SkString description() const override {
return "(" + fTest->description() + " ? " + fIfTrue->description() + " : " +
fIfFalse->description() + ")";
}
diff --git a/src/sksl/ast/SkSLASTType.h b/src/sksl/ast/SkSLASTType.h
index b8fdedb214..81594000e5 100644
--- a/src/sksl/ast/SkSLASTType.h
+++ b/src/sksl/ast/SkSLASTType.h
@@ -19,16 +19,16 @@ struct ASTType : public ASTPositionNode {
kStruct_Kind
};
- ASTType(Position position, std::string name, Kind kind)
+ ASTType(Position position, SkString name, Kind kind)
: INHERITED(position)
, fName(std::move(name))
, fKind(kind) {}
- std::string description() const override {
+ SkString description() const override {
return fName;
}
- const std::string fName;
+ const SkString fName;
const Kind fKind;
diff --git a/src/sksl/ast/SkSLASTVarDeclaration.h b/src/sksl/ast/SkSLASTVarDeclaration.h
index 066922fb85..9de4cf55b9 100644
--- a/src/sksl/ast/SkSLASTVarDeclaration.h
+++ b/src/sksl/ast/SkSLASTVarDeclaration.h
@@ -22,15 +22,15 @@ namespace SkSL {
* instances.
*/
struct ASTVarDeclaration {
- ASTVarDeclaration(const std::string name,
+ ASTVarDeclaration(const SkString name,
std::vector<std::unique_ptr<ASTExpression>> sizes,
std::unique_ptr<ASTExpression> value)
: fName(name)
, fSizes(std::move(sizes))
, fValue(std::move(value)) {}
- std::string description() const {
- std::string result = fName;
+ SkString description() const {
+ SkString result = fName;
for (const auto& size : fSizes) {
if (size) {
result += "[" + size->description() + "]";
@@ -44,7 +44,7 @@ struct ASTVarDeclaration {
return result;
}
- std::string fName;
+ SkString fName;
// array sizes, if any. e.g. 'foo[3][]' has sizes [3, null]
std::vector<std::unique_ptr<ASTExpression>> fSizes;
@@ -65,9 +65,9 @@ struct ASTVarDeclarations : public ASTDeclaration {
, fType(std::move(type))
, fVars(std::move(vars)) {}
- std::string description() const override {
- std::string result = fModifiers.description() + fType->description() + " ";
- std::string separator = "";
+ SkString description() const override {
+ SkString result = fModifiers.description() + fType->description() + " ";
+ SkString separator;
for (const auto& var : fVars) {
result += separator;
separator = ", ";
diff --git a/src/sksl/ast/SkSLASTVarDeclarationStatement.h b/src/sksl/ast/SkSLASTVarDeclarationStatement.h
index 8bae389146..d71639d797 100644
--- a/src/sksl/ast/SkSLASTVarDeclarationStatement.h
+++ b/src/sksl/ast/SkSLASTVarDeclarationStatement.h
@@ -21,7 +21,7 @@ struct ASTVarDeclarationStatement : public ASTStatement {
: INHERITED(decl->fPosition, kVarDeclaration_Kind)
, fDeclarations(std::move(decl)) {}
- std::string description() const override {
+ SkString description() const override {
return fDeclarations->description() + ";";
}
diff --git a/src/sksl/ast/SkSLASTWhileStatement.h b/src/sksl/ast/SkSLASTWhileStatement.h
index e29aa23e4a..853ac8028d 100644
--- a/src/sksl/ast/SkSLASTWhileStatement.h
+++ b/src/sksl/ast/SkSLASTWhileStatement.h
@@ -22,7 +22,7 @@ struct ASTWhileStatement : public ASTStatement {
, fTest(std::move(test))
, fStatement(std::move(statement)) {}
- std::string description() const override {
+ SkString description() const override {
return "while (" + fTest->description() + ") " + fStatement->description();
}