diff options
author | Ethan Nicholas <ethannicholas@google.com> | 2017-03-31 13:56:23 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-03-31 18:49:51 +0000 |
commit | 0df1b04db87c3d86ee0b0bd6aa2cb5b6be32cac2 (patch) | |
tree | 12e72247e1d2f4a66d2045cc6a6a62a3505d82ab /src/sksl/ast | |
parent | f809fef8280e3d6ad9d95697cd234560b49962ab (diff) |
skslc can now be compiled with no Skia dependencies, in preparation for its eventual
This reverts commit 9bd301d640ff63c280b202c7dd00bc00a3315ff4.
Bug: skia:
Change-Id: I5ad3f77ef33aa5ce2fd27fe383c9339c571663a1
Reviewed-on: https://skia-review.googlesource.com/10964
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/ast')
38 files changed, 145 insertions, 145 deletions
diff --git a/src/sksl/ast/SkSLASTBinaryExpression.h b/src/sksl/ast/SkSLASTBinaryExpression.h index c4b6e3a45b..9a24970262 100644 --- a/src/sksl/ast/SkSLASTBinaryExpression.h +++ b/src/sksl/ast/SkSLASTBinaryExpression.h @@ -14,7 +14,7 @@ namespace SkSL { /** - * Represents a binary operation, with the operator represented by the token's type. + * Represents a binary operation, with the operator represented by the token's type. */ struct ASTBinaryExpression : public ASTExpression { ASTBinaryExpression(std::unique_ptr<ASTExpression> left, Token op, @@ -24,7 +24,7 @@ struct ASTBinaryExpression : public ASTExpression { , fOperator(op.fKind) , fRight(std::move(right)) {} - SkString description() const override { + String 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 6b1e9c5551..37c0e81a95 100644 --- a/src/sksl/ast/SkSLASTBlock.h +++ b/src/sksl/ast/SkSLASTBlock.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTBLOCK #define SKSL_ASTBLOCK @@ -13,21 +13,21 @@ namespace SkSL { /** - * Represents a curly-braced block of statements. + * Represents a curly-braced block of statements. */ struct ASTBlock : public ASTStatement { ASTBlock(Position position, std::vector<std::unique_ptr<ASTStatement>> statements) : INHERITED(position, kBlock_Kind) , fStatements(std::move(statements)) {} - SkString description() const override { - SkString result("{"); + String description() const override { + String result("{"); for (size_t i = 0; i < fStatements.size(); i++) { result += "\n"; result += fStatements[i]->description(); } result += "\n}\n"; - return result; + return result; } const std::vector<std::unique_ptr<ASTStatement>> fStatements; diff --git a/src/sksl/ast/SkSLASTBoolLiteral.h b/src/sksl/ast/SkSLASTBoolLiteral.h index 02f4bac0da..48e916eed5 100644 --- a/src/sksl/ast/SkSLASTBoolLiteral.h +++ b/src/sksl/ast/SkSLASTBoolLiteral.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTBOOLLITERAL #define SKSL_ASTBOOLLITERAL @@ -13,15 +13,15 @@ namespace SkSL { /** - * Represents "true" or "false". + * Represents "true" or "false". */ struct ASTBoolLiteral : public ASTExpression { ASTBoolLiteral(Position position, bool value) : INHERITED(position, kBool_Kind) , fValue(value) {} - SkString description() const override { - return SkString(fValue ? "true" : "false"); + String description() const override { + return String(fValue ? "true" : "false"); } const bool fValue; diff --git a/src/sksl/ast/SkSLASTBreakStatement.h b/src/sksl/ast/SkSLASTBreakStatement.h index dad2a85c0a..079ee76d20 100644 --- a/src/sksl/ast/SkSLASTBreakStatement.h +++ b/src/sksl/ast/SkSLASTBreakStatement.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTBREAKSTATEMENT #define SKSL_ASTBREAKSTATEMENT @@ -13,14 +13,14 @@ namespace SkSL { /** - * A 'break' statement. + * A 'break' statement. */ struct ASTBreakStatement : public ASTStatement { ASTBreakStatement(Position position) : INHERITED(position, kBreak_Kind) {} - SkString description() const override { - return SkString("break;"); + String description() const override { + return String("break;"); } typedef ASTStatement INHERITED; diff --git a/src/sksl/ast/SkSLASTCallSuffix.h b/src/sksl/ast/SkSLASTCallSuffix.h index 356ac850f9..3ba3f0e60f 100644 --- a/src/sksl/ast/SkSLASTCallSuffix.h +++ b/src/sksl/ast/SkSLASTCallSuffix.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTCALLSUFFIX #define SKSL_ASTCALLSUFFIX @@ -14,16 +14,16 @@ namespace SkSL { /** - * A parenthesized list of arguments following an expression, indicating a function call. + * A parenthesized list of arguments following an expression, indicating a function call. */ struct ASTCallSuffix : public ASTSuffix { - ASTCallSuffix(Position position, std::vector<std::unique_ptr<ASTExpression>> arguments) + ASTCallSuffix(Position position, std::vector<std::unique_ptr<ASTExpression>> arguments) : INHERITED(position, ASTSuffix::kCall_Kind) , fArguments(std::move(arguments)) {} - SkString description() const override { - SkString result("("); - SkString separator; + String description() const override { + String result("("); + String 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 4cded3b16b..fdfce8598d 100644 --- a/src/sksl/ast/SkSLASTContinueStatement.h +++ b/src/sksl/ast/SkSLASTContinueStatement.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTCONTINUESTATEMENT #define SKSL_ASTCONTINUESTATEMENT @@ -13,14 +13,14 @@ namespace SkSL { /** - * A 'continue' statement. + * A 'continue' statement. */ struct ASTContinueStatement : public ASTStatement { ASTContinueStatement(Position position) : INHERITED(position, kContinue_Kind) {} - SkString description() const override { - return SkString("continue;"); + String description() const override { + return String("continue;"); } typedef ASTStatement INHERITED; diff --git a/src/sksl/ast/SkSLASTDeclaration.h b/src/sksl/ast/SkSLASTDeclaration.h index 70f0ebc72d..0395ef91b4 100644 --- a/src/sksl/ast/SkSLASTDeclaration.h +++ b/src/sksl/ast/SkSLASTDeclaration.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTDECLARATION #define SKSL_ASTDECLARATION @@ -13,7 +13,7 @@ namespace SkSL { /** - * Abstract supertype of declarations such as variables and functions. + * Abstract supertype of declarations such as variables and functions. */ struct ASTDeclaration : public ASTPositionNode { enum Kind { diff --git a/src/sksl/ast/SkSLASTDiscardStatement.h b/src/sksl/ast/SkSLASTDiscardStatement.h index 754bf95efe..dcf6b15e64 100644 --- a/src/sksl/ast/SkSLASTDiscardStatement.h +++ b/src/sksl/ast/SkSLASTDiscardStatement.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTDISCARDSTATEMENT #define SKSL_ASTDISCARDSTATEMENT @@ -13,14 +13,14 @@ namespace SkSL { /** - * A 'discard' statement. + * A 'discard' statement. */ struct ASTDiscardStatement : public ASTStatement { ASTDiscardStatement(Position position) : INHERITED(position, kDiscard_Kind) {} - SkString description() const override { - return SkString("discard;"); + String description() const override { + return String("discard;"); } typedef ASTStatement INHERITED; diff --git a/src/sksl/ast/SkSLASTDoStatement.h b/src/sksl/ast/SkSLASTDoStatement.h index 9a0caced1c..fc97d9e142 100644 --- a/src/sksl/ast/SkSLASTDoStatement.h +++ b/src/sksl/ast/SkSLASTDoStatement.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTDOSTATEMENT #define SKSL_ASTDOSTATEMENT @@ -13,7 +13,7 @@ namespace SkSL { /** - * A 'do' loop. + * A 'do' loop. */ struct ASTDoStatement : public ASTStatement { ASTDoStatement(Position position, std::unique_ptr<ASTStatement> statement, @@ -22,7 +22,7 @@ struct ASTDoStatement : public ASTStatement { , fStatement(std::move(statement)) , fTest(std::move(test)) {} - SkString description() const override { + String description() const override { return "do " + fStatement->description() + " while (" + fTest->description() + ");"; } diff --git a/src/sksl/ast/SkSLASTExpression.h b/src/sksl/ast/SkSLASTExpression.h index 8a48271042..11815aef84 100644 --- a/src/sksl/ast/SkSLASTExpression.h +++ b/src/sksl/ast/SkSLASTExpression.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTEXPRESSION #define SKSL_ASTEXPRESSION @@ -13,7 +13,7 @@ namespace SkSL { /** - * Abstract supertype of all expressions. + * Abstract supertype of all expressions. */ struct ASTExpression : public ASTPositionNode { enum Kind { diff --git a/src/sksl/ast/SkSLASTExpressionStatement.h b/src/sksl/ast/SkSLASTExpressionStatement.h index 2dbd20940d..398a16a23a 100644 --- a/src/sksl/ast/SkSLASTExpressionStatement.h +++ b/src/sksl/ast/SkSLASTExpressionStatement.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTEXPRESSIONSTATEMENT #define SKSL_ASTEXPRESSIONSTATEMENT @@ -13,14 +13,14 @@ namespace SkSL { /** - * A lone expression being used as a statement. + * A lone expression being used as a statement. */ struct ASTExpressionStatement : public ASTStatement { ASTExpressionStatement(std::unique_ptr<ASTExpression> expression) : INHERITED(expression->fPosition, kExpression_Kind) , fExpression(std::move(expression)) {} - SkString description() const override { + String description() const override { return fExpression->description() + ";"; } diff --git a/src/sksl/ast/SkSLASTExtension.h b/src/sksl/ast/SkSLASTExtension.h index b9df3c52e9..a6fde0694c 100644 --- a/src/sksl/ast/SkSLASTExtension.h +++ b/src/sksl/ast/SkSLASTExtension.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTEXTENSION #define SKSL_ASTEXTENSION @@ -12,19 +12,19 @@ namespace SkSL { -/** - * An extension declaration. +/** + * An extension declaration. */ struct ASTExtension : public ASTDeclaration { - ASTExtension(Position position, SkString name) + ASTExtension(Position position, String name) : INHERITED(position, kExtension_Kind) , fName(std::move(name)) {} - SkString description() const override { + String description() const override { return "#extension " + fName + " : enable"; } - const SkString fName; + const String fName; typedef ASTDeclaration INHERITED; }; diff --git a/src/sksl/ast/SkSLASTFieldSuffix.h b/src/sksl/ast/SkSLASTFieldSuffix.h index 9ee8531bf1..bde1e4aec5 100644 --- a/src/sksl/ast/SkSLASTFieldSuffix.h +++ b/src/sksl/ast/SkSLASTFieldSuffix.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTFIELDSUFFIX #define SKSL_ASTFIELDSUFFIX @@ -17,15 +17,15 @@ namespace SkSL { * actually vector swizzle (which looks the same to the parser). */ struct ASTFieldSuffix : public ASTSuffix { - ASTFieldSuffix(Position position, SkString field) + ASTFieldSuffix(Position position, String field) : INHERITED(position, ASTSuffix::kField_Kind) , fField(std::move(field)) {} - SkString description() const override { + String description() const override { return "." + fField; } - SkString fField; + String fField; typedef ASTSuffix INHERITED; }; diff --git a/src/sksl/ast/SkSLASTFloatLiteral.h b/src/sksl/ast/SkSLASTFloatLiteral.h index ea0f595abc..15fe836049 100644 --- a/src/sksl/ast/SkSLASTFloatLiteral.h +++ b/src/sksl/ast/SkSLASTFloatLiteral.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTFLOATLITERAL #define SKSL_ASTFLOATLITERAL @@ -13,14 +13,14 @@ namespace SkSL { /** - * A literal floating point number. + * A literal floating point number. */ struct ASTFloatLiteral : public ASTExpression { ASTFloatLiteral(Position position, double value) : INHERITED(position, kFloat_Kind) , fValue(value) {} - SkString description() const override { + String description() const override { return to_string(fValue); } diff --git a/src/sksl/ast/SkSLASTForStatement.h b/src/sksl/ast/SkSLASTForStatement.h index 2706a39954..326713eb62 100644 --- a/src/sksl/ast/SkSLASTForStatement.h +++ b/src/sksl/ast/SkSLASTForStatement.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTFORSTATEMENT #define SKSL_ASTFORSTATEMENT @@ -13,10 +13,10 @@ namespace SkSL { /** - * A 'for' loop. + * A 'for' loop. */ struct ASTForStatement : public ASTStatement { - ASTForStatement(Position position, std::unique_ptr<ASTStatement> initializer, + ASTForStatement(Position position, std::unique_ptr<ASTStatement> initializer, std::unique_ptr<ASTExpression> test, std::unique_ptr<ASTExpression> next, std::unique_ptr<ASTStatement> statement) : INHERITED(position, kFor_Kind) @@ -25,8 +25,8 @@ struct ASTForStatement : public ASTStatement { , fNext(std::move(next)) , fStatement(std::move(statement)) {} - SkString description() const override { - SkString result("for ("); + String description() const override { + String result("for ("); if (fInitializer) { result.append(fInitializer->description()); } diff --git a/src/sksl/ast/SkSLASTFunction.h b/src/sksl/ast/SkSLASTFunction.h index 32f4da71f2..d9f3067baa 100644 --- a/src/sksl/ast/SkSLASTFunction.h +++ b/src/sksl/ast/SkSLASTFunction.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTFUNCTION #define SKSL_ASTFUNCTION @@ -16,11 +16,11 @@ namespace SkSL { /** - * A function declaration or definition. The fBody field will be null for declarations. + * 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, SkString name, - std::vector<std::unique_ptr<ASTParameter>> parameters, + ASTFunction(Position position, std::unique_ptr<ASTType> returnType, String name, + std::vector<std::unique_ptr<ASTParameter>> parameters, std::unique_ptr<ASTBlock> body) : INHERITED(position, kFunction_Kind) , fReturnType(std::move(returnType)) @@ -28,8 +28,8 @@ struct ASTFunction : public ASTDeclaration { , fParameters(std::move(parameters)) , fBody(std::move(body)) {} - SkString description() const override { - SkString result = fReturnType->description() + " " + fName + "("; + String description() const override { + String result = fReturnType->description() + " " + fName + "("; for (size_t i = 0; i < fParameters.size(); i++) { if (i > 0) { result += ", "; @@ -41,11 +41,11 @@ struct ASTFunction : public ASTDeclaration { } else { result += ");"; } - return result; + return result; } const std::unique_ptr<ASTType> fReturnType; - const SkString fName; + const String 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 aa0179a18f..016123cf8c 100644 --- a/src/sksl/ast/SkSLASTIdentifier.h +++ b/src/sksl/ast/SkSLASTIdentifier.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTIDENTIFIER #define SKSL_ASTIDENTIFIER @@ -13,18 +13,18 @@ namespace SkSL { /** - * An identifier in an expression context. + * An identifier in an expression context. */ struct ASTIdentifier : public ASTExpression { - ASTIdentifier(Position position, SkString text) + ASTIdentifier(Position position, String text) : INHERITED(position, kIdentifier_Kind) , fText(std::move(text)) {} - SkString description() const override { + String description() const override { return fText; } - const SkString fText; + const String fText; typedef ASTExpression INHERITED; }; diff --git a/src/sksl/ast/SkSLASTIfStatement.h b/src/sksl/ast/SkSLASTIfStatement.h index d169702710..684bea00d9 100644 --- a/src/sksl/ast/SkSLASTIfStatement.h +++ b/src/sksl/ast/SkSLASTIfStatement.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTIFSTATEMENT #define SKSL_ASTIFSTATEMENT @@ -13,18 +13,18 @@ namespace SkSL { /** - * An 'if' statement. + * An 'if' statement. */ struct ASTIfStatement : public ASTStatement { - ASTIfStatement(Position position, std::unique_ptr<ASTExpression> test, + ASTIfStatement(Position position, std::unique_ptr<ASTExpression> test, std::unique_ptr<ASTStatement> ifTrue, std::unique_ptr<ASTStatement> ifFalse) : INHERITED(position, kIf_Kind) , fTest(std::move(test)) , fIfTrue(std::move(ifTrue)) , fIfFalse(std::move(ifFalse)) {} - SkString description() const override { - SkString result("if ("); + String description() const override { + String result("if ("); result += fTest->description(); result += ") "; result += fIfTrue->description(); @@ -32,7 +32,7 @@ struct ASTIfStatement : public ASTStatement { result += " else "; result += fIfFalse->description(); } - return result; + return result; } const std::unique_ptr<ASTExpression> fTest; diff --git a/src/sksl/ast/SkSLASTIndexSuffix.h b/src/sksl/ast/SkSLASTIndexSuffix.h index 2b7cd48417..31142e3685 100644 --- a/src/sksl/ast/SkSLASTIndexSuffix.h +++ b/src/sksl/ast/SkSLASTIndexSuffix.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTINDEXSUFFIX #define SKSL_ASTINDEXSUFFIX @@ -18,19 +18,19 @@ namespace SkSL { * 'float[](5, 6)' are represented with a null fExpression. */ struct ASTIndexSuffix : public ASTSuffix { - ASTIndexSuffix(Position position) + ASTIndexSuffix(Position position) : INHERITED(position, ASTSuffix::kIndex_Kind) , fExpression(nullptr) {} - ASTIndexSuffix(std::unique_ptr<ASTExpression> expression) + ASTIndexSuffix(std::unique_ptr<ASTExpression> expression) : INHERITED(expression ? expression->fPosition : Position(), ASTSuffix::kIndex_Kind) , fExpression(std::move(expression)) {} - SkString description() const override { + String description() const override { if (fExpression) { return "[" + fExpression->description() + "]"; } else { - return SkString("[]"); + return String("[]"); } } diff --git a/src/sksl/ast/SkSLASTIntLiteral.h b/src/sksl/ast/SkSLASTIntLiteral.h index f524bc04ad..fe04347fd8 100644 --- a/src/sksl/ast/SkSLASTIntLiteral.h +++ b/src/sksl/ast/SkSLASTIntLiteral.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTINTLITERAL #define SKSL_ASTINTLITERAL @@ -21,7 +21,7 @@ struct ASTIntLiteral : public ASTExpression { : INHERITED(position, kInt_Kind) , fValue(value) {} - SkString description() const override { + String description() const override { return to_string(fValue); } diff --git a/src/sksl/ast/SkSLASTInterfaceBlock.h b/src/sksl/ast/SkSLASTInterfaceBlock.h index 7647fb5c00..e727ae9aad 100644 --- a/src/sksl/ast/SkSLASTInterfaceBlock.h +++ b/src/sksl/ast/SkSLASTInterfaceBlock.h @@ -25,9 +25,9 @@ struct ASTInterfaceBlock : public ASTDeclaration { // valueName is empty when it was not present in the source ASTInterfaceBlock(Position position, Modifiers modifiers, - SkString typeName, + String typeName, std::vector<std::unique_ptr<ASTVarDeclarations>> declarations, - SkString instanceName, + String instanceName, std::vector<std::unique_ptr<ASTExpression>> sizes) : INHERITED(position, kInterfaceBlock_Kind) , fModifiers(modifiers) @@ -36,8 +36,8 @@ struct ASTInterfaceBlock : public ASTDeclaration { , fInstanceName(std::move(instanceName)) , fSizes(std::move(sizes)) {} - SkString description() const override { - SkString result = fModifiers.description() + fTypeName + " {\n"; + String description() const override { + String result = fModifiers.description() + fTypeName + " {\n"; for (size_t i = 0; i < fDeclarations.size(); i++) { result += fDeclarations[i]->description() + "\n"; } @@ -56,9 +56,9 @@ struct ASTInterfaceBlock : public ASTDeclaration { } const Modifiers fModifiers; - const SkString fTypeName; + const String fTypeName; const std::vector<std::unique_ptr<ASTVarDeclarations>> fDeclarations; - const SkString fInstanceName; + const String fInstanceName; const std::vector<std::unique_ptr<ASTExpression>> fSizes; typedef ASTDeclaration INHERITED; diff --git a/src/sksl/ast/SkSLASTModifiersDeclaration.h b/src/sksl/ast/SkSLASTModifiersDeclaration.h index 7950f6dd5d..ba07f168b2 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) {} - SkString description() const { + String description() const { return fModifiers.description() + ";"; } diff --git a/src/sksl/ast/SkSLASTNode.h b/src/sksl/ast/SkSLASTNode.h index af065955f8..b08bc2a932 100644 --- a/src/sksl/ast/SkSLASTNode.h +++ b/src/sksl/ast/SkSLASTNode.h @@ -4,11 +4,11 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTNODE #define SKSL_ASTNODE -#include "SkString.h" +#include "SkSLString.h" namespace SkSL { @@ -18,8 +18,8 @@ namespace SkSL { */ struct ASTNode { virtual ~ASTNode() {} - - virtual SkString description() const = 0; + + virtual String description() const = 0; }; } // namespace diff --git a/src/sksl/ast/SkSLASTParameter.h b/src/sksl/ast/SkSLASTParameter.h index 6bb13acf49..01227c637e 100644 --- a/src/sksl/ast/SkSLASTParameter.h +++ b/src/sksl/ast/SkSLASTParameter.h @@ -21,15 +21,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, Modifiers modifiers, std::unique_ptr<ASTType> type, - SkString name, std::vector<int> sizes) + String name, std::vector<int> sizes) : INHERITED(position) , fModifiers(modifiers) , fType(std::move(type)) , fName(std::move(name)) , fSizes(std::move(sizes)) {} - SkString description() const override { - SkString result = fModifiers.description() + fType->description() + " " + fName; + String description() const override { + String result = fModifiers.description() + fType->description() + " " + fName; for (int size : fSizes) { result += "[" + to_string(size) + "]"; } @@ -38,7 +38,7 @@ struct ASTParameter : public ASTPositionNode { const Modifiers fModifiers; const std::unique_ptr<ASTType> fType; - const SkString fName; + const String fName; const std::vector<int> fSizes; typedef ASTPositionNode INHERITED; diff --git a/src/sksl/ast/SkSLASTPositionNode.h b/src/sksl/ast/SkSLASTPositionNode.h index 226b4ae4b0..cc435c486c 100644 --- a/src/sksl/ast/SkSLASTPositionNode.h +++ b/src/sksl/ast/SkSLASTPositionNode.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTPOSITIONNODE #define SKSL_ASTPOSITIONNODE diff --git a/src/sksl/ast/SkSLASTPrecision.h b/src/sksl/ast/SkSLASTPrecision.h index a2f427c9ce..4b50ed3979 100644 --- a/src/sksl/ast/SkSLASTPrecision.h +++ b/src/sksl/ast/SkSLASTPrecision.h @@ -4,7 +4,7 @@ * 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 @@ -22,17 +22,17 @@ struct ASTPrecision : public ASTDeclaration { : INHERITED(position, kPrecision_Kind) , fPrecision(precision) {} - SkString description() const { + String description() const { switch (fPrecision) { - 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 SkString("<error>"); + case Modifiers::kLowp_Flag: return String("precision lowp float;"); + case Modifiers::kMediump_Flag: return String("precision mediump float;"); + case Modifiers::kHighp_Flag: return String("precision highp float;"); + default: + ASSERT(false); + return String("<error>"); } ASSERT(false); - return SkString("<error>"); + return String("<error>"); } const Modifiers::Flag fPrecision; diff --git a/src/sksl/ast/SkSLASTPrefixExpression.h b/src/sksl/ast/SkSLASTPrefixExpression.h index e06ec41f9e..08e50f7bf1 100644 --- a/src/sksl/ast/SkSLASTPrefixExpression.h +++ b/src/sksl/ast/SkSLASTPrefixExpression.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTPREFIXEXPRESSION #define SKSL_ASTPREFIXEXPRESSION @@ -22,7 +22,7 @@ struct ASTPrefixExpression : public ASTExpression { , fOperator(op.fKind) , fOperand(std::move(operand)) {} - SkString description() const override { + String description() const override { return Token::OperatorName(fOperator) + fOperand->description(); } diff --git a/src/sksl/ast/SkSLASTReturnStatement.h b/src/sksl/ast/SkSLASTReturnStatement.h index ed24d4a153..6762eb3f90 100644 --- a/src/sksl/ast/SkSLASTReturnStatement.h +++ b/src/sksl/ast/SkSLASTReturnStatement.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTRETURNSTATEMENT #define SKSL_ASTRETURNSTATEMENT @@ -21,12 +21,12 @@ struct ASTReturnStatement : public ASTStatement { : INHERITED(position, kReturn_Kind) , fExpression(std::move(expression)) {} - SkString description() const override { - SkString result("return"); + String description() const override { + String result("return"); if (fExpression) { result += " " + fExpression->description(); } - return result + ";"; + return result + ";"; } const std::unique_ptr<ASTExpression> fExpression; diff --git a/src/sksl/ast/SkSLASTStatement.h b/src/sksl/ast/SkSLASTStatement.h index 6ce320e343..1989a1fce6 100644 --- a/src/sksl/ast/SkSLASTStatement.h +++ b/src/sksl/ast/SkSLASTStatement.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTSTATEMENT #define SKSL_ASTSTATEMENT diff --git a/src/sksl/ast/SkSLASTSuffix.h b/src/sksl/ast/SkSLASTSuffix.h index 64178c7682..f06c6fd362 100644 --- a/src/sksl/ast/SkSLASTSuffix.h +++ b/src/sksl/ast/SkSLASTSuffix.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTSUFFIX #define SKSL_ASTSUFFIX @@ -30,15 +30,15 @@ struct ASTSuffix : public ASTPositionNode { : INHERITED(position) , fKind(kind) {} - SkString description() const override { + String description() const override { switch (fKind) { case kPostIncrement_Kind: - return SkString("++"); + return String("++"); case kPostDecrement_Kind: - return SkString("--"); + return String("--"); default: ABORT("unsupported suffix operator"); - } + } } Kind fKind; diff --git a/src/sksl/ast/SkSLASTSuffixExpression.h b/src/sksl/ast/SkSLASTSuffixExpression.h index 7ee200fd43..2cff9a865f 100644 --- a/src/sksl/ast/SkSLASTSuffixExpression.h +++ b/src/sksl/ast/SkSLASTSuffixExpression.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTSUFFIXEXPRESSION #define SKSL_ASTSUFFIXEXPRESSION @@ -22,7 +22,7 @@ struct ASTSuffixExpression : public ASTExpression { , fBase(std::move(base)) , fSuffix(std::move(suffix)) {} - SkString description() const override { + String description() const override { return fBase->description() + fSuffix->description(); } diff --git a/src/sksl/ast/SkSLASTSwitchCase.h b/src/sksl/ast/SkSLASTSwitchCase.h index 2c0a01c7fa..405013a6a7 100644 --- a/src/sksl/ast/SkSLASTSwitchCase.h +++ b/src/sksl/ast/SkSLASTSwitchCase.h @@ -23,8 +23,8 @@ struct ASTSwitchCase : public ASTStatement { , fValue(std::move(value)) , fStatements(std::move(statements)) {} - SkString description() const override { - SkString result; + String description() const override { + String result; if (fValue) { result.appendf("case %s:\n", fValue->description().c_str()); } else { diff --git a/src/sksl/ast/SkSLASTSwitchStatement.h b/src/sksl/ast/SkSLASTSwitchStatement.h index 3031a7d2b1..4a963ebc7a 100644 --- a/src/sksl/ast/SkSLASTSwitchStatement.h +++ b/src/sksl/ast/SkSLASTSwitchStatement.h @@ -23,8 +23,8 @@ struct ASTSwitchStatement : public ASTStatement { , fValue(std::move(value)) , fCases(std::move(cases)) {} - SkString description() const override { - SkString result = SkStringPrintf("switch (%s) {\n", + fValue->description().c_str()); + String description() const override { + String result = String::printf("switch (%s) {\n", + fValue->description().c_str()); for (const auto& c : fCases) { result += c->description(); } diff --git a/src/sksl/ast/SkSLASTTernaryExpression.h b/src/sksl/ast/SkSLASTTernaryExpression.h index ddf8e3d120..07c92975e0 100644 --- a/src/sksl/ast/SkSLASTTernaryExpression.h +++ b/src/sksl/ast/SkSLASTTernaryExpression.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTTERNARYEXPRESSION #define SKSL_ASTTERNARYEXPRESSION @@ -24,9 +24,9 @@ struct ASTTernaryExpression : public ASTExpression { , fIfTrue(std::move(ifTrue)) , fIfFalse(std::move(ifFalse)) {} - SkString description() const override { + String description() const override { return "(" + fTest->description() + " ? " + fIfTrue->description() + " : " + - fIfFalse->description() + ")"; + fIfFalse->description() + ")"; } const std::unique_ptr<ASTExpression> fTest; diff --git a/src/sksl/ast/SkSLASTType.h b/src/sksl/ast/SkSLASTType.h index b95c3d7a0b..57a8025b7b 100644 --- a/src/sksl/ast/SkSLASTType.h +++ b/src/sksl/ast/SkSLASTType.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTTYPE #define SKSL_ASTTYPE @@ -21,17 +21,17 @@ struct ASTType : public ASTPositionNode { kStruct_Kind }; - ASTType(Position position, SkString name, Kind kind, std::vector<int> sizes) + ASTType(Position position, String name, Kind kind, std::vector<int> sizes) : INHERITED(position) , fName(std::move(name)) , fKind(kind) , fSizes(std::move(sizes)) {} - SkString description() const override { + String description() const override { return fName; } - const SkString fName; + const String fName; const Kind fKind; diff --git a/src/sksl/ast/SkSLASTVarDeclaration.h b/src/sksl/ast/SkSLASTVarDeclaration.h index 7d50a06a50..2dcb9787ea 100644 --- a/src/sksl/ast/SkSLASTVarDeclaration.h +++ b/src/sksl/ast/SkSLASTVarDeclaration.h @@ -22,15 +22,15 @@ namespace SkSL { * instances. */ struct ASTVarDeclaration { - ASTVarDeclaration(const SkString name, + ASTVarDeclaration(const String name, std::vector<std::unique_ptr<ASTExpression>> sizes, std::unique_ptr<ASTExpression> value) : fName(name) , fSizes(std::move(sizes)) , fValue(std::move(value)) {} - SkString description() const { - SkString result = fName; + String description() const { + String result = fName; for (const auto& size : fSizes) { if (size) { result += "[" + size->description() + "]"; @@ -44,7 +44,7 @@ struct ASTVarDeclaration { return result; } - SkString fName; + String 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)) {} - SkString description() const override { - SkString result = fModifiers.description() + fType->description() + " "; - SkString separator; + String description() const override { + String result = fModifiers.description() + fType->description() + " "; + String separator; for (const auto& var : fVars) { result += separator; separator = ", "; diff --git a/src/sksl/ast/SkSLASTVarDeclarationStatement.h b/src/sksl/ast/SkSLASTVarDeclarationStatement.h index d71639d797..c3a4069ba0 100644 --- a/src/sksl/ast/SkSLASTVarDeclarationStatement.h +++ b/src/sksl/ast/SkSLASTVarDeclarationStatement.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTVARDECLARATIONSTATEMENT #define SKSL_ASTVARDECLARATIONSTATEMENT @@ -21,7 +21,7 @@ struct ASTVarDeclarationStatement : public ASTStatement { : INHERITED(decl->fPosition, kVarDeclaration_Kind) , fDeclarations(std::move(decl)) {} - SkString description() const override { + String description() const override { return fDeclarations->description() + ";"; } diff --git a/src/sksl/ast/SkSLASTWhileStatement.h b/src/sksl/ast/SkSLASTWhileStatement.h index 853ac8028d..e63c50293a 100644 --- a/src/sksl/ast/SkSLASTWhileStatement.h +++ b/src/sksl/ast/SkSLASTWhileStatement.h @@ -4,7 +4,7 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ - + #ifndef SKSL_ASTWHILESTATEMENT #define SKSL_ASTWHILESTATEMENT @@ -16,13 +16,13 @@ namespace SkSL { * A 'while' statement. */ struct ASTWhileStatement : public ASTStatement { - ASTWhileStatement(Position position, std::unique_ptr<ASTExpression> test, + ASTWhileStatement(Position position, std::unique_ptr<ASTExpression> test, std::unique_ptr<ASTStatement> statement) : INHERITED(position, kWhile_Kind) , fTest(std::move(test)) , fStatement(std::move(statement)) {} - SkString description() const override { + String description() const override { return "while (" + fTest->description() + ") " + fStatement->description(); } |