diff options
Diffstat (limited to 'src/sksl/ast')
38 files changed, 101 insertions, 97 deletions
diff --git a/src/sksl/ast/SkSLASTBinaryExpression.h b/src/sksl/ast/SkSLASTBinaryExpression.h index 9a24970262..c2f7b749a5 100644 --- a/src/sksl/ast/SkSLASTBinaryExpression.h +++ b/src/sksl/ast/SkSLASTBinaryExpression.h @@ -9,7 +9,8 @@ #define SKSL_ASTBINARYEXPRESSION #include "SkSLASTExpression.h" -#include "../SkSLToken.h" +#include "../SkSLCompiler.h" +#include "../SkSLLexer.h" namespace SkSL { @@ -19,13 +20,13 @@ namespace SkSL { struct ASTBinaryExpression : public ASTExpression { ASTBinaryExpression(std::unique_ptr<ASTExpression> left, Token op, std::unique_ptr<ASTExpression> right) - : INHERITED(op.fPosition, kBinary_Kind) + : INHERITED(op.fOffset, kBinary_Kind) , fLeft(std::move(left)) , fOperator(op.fKind) , fRight(std::move(right)) {} String description() const override { - return "(" + fLeft->description() + " " + Token::OperatorName(fOperator) + " " + + return "(" + fLeft->description() + " " + Compiler::OperatorName(fOperator) + " " + fRight->description() + ")"; } diff --git a/src/sksl/ast/SkSLASTBlock.h b/src/sksl/ast/SkSLASTBlock.h index 37c0e81a95..df01f62a15 100644 --- a/src/sksl/ast/SkSLASTBlock.h +++ b/src/sksl/ast/SkSLASTBlock.h @@ -16,8 +16,8 @@ namespace SkSL { * 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) + ASTBlock(int offset, std::vector<std::unique_ptr<ASTStatement>> statements) + : INHERITED(offset, kBlock_Kind) , fStatements(std::move(statements)) {} String description() const override { diff --git a/src/sksl/ast/SkSLASTBoolLiteral.h b/src/sksl/ast/SkSLASTBoolLiteral.h index 48e916eed5..6782d36e7e 100644 --- a/src/sksl/ast/SkSLASTBoolLiteral.h +++ b/src/sksl/ast/SkSLASTBoolLiteral.h @@ -16,8 +16,8 @@ namespace SkSL { * Represents "true" or "false". */ struct ASTBoolLiteral : public ASTExpression { - ASTBoolLiteral(Position position, bool value) - : INHERITED(position, kBool_Kind) + ASTBoolLiteral(int offset, bool value) + : INHERITED(offset, kBool_Kind) , fValue(value) {} String description() const override { diff --git a/src/sksl/ast/SkSLASTBreakStatement.h b/src/sksl/ast/SkSLASTBreakStatement.h index 079ee76d20..2937dae447 100644 --- a/src/sksl/ast/SkSLASTBreakStatement.h +++ b/src/sksl/ast/SkSLASTBreakStatement.h @@ -16,8 +16,8 @@ namespace SkSL { * A 'break' statement. */ struct ASTBreakStatement : public ASTStatement { - ASTBreakStatement(Position position) - : INHERITED(position, kBreak_Kind) {} + ASTBreakStatement(int offset) + : INHERITED(offset, kBreak_Kind) {} String description() const override { return String("break;"); diff --git a/src/sksl/ast/SkSLASTCallSuffix.h b/src/sksl/ast/SkSLASTCallSuffix.h index 3ba3f0e60f..316a0ae7cc 100644 --- a/src/sksl/ast/SkSLASTCallSuffix.h +++ b/src/sksl/ast/SkSLASTCallSuffix.h @@ -17,8 +17,8 @@ namespace SkSL { * 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) - : INHERITED(position, ASTSuffix::kCall_Kind) + ASTCallSuffix(int offset, std::vector<std::unique_ptr<ASTExpression>> arguments) + : INHERITED(offset, ASTSuffix::kCall_Kind) , fArguments(std::move(arguments)) {} String description() const override { diff --git a/src/sksl/ast/SkSLASTContinueStatement.h b/src/sksl/ast/SkSLASTContinueStatement.h index fdfce8598d..30b2dae4ec 100644 --- a/src/sksl/ast/SkSLASTContinueStatement.h +++ b/src/sksl/ast/SkSLASTContinueStatement.h @@ -16,8 +16,8 @@ namespace SkSL { * A 'continue' statement. */ struct ASTContinueStatement : public ASTStatement { - ASTContinueStatement(Position position) - : INHERITED(position, kContinue_Kind) {} + ASTContinueStatement(int offset) + : INHERITED(offset, kContinue_Kind) {} String description() const override { return String("continue;"); diff --git a/src/sksl/ast/SkSLASTDeclaration.h b/src/sksl/ast/SkSLASTDeclaration.h index 873c6b2208..53aa65f6f2 100644 --- a/src/sksl/ast/SkSLASTDeclaration.h +++ b/src/sksl/ast/SkSLASTDeclaration.h @@ -26,8 +26,8 @@ struct ASTDeclaration : public ASTPositionNode { kSection_Kind }; - ASTDeclaration(Position position, Kind kind) - : INHERITED(position) + ASTDeclaration(int offset, Kind kind) + : INHERITED(offset) , fKind(kind) {} Kind fKind; diff --git a/src/sksl/ast/SkSLASTDiscardStatement.h b/src/sksl/ast/SkSLASTDiscardStatement.h index dcf6b15e64..083c3f82d7 100644 --- a/src/sksl/ast/SkSLASTDiscardStatement.h +++ b/src/sksl/ast/SkSLASTDiscardStatement.h @@ -16,8 +16,8 @@ namespace SkSL { * A 'discard' statement. */ struct ASTDiscardStatement : public ASTStatement { - ASTDiscardStatement(Position position) - : INHERITED(position, kDiscard_Kind) {} + ASTDiscardStatement(int offset) + : INHERITED(offset, kDiscard_Kind) {} String description() const override { return String("discard;"); diff --git a/src/sksl/ast/SkSLASTDoStatement.h b/src/sksl/ast/SkSLASTDoStatement.h index fc97d9e142..36324e3685 100644 --- a/src/sksl/ast/SkSLASTDoStatement.h +++ b/src/sksl/ast/SkSLASTDoStatement.h @@ -16,9 +16,9 @@ namespace SkSL { * A 'do' loop. */ struct ASTDoStatement : public ASTStatement { - ASTDoStatement(Position position, std::unique_ptr<ASTStatement> statement, + ASTDoStatement(int offset, std::unique_ptr<ASTStatement> statement, std::unique_ptr<ASTExpression> test) - : INHERITED(position, kDo_Kind) + : INHERITED(offset, kDo_Kind) , fStatement(std::move(statement)) , fTest(std::move(test)) {} diff --git a/src/sksl/ast/SkSLASTExpression.h b/src/sksl/ast/SkSLASTExpression.h index 11815aef84..0d8ddc781f 100644 --- a/src/sksl/ast/SkSLASTExpression.h +++ b/src/sksl/ast/SkSLASTExpression.h @@ -27,8 +27,8 @@ struct ASTExpression : public ASTPositionNode { kTernary_Kind }; - ASTExpression(Position position, Kind kind) - : INHERITED(position) + ASTExpression(int offset, Kind kind) + : INHERITED(offset) , fKind(kind) {} const Kind fKind; diff --git a/src/sksl/ast/SkSLASTExpressionStatement.h b/src/sksl/ast/SkSLASTExpressionStatement.h index 398a16a23a..14f087f57c 100644 --- a/src/sksl/ast/SkSLASTExpressionStatement.h +++ b/src/sksl/ast/SkSLASTExpressionStatement.h @@ -17,7 +17,7 @@ namespace SkSL { */ struct ASTExpressionStatement : public ASTStatement { ASTExpressionStatement(std::unique_ptr<ASTExpression> expression) - : INHERITED(expression->fPosition, kExpression_Kind) + : INHERITED(expression->fOffset, kExpression_Kind) , fExpression(std::move(expression)) {} String description() const override { diff --git a/src/sksl/ast/SkSLASTExtension.h b/src/sksl/ast/SkSLASTExtension.h index a6fde0694c..c394b1d4d0 100644 --- a/src/sksl/ast/SkSLASTExtension.h +++ b/src/sksl/ast/SkSLASTExtension.h @@ -16,8 +16,8 @@ namespace SkSL { * An extension declaration. */ struct ASTExtension : public ASTDeclaration { - ASTExtension(Position position, String name) - : INHERITED(position, kExtension_Kind) + ASTExtension(int offset, String name) + : INHERITED(offset, kExtension_Kind) , fName(std::move(name)) {} String description() const override { diff --git a/src/sksl/ast/SkSLASTFieldSuffix.h b/src/sksl/ast/SkSLASTFieldSuffix.h index bde1e4aec5..b29ddf3bda 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, String field) - : INHERITED(position, ASTSuffix::kField_Kind) - , fField(std::move(field)) {} + ASTFieldSuffix(int offset, StringFragment field) + : INHERITED(offset, ASTSuffix::kField_Kind) + , fField(field) {} String description() const override { return "." + fField; } - String fField; + StringFragment fField; typedef ASTSuffix INHERITED; }; diff --git a/src/sksl/ast/SkSLASTFloatLiteral.h b/src/sksl/ast/SkSLASTFloatLiteral.h index 15fe836049..6e63b4e4ca 100644 --- a/src/sksl/ast/SkSLASTFloatLiteral.h +++ b/src/sksl/ast/SkSLASTFloatLiteral.h @@ -16,8 +16,8 @@ namespace SkSL { * A literal floating point number. */ struct ASTFloatLiteral : public ASTExpression { - ASTFloatLiteral(Position position, double value) - : INHERITED(position, kFloat_Kind) + ASTFloatLiteral(int offset, double value) + : INHERITED(offset, kFloat_Kind) , fValue(value) {} String description() const override { diff --git a/src/sksl/ast/SkSLASTForStatement.h b/src/sksl/ast/SkSLASTForStatement.h index 326713eb62..713f9522f7 100644 --- a/src/sksl/ast/SkSLASTForStatement.h +++ b/src/sksl/ast/SkSLASTForStatement.h @@ -16,10 +16,10 @@ namespace SkSL { * A 'for' loop. */ struct ASTForStatement : public ASTStatement { - ASTForStatement(Position position, std::unique_ptr<ASTStatement> initializer, + ASTForStatement(int offset, std::unique_ptr<ASTStatement> initializer, std::unique_ptr<ASTExpression> test, std::unique_ptr<ASTExpression> next, std::unique_ptr<ASTStatement> statement) - : INHERITED(position, kFor_Kind) + : INHERITED(offset, kFor_Kind) , fInitializer(std::move(initializer)) , fTest(std::move(test)) , fNext(std::move(next)) diff --git a/src/sksl/ast/SkSLASTFunction.h b/src/sksl/ast/SkSLASTFunction.h index 36d8a3af9f..4fa2482d8b 100644 --- a/src/sksl/ast/SkSLASTFunction.h +++ b/src/sksl/ast/SkSLASTFunction.h @@ -19,13 +19,13 @@ namespace SkSL { * A function declaration or definition. The fBody field will be null for declarations. */ struct ASTFunction : public ASTDeclaration { - ASTFunction(Position position, Modifiers modifiers, std::unique_ptr<ASTType> returnType, - String name, std::vector<std::unique_ptr<ASTParameter>> parameters, + ASTFunction(int offset, Modifiers modifiers, std::unique_ptr<ASTType> returnType, + StringFragment name, std::vector<std::unique_ptr<ASTParameter>> parameters, std::unique_ptr<ASTBlock> body) - : INHERITED(position, kFunction_Kind) + : INHERITED(offset, kFunction_Kind) , fModifiers(modifiers) , fReturnType(std::move(returnType)) - , fName(std::move(name)) + , fName(name) , fParameters(std::move(parameters)) , fBody(std::move(body)) {} @@ -47,7 +47,7 @@ struct ASTFunction : public ASTDeclaration { const Modifiers fModifiers; const std::unique_ptr<ASTType> fReturnType; - const String fName; + const StringFragment 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 016123cf8c..a84370ec3f 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, String text) - : INHERITED(position, kIdentifier_Kind) - , fText(std::move(text)) {} + ASTIdentifier(int offset, StringFragment text) + : INHERITED(offset, kIdentifier_Kind) + , fText(text) {} String description() const override { - return fText; + return String(fText); } - const String fText; + const StringFragment fText; typedef ASTExpression INHERITED; }; diff --git a/src/sksl/ast/SkSLASTIfStatement.h b/src/sksl/ast/SkSLASTIfStatement.h index 2752b2b750..85b1239e0b 100644 --- a/src/sksl/ast/SkSLASTIfStatement.h +++ b/src/sksl/ast/SkSLASTIfStatement.h @@ -16,9 +16,9 @@ namespace SkSL { * An 'if' statement. */ struct ASTIfStatement : public ASTStatement { - ASTIfStatement(Position position, bool isStatic, std::unique_ptr<ASTExpression> test, + ASTIfStatement(int offset, bool isStatic, std::unique_ptr<ASTExpression> test, std::unique_ptr<ASTStatement> ifTrue, std::unique_ptr<ASTStatement> ifFalse) - : INHERITED(position, kIf_Kind) + : INHERITED(offset, kIf_Kind) , fIsStatic(isStatic) , fTest(std::move(test)) , fIfTrue(std::move(ifTrue)) diff --git a/src/sksl/ast/SkSLASTIndexSuffix.h b/src/sksl/ast/SkSLASTIndexSuffix.h index 31142e3685..cb19e549ef 100644 --- a/src/sksl/ast/SkSLASTIndexSuffix.h +++ b/src/sksl/ast/SkSLASTIndexSuffix.h @@ -18,12 +18,12 @@ namespace SkSL { * 'float[](5, 6)' are represented with a null fExpression. */ struct ASTIndexSuffix : public ASTSuffix { - ASTIndexSuffix(Position position) - : INHERITED(position, ASTSuffix::kIndex_Kind) + ASTIndexSuffix(int offset) + : INHERITED(offset, ASTSuffix::kIndex_Kind) , fExpression(nullptr) {} ASTIndexSuffix(std::unique_ptr<ASTExpression> expression) - : INHERITED(expression ? expression->fPosition : Position(), ASTSuffix::kIndex_Kind) + : INHERITED(expression ? expression->fOffset : -1, ASTSuffix::kIndex_Kind) , fExpression(std::move(expression)) {} String description() const override { diff --git a/src/sksl/ast/SkSLASTIntLiteral.h b/src/sksl/ast/SkSLASTIntLiteral.h index fe04347fd8..927537b250 100644 --- a/src/sksl/ast/SkSLASTIntLiteral.h +++ b/src/sksl/ast/SkSLASTIntLiteral.h @@ -17,8 +17,8 @@ namespace SkSL { * appear as a unary minus being applied to an integer literal. */ struct ASTIntLiteral : public ASTExpression { - ASTIntLiteral(Position position, uint64_t value) - : INHERITED(position, kInt_Kind) + ASTIntLiteral(int offset, uint64_t value) + : INHERITED(offset, kInt_Kind) , fValue(value) {} String description() const override { diff --git a/src/sksl/ast/SkSLASTInterfaceBlock.h b/src/sksl/ast/SkSLASTInterfaceBlock.h index f111f73e18..d445ae0398 100644 --- a/src/sksl/ast/SkSLASTInterfaceBlock.h +++ b/src/sksl/ast/SkSLASTInterfaceBlock.h @@ -23,17 +23,17 @@ namespace SkSL { */ struct ASTInterfaceBlock : public ASTDeclaration { // valueName is empty when it was not present in the source - ASTInterfaceBlock(Position position, + ASTInterfaceBlock(int offset, Modifiers modifiers, - String typeName, + StringFragment typeName, std::vector<std::unique_ptr<ASTVarDeclarations>> declarations, - String instanceName, + StringFragment instanceName, std::vector<std::unique_ptr<ASTExpression>> sizes) - : INHERITED(position, kInterfaceBlock_Kind) + : INHERITED(offset, kInterfaceBlock_Kind) , fModifiers(modifiers) - , fTypeName(std::move(typeName)) + , fTypeName(typeName) , fDeclarations(std::move(declarations)) - , fInstanceName(std::move(instanceName)) + , fInstanceName(instanceName) , fSizes(std::move(sizes)) {} String description() const override { @@ -42,7 +42,7 @@ struct ASTInterfaceBlock : public ASTDeclaration { result += fDeclarations[i]->description() + "\n"; } result += "}"; - if (fInstanceName.size()) { + if (fInstanceName.fLength) { result += " " + fInstanceName; for (const auto& size : fSizes) { result += "["; @@ -56,9 +56,9 @@ struct ASTInterfaceBlock : public ASTDeclaration { } const Modifiers fModifiers; - const String fTypeName; + const StringFragment fTypeName; const std::vector<std::unique_ptr<ASTVarDeclarations>> fDeclarations; - const String fInstanceName; + const StringFragment 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 ba07f168b2..5269cd54d4 100644 --- a/src/sksl/ast/SkSLASTModifiersDeclaration.h +++ b/src/sksl/ast/SkSLASTModifiersDeclaration.h @@ -20,7 +20,7 @@ namespace SkSL { */ struct ASTModifiersDeclaration : public ASTDeclaration { ASTModifiersDeclaration(Modifiers modifiers) - : INHERITED(Position(), kModifiers_Kind) + : INHERITED(-1, kModifiers_Kind) , fModifiers(modifiers) {} String description() const { diff --git a/src/sksl/ast/SkSLASTParameter.h b/src/sksl/ast/SkSLASTParameter.h index 01227c637e..965e374540 100644 --- a/src/sksl/ast/SkSLASTParameter.h +++ b/src/sksl/ast/SkSLASTParameter.h @@ -20,12 +20,12 @@ namespace SkSL { 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, - String name, std::vector<int> sizes) - : INHERITED(position) + ASTParameter(int offset, Modifiers modifiers, std::unique_ptr<ASTType> type, + StringFragment name, std::vector<int> sizes) + : INHERITED(offset) , fModifiers(modifiers) , fType(std::move(type)) - , fName(std::move(name)) + , fName(name) , fSizes(std::move(sizes)) {} String description() const override { @@ -38,7 +38,7 @@ struct ASTParameter : public ASTPositionNode { const Modifiers fModifiers; const std::unique_ptr<ASTType> fType; - const String fName; + const StringFragment fName; const std::vector<int> fSizes; typedef ASTPositionNode INHERITED; diff --git a/src/sksl/ast/SkSLASTPositionNode.h b/src/sksl/ast/SkSLASTPositionNode.h index cc435c486c..b8f22a765b 100644 --- a/src/sksl/ast/SkSLASTPositionNode.h +++ b/src/sksl/ast/SkSLASTPositionNode.h @@ -17,10 +17,12 @@ namespace SkSL { * An AST node with an associated position in the source. */ struct ASTPositionNode : public ASTNode { - ASTPositionNode(Position position) - : fPosition(position) {} + ASTPositionNode(int offset) + : fOffset(offset) {} - const Position fPosition; + // character offset of this element within the program being compiled, for error reporting + // purposes + const int fOffset; }; } // namespace diff --git a/src/sksl/ast/SkSLASTPrecision.h b/src/sksl/ast/SkSLASTPrecision.h index 4b50ed3979..0b81ca3887 100644 --- a/src/sksl/ast/SkSLASTPrecision.h +++ b/src/sksl/ast/SkSLASTPrecision.h @@ -18,8 +18,8 @@ namespace SkSL { */ struct ASTPrecision : public ASTDeclaration { // FIXME handle the type - ASTPrecision(Position position, Modifiers::Flag precision) - : INHERITED(position, kPrecision_Kind) + ASTPrecision(int offset, Modifiers::Flag precision) + : INHERITED(offset, kPrecision_Kind) , fPrecision(precision) {} String description() const { diff --git a/src/sksl/ast/SkSLASTPrefixExpression.h b/src/sksl/ast/SkSLASTPrefixExpression.h index 08e50f7bf1..0403a2f172 100644 --- a/src/sksl/ast/SkSLASTPrefixExpression.h +++ b/src/sksl/ast/SkSLASTPrefixExpression.h @@ -9,7 +9,8 @@ #define SKSL_ASTPREFIXEXPRESSION #include "SkSLASTExpression.h" -#include "../SkSLToken.h" +#include "../SkSLCompiler.h" +#include "../SkSLLexer.h" namespace SkSL { @@ -18,12 +19,12 @@ namespace SkSL { */ struct ASTPrefixExpression : public ASTExpression { ASTPrefixExpression(Token op, std::unique_ptr<ASTExpression> operand) - : INHERITED(op.fPosition, kPrefix_Kind) + : INHERITED(op.fOffset, kPrefix_Kind) , fOperator(op.fKind) , fOperand(std::move(operand)) {} String description() const override { - return Token::OperatorName(fOperator) + fOperand->description(); + return Compiler::OperatorName(fOperator) + fOperand->description(); } const Token::Kind fOperator; diff --git a/src/sksl/ast/SkSLASTReturnStatement.h b/src/sksl/ast/SkSLASTReturnStatement.h index 6762eb3f90..489658a78b 100644 --- a/src/sksl/ast/SkSLASTReturnStatement.h +++ b/src/sksl/ast/SkSLASTReturnStatement.h @@ -17,8 +17,8 @@ namespace SkSL { */ struct ASTReturnStatement : public ASTStatement { // expression may be null - ASTReturnStatement(Position position, std::unique_ptr<ASTExpression> expression) - : INHERITED(position, kReturn_Kind) + ASTReturnStatement(int offset, std::unique_ptr<ASTExpression> expression) + : INHERITED(offset, kReturn_Kind) , fExpression(std::move(expression)) {} String description() const override { diff --git a/src/sksl/ast/SkSLASTSection.h b/src/sksl/ast/SkSLASTSection.h index d0887e20fe..6c1f8eefa2 100644 --- a/src/sksl/ast/SkSLASTSection.h +++ b/src/sksl/ast/SkSLASTSection.h @@ -16,8 +16,8 @@ namespace SkSL { * A section declaration (e.g. @body { body code here }).. */ struct ASTSection : public ASTDeclaration { - ASTSection(Position position, String name, String arg, String text) - : INHERITED(position, kSection_Kind) + ASTSection(int offset, String name, String arg, String text) + : INHERITED(offset, kSection_Kind) , fName(std::move(name)) , fArgument(std::move(arg)) , fText(std::move(text)) {} diff --git a/src/sksl/ast/SkSLASTStatement.h b/src/sksl/ast/SkSLASTStatement.h index 1989a1fce6..c22a2fbb0a 100644 --- a/src/sksl/ast/SkSLASTStatement.h +++ b/src/sksl/ast/SkSLASTStatement.h @@ -33,8 +33,8 @@ struct ASTStatement : public ASTPositionNode { kDiscard_Kind }; - ASTStatement(Position position, Kind kind) - : INHERITED(position) + ASTStatement(int offset, Kind kind) + : INHERITED(offset) , fKind(kind) {} Kind fKind; diff --git a/src/sksl/ast/SkSLASTSuffix.h b/src/sksl/ast/SkSLASTSuffix.h index f06c6fd362..898855c478 100644 --- a/src/sksl/ast/SkSLASTSuffix.h +++ b/src/sksl/ast/SkSLASTSuffix.h @@ -26,8 +26,8 @@ struct ASTSuffix : public ASTPositionNode { kPostDecrement_Kind }; - ASTSuffix(Position position, Kind kind) - : INHERITED(position) + ASTSuffix(int offset, Kind kind) + : INHERITED(offset) , fKind(kind) {} String description() const override { diff --git a/src/sksl/ast/SkSLASTSuffixExpression.h b/src/sksl/ast/SkSLASTSuffixExpression.h index 2cff9a865f..31cddb29d1 100644 --- a/src/sksl/ast/SkSLASTSuffixExpression.h +++ b/src/sksl/ast/SkSLASTSuffixExpression.h @@ -18,7 +18,7 @@ namespace SkSL { */ struct ASTSuffixExpression : public ASTExpression { ASTSuffixExpression(std::unique_ptr<ASTExpression> base, std::unique_ptr<ASTSuffix> suffix) - : INHERITED(base->fPosition, kSuffix_Kind) + : INHERITED(base->fOffset, kSuffix_Kind) , fBase(std::move(base)) , fSuffix(std::move(suffix)) {} diff --git a/src/sksl/ast/SkSLASTSwitchCase.h b/src/sksl/ast/SkSLASTSwitchCase.h index 405013a6a7..221e2128ed 100644 --- a/src/sksl/ast/SkSLASTSwitchCase.h +++ b/src/sksl/ast/SkSLASTSwitchCase.h @@ -17,9 +17,9 @@ namespace SkSL { */ struct ASTSwitchCase : public ASTStatement { // a null value means "default:" - ASTSwitchCase(Position position, std::unique_ptr<ASTExpression> value, + ASTSwitchCase(int offset, std::unique_ptr<ASTExpression> value, std::vector<std::unique_ptr<ASTStatement>> statements) - : INHERITED(position, kSwitch_Kind) + : INHERITED(offset, kSwitch_Kind) , fValue(std::move(value)) , fStatements(std::move(statements)) {} diff --git a/src/sksl/ast/SkSLASTSwitchStatement.h b/src/sksl/ast/SkSLASTSwitchStatement.h index ecd0a6755d..3bee0a4728 100644 --- a/src/sksl/ast/SkSLASTSwitchStatement.h +++ b/src/sksl/ast/SkSLASTSwitchStatement.h @@ -17,9 +17,9 @@ namespace SkSL { * A 'switch' statement. */ struct ASTSwitchStatement : public ASTStatement { - ASTSwitchStatement(Position position, bool isStatic, std::unique_ptr<ASTExpression> value, + ASTSwitchStatement(int offset, bool isStatic, std::unique_ptr<ASTExpression> value, std::vector<std::unique_ptr<ASTSwitchCase>> cases) - : INHERITED(position, kSwitch_Kind) + : INHERITED(offset, kSwitch_Kind) , fIsStatic(isStatic) , fValue(std::move(value)) , fCases(std::move(cases)) {} diff --git a/src/sksl/ast/SkSLASTTernaryExpression.h b/src/sksl/ast/SkSLASTTernaryExpression.h index 07c92975e0..35795e9f12 100644 --- a/src/sksl/ast/SkSLASTTernaryExpression.h +++ b/src/sksl/ast/SkSLASTTernaryExpression.h @@ -19,7 +19,7 @@ struct ASTTernaryExpression : public ASTExpression { ASTTernaryExpression(std::unique_ptr<ASTExpression> test, std::unique_ptr<ASTExpression> ifTrue, std::unique_ptr<ASTExpression> ifFalse) - : INHERITED(test->fPosition, kTernary_Kind) + : INHERITED(test->fOffset, kTernary_Kind) , fTest(std::move(test)) , fIfTrue(std::move(ifTrue)) , fIfFalse(std::move(ifFalse)) {} diff --git a/src/sksl/ast/SkSLASTType.h b/src/sksl/ast/SkSLASTType.h index 57a8025b7b..44fd95bdc7 100644 --- a/src/sksl/ast/SkSLASTType.h +++ b/src/sksl/ast/SkSLASTType.h @@ -21,9 +21,9 @@ struct ASTType : public ASTPositionNode { kStruct_Kind }; - ASTType(Position position, String name, Kind kind, std::vector<int> sizes) - : INHERITED(position) - , fName(std::move(name)) + ASTType(int offset, StringFragment name, Kind kind, std::vector<int> sizes) + : INHERITED(offset) + , fName(name) , fKind(kind) , fSizes(std::move(sizes)) {} @@ -31,7 +31,7 @@ struct ASTType : public ASTPositionNode { return fName; } - const String fName; + const StringFragment fName; const Kind fKind; diff --git a/src/sksl/ast/SkSLASTVarDeclaration.h b/src/sksl/ast/SkSLASTVarDeclaration.h index 2dcb9787ea..38c9104865 100644 --- a/src/sksl/ast/SkSLASTVarDeclaration.h +++ b/src/sksl/ast/SkSLASTVarDeclaration.h @@ -22,7 +22,7 @@ namespace SkSL { * instances. */ struct ASTVarDeclaration { - ASTVarDeclaration(const String name, + ASTVarDeclaration(StringFragment name, std::vector<std::unique_ptr<ASTExpression>> sizes, std::unique_ptr<ASTExpression> value) : fName(name) @@ -30,7 +30,7 @@ struct ASTVarDeclaration { , fValue(std::move(value)) {} String description() const { - String result = fName; + String result(fName); for (const auto& size : fSizes) { if (size) { result += "[" + size->description() + "]"; @@ -44,7 +44,7 @@ struct ASTVarDeclaration { return result; } - String fName; + StringFragment fName; // array sizes, if any. e.g. 'foo[3][]' has sizes [3, null] std::vector<std::unique_ptr<ASTExpression>> fSizes; @@ -60,7 +60,7 @@ struct ASTVarDeclarations : public ASTDeclaration { ASTVarDeclarations(Modifiers modifiers, std::unique_ptr<ASTType> type, std::vector<ASTVarDeclaration> vars) - : INHERITED(type->fPosition, kVar_Kind) + : INHERITED(type->fOffset, kVar_Kind) , fModifiers(modifiers) , fType(std::move(type)) , fVars(std::move(vars)) {} diff --git a/src/sksl/ast/SkSLASTVarDeclarationStatement.h b/src/sksl/ast/SkSLASTVarDeclarationStatement.h index c3a4069ba0..8ec5bf6789 100644 --- a/src/sksl/ast/SkSLASTVarDeclarationStatement.h +++ b/src/sksl/ast/SkSLASTVarDeclarationStatement.h @@ -18,7 +18,7 @@ namespace SkSL { */ struct ASTVarDeclarationStatement : public ASTStatement { ASTVarDeclarationStatement(std::unique_ptr<ASTVarDeclarations> decl) - : INHERITED(decl->fPosition, kVarDeclaration_Kind) + : INHERITED(decl->fOffset, kVarDeclaration_Kind) , fDeclarations(std::move(decl)) {} String description() const override { diff --git a/src/sksl/ast/SkSLASTWhileStatement.h b/src/sksl/ast/SkSLASTWhileStatement.h index e63c50293a..c0da0afb7d 100644 --- a/src/sksl/ast/SkSLASTWhileStatement.h +++ b/src/sksl/ast/SkSLASTWhileStatement.h @@ -16,9 +16,9 @@ namespace SkSL { * A 'while' statement. */ struct ASTWhileStatement : public ASTStatement { - ASTWhileStatement(Position position, std::unique_ptr<ASTExpression> test, + ASTWhileStatement(int offset, std::unique_ptr<ASTExpression> test, std::unique_ptr<ASTStatement> statement) - : INHERITED(position, kWhile_Kind) + : INHERITED(offset, kWhile_Kind) , fTest(std::move(test)) , fStatement(std::move(statement)) {} |