aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/ir
diff options
context:
space:
mode:
Diffstat (limited to 'src/sksl/ir')
-rw-r--r--src/sksl/ir/SkSLBinaryExpression.h10
-rw-r--r--src/sksl/ir/SkSLBlock.h4
-rw-r--r--src/sksl/ir/SkSLBoolLiteral.h4
-rw-r--r--src/sksl/ir/SkSLBreakStatement.h4
-rw-r--r--src/sksl/ir/SkSLConstructor.h15
-rw-r--r--src/sksl/ir/SkSLContinueStatement.h4
-rw-r--r--src/sksl/ir/SkSLDiscardStatement.h4
-rw-r--r--src/sksl/ir/SkSLDoStatement.h4
-rw-r--r--src/sksl/ir/SkSLExpression.h4
-rw-r--r--src/sksl/ir/SkSLExpressionStatement.h2
-rw-r--r--src/sksl/ir/SkSLExtension.h4
-rw-r--r--src/sksl/ir/SkSLField.h4
-rw-r--r--src/sksl/ir/SkSLFieldAccess.h2
-rw-r--r--src/sksl/ir/SkSLFloatLiteral.h4
-rw-r--r--src/sksl/ir/SkSLForStatement.h4
-rw-r--r--src/sksl/ir/SkSLFunctionCall.h6
-rw-r--r--src/sksl/ir/SkSLFunctionDeclaration.h4
-rw-r--r--src/sksl/ir/SkSLFunctionDefinition.h4
-rw-r--r--src/sksl/ir/SkSLFunctionReference.h4
-rw-r--r--src/sksl/ir/SkSLIRNode.h10
-rw-r--r--src/sksl/ir/SkSLIfStatement.h4
-rw-r--r--src/sksl/ir/SkSLIndexExpression.h2
-rw-r--r--src/sksl/ir/SkSLIntLiteral.h4
-rw-r--r--src/sksl/ir/SkSLInterfaceBlock.h4
-rw-r--r--src/sksl/ir/SkSLModifiersDeclaration.h2
-rw-r--r--src/sksl/ir/SkSLNop.h2
-rw-r--r--src/sksl/ir/SkSLPostfixExpression.h6
-rw-r--r--src/sksl/ir/SkSLPrefixExpression.h8
-rw-r--r--src/sksl/ir/SkSLProgram.h9
-rw-r--r--src/sksl/ir/SkSLProgramElement.h4
-rw-r--r--src/sksl/ir/SkSLReturnStatement.h6
-rw-r--r--src/sksl/ir/SkSLSection.h4
-rw-r--r--src/sksl/ir/SkSLSetting.h4
-rw-r--r--src/sksl/ir/SkSLStatement.h4
-rw-r--r--src/sksl/ir/SkSLSwitchCase.h4
-rw-r--r--src/sksl/ir/SkSLSwitchStatement.h4
-rw-r--r--src/sksl/ir/SkSLSwizzle.h8
-rw-r--r--src/sksl/ir/SkSLSymbol.h8
-rw-r--r--src/sksl/ir/SkSLSymbolTable.cpp8
-rw-r--r--src/sksl/ir/SkSLSymbolTable.h8
-rw-r--r--src/sksl/ir/SkSLTernaryExpression.h4
-rw-r--r--src/sksl/ir/SkSLType.h77
-rw-r--r--src/sksl/ir/SkSLTypeReference.h6
-rw-r--r--src/sksl/ir/SkSLUnresolvedFunction.h2
-rw-r--r--src/sksl/ir/SkSLVarDeclarations.h6
-rw-r--r--src/sksl/ir/SkSLVarDeclarationsStatement.h2
-rw-r--r--src/sksl/ir/SkSLVariable.h4
-rw-r--r--src/sksl/ir/SkSLVariableReference.h23
-rw-r--r--src/sksl/ir/SkSLWhileStatement.h4
49 files changed, 184 insertions, 148 deletions
diff --git a/src/sksl/ir/SkSLBinaryExpression.h b/src/sksl/ir/SkSLBinaryExpression.h
index 789db5783b..c26994edf2 100644
--- a/src/sksl/ir/SkSLBinaryExpression.h
+++ b/src/sksl/ir/SkSLBinaryExpression.h
@@ -11,7 +11,7 @@
#include "SkSLExpression.h"
#include "SkSLExpression.h"
#include "../SkSLIRGenerator.h"
-#include "../SkSLToken.h"
+#include "../SkSLLexer.h"
namespace SkSL {
@@ -19,9 +19,9 @@ namespace SkSL {
* A binary operation.
*/
struct BinaryExpression : public Expression {
- BinaryExpression(Position position, std::unique_ptr<Expression> left, Token::Kind op,
+ BinaryExpression(int offset, std::unique_ptr<Expression> left, Token::Kind op,
std::unique_ptr<Expression> right, const Type& type)
- : INHERITED(position, kBinary_Kind, type)
+ : INHERITED(offset, kBinary_Kind, type)
, fLeft(std::move(left))
, fOperator(op)
, fRight(std::move(right)) {}
@@ -34,12 +34,12 @@ struct BinaryExpression : public Expression {
}
bool hasSideEffects() const override {
- return Token::IsAssignment(fOperator) || fLeft->hasSideEffects() ||
+ return Compiler::IsAssignment(fOperator) || fLeft->hasSideEffects() ||
fRight->hasSideEffects();
}
String description() const override {
- return "(" + fLeft->description() + " " + Token::OperatorName(fOperator) + " " +
+ return "(" + fLeft->description() + " " + Compiler::OperatorName(fOperator) + " " +
fRight->description() + ")";
}
diff --git a/src/sksl/ir/SkSLBlock.h b/src/sksl/ir/SkSLBlock.h
index bcd4bb1b59..af1975396e 100644
--- a/src/sksl/ir/SkSLBlock.h
+++ b/src/sksl/ir/SkSLBlock.h
@@ -17,9 +17,9 @@ namespace SkSL {
* A block of multiple statements functioning as a single statement.
*/
struct Block : public Statement {
- Block(Position position, std::vector<std::unique_ptr<Statement>> statements,
+ Block(int offset, std::vector<std::unique_ptr<Statement>> statements,
const std::shared_ptr<SymbolTable> symbols = nullptr)
- : INHERITED(position, kBlock_Kind)
+ : INHERITED(offset, kBlock_Kind)
, fSymbols(std::move(symbols))
, fStatements(std::move(statements)) {}
diff --git a/src/sksl/ir/SkSLBoolLiteral.h b/src/sksl/ir/SkSLBoolLiteral.h
index a4151b8b35..9a69f0f138 100644
--- a/src/sksl/ir/SkSLBoolLiteral.h
+++ b/src/sksl/ir/SkSLBoolLiteral.h
@@ -17,8 +17,8 @@ namespace SkSL {
* Represents 'true' or 'false'.
*/
struct BoolLiteral : public Expression {
- BoolLiteral(const Context& context, Position position, bool value)
- : INHERITED(position, kBoolLiteral_Kind, *context.fBool_Type)
+ BoolLiteral(const Context& context, int offset, bool value)
+ : INHERITED(offset, kBoolLiteral_Kind, *context.fBool_Type)
, fValue(value) {}
String description() const override {
diff --git a/src/sksl/ir/SkSLBreakStatement.h b/src/sksl/ir/SkSLBreakStatement.h
index f6edc558e5..da392f5960 100644
--- a/src/sksl/ir/SkSLBreakStatement.h
+++ b/src/sksl/ir/SkSLBreakStatement.h
@@ -17,8 +17,8 @@ namespace SkSL {
* A 'break' statement.
*/
struct BreakStatement : public Statement {
- BreakStatement(Position position)
- : INHERITED(position, kBreak_Kind) {}
+ BreakStatement(int offset)
+ : INHERITED(offset, kBreak_Kind) {}
String description() const override {
return String("break;");
diff --git a/src/sksl/ir/SkSLConstructor.h b/src/sksl/ir/SkSLConstructor.h
index beed0f702d..32fc0fb2e7 100644
--- a/src/sksl/ir/SkSLConstructor.h
+++ b/src/sksl/ir/SkSLConstructor.h
@@ -16,7 +16,7 @@
namespace SkSL {
/**
- * Represents the construction of a compound type, such as "float2x, y)".
+ * Represents the construction of a compound type, such as "float2(x, y)".
*
* Vector constructors will always consist of either exactly 1 scalar, or a collection of vectors
* and scalars totalling exactly the right number of scalar components.
@@ -25,9 +25,8 @@ namespace SkSL {
* collection of vectors and scalars totalling exactly the right number of scalar components.
*/
struct Constructor : public Expression {
- Constructor(Position position, const Type& type,
- std::vector<std::unique_ptr<Expression>> arguments)
- : INHERITED(position, kConstructor_Kind, type)
+ Constructor(int offset, const Type& type, std::vector<std::unique_ptr<Expression>> arguments)
+ : INHERITED(offset, kConstructor_Kind, type)
, fArguments(std::move(arguments)) {}
std::unique_ptr<Expression> constantPropagate(const IRGenerator& irGenerator,
@@ -37,13 +36,13 @@ struct Constructor : public Expression {
// promote float(1) to 1.0
int64_t intValue = ((IntLiteral&) *fArguments[0]).fValue;
return std::unique_ptr<Expression>(new FloatLiteral(irGenerator.fContext,
- fPosition,
+ fOffset,
intValue));
} else if (fType == *irGenerator.fContext.fUInt_Type) {
// promote uint(1) to 1u
int64_t intValue = ((IntLiteral&) *fArguments[0]).fValue;
return std::unique_ptr<Expression>(new IntLiteral(irGenerator.fContext,
- fPosition,
+ fOffset,
intValue,
&fType));
}
@@ -96,8 +95,8 @@ struct Constructor : public Expression {
// a constant scalar constructor should have been collapsed down to the appropriate
// literal
ASSERT(fType.kind() == Type::kMatrix_Kind);
- const FloatLiteral fzero(context, Position(), 0);
- const IntLiteral izero(context, Position(), 0);
+ const FloatLiteral fzero(context, -1, 0);
+ const IntLiteral izero(context, -1, 0);
const Expression* zero;
if (fType.componentType() == *context.fFloat_Type) {
zero = &fzero;
diff --git a/src/sksl/ir/SkSLContinueStatement.h b/src/sksl/ir/SkSLContinueStatement.h
index 3f5bc1d4bb..6ed40c404f 100644
--- a/src/sksl/ir/SkSLContinueStatement.h
+++ b/src/sksl/ir/SkSLContinueStatement.h
@@ -17,8 +17,8 @@ namespace SkSL {
* A 'continue' statement.
*/
struct ContinueStatement : public Statement {
- ContinueStatement(Position position)
- : INHERITED(position, kContinue_Kind) {}
+ ContinueStatement(int offset)
+ : INHERITED(offset, kContinue_Kind) {}
String description() const override {
return String("continue;");
diff --git a/src/sksl/ir/SkSLDiscardStatement.h b/src/sksl/ir/SkSLDiscardStatement.h
index 62124668ee..b62530e6f3 100644
--- a/src/sksl/ir/SkSLDiscardStatement.h
+++ b/src/sksl/ir/SkSLDiscardStatement.h
@@ -17,8 +17,8 @@ namespace SkSL {
* A 'discard' statement.
*/
struct DiscardStatement : public Statement {
- DiscardStatement(Position position)
- : INHERITED(position, kDiscard_Kind) {}
+ DiscardStatement(int offset)
+ : INHERITED(offset, kDiscard_Kind) {}
String description() const override {
return String("discard;");
diff --git a/src/sksl/ir/SkSLDoStatement.h b/src/sksl/ir/SkSLDoStatement.h
index f1ecd9a8bf..3abec550eb 100644
--- a/src/sksl/ir/SkSLDoStatement.h
+++ b/src/sksl/ir/SkSLDoStatement.h
@@ -17,9 +17,9 @@ namespace SkSL {
* A 'do' statement.
*/
struct DoStatement : public Statement {
- DoStatement(Position position, std::unique_ptr<Statement> statement,
+ DoStatement(int offset, std::unique_ptr<Statement> statement,
std::unique_ptr<Expression> test)
- : INHERITED(position, kDo_Kind)
+ : INHERITED(offset, kDo_Kind)
, fStatement(std::move(statement))
, fTest(std::move(test)) {}
diff --git a/src/sksl/ir/SkSLExpression.h b/src/sksl/ir/SkSLExpression.h
index 286610f078..555e66061d 100644
--- a/src/sksl/ir/SkSLExpression.h
+++ b/src/sksl/ir/SkSLExpression.h
@@ -44,8 +44,8 @@ struct Expression : public IRNode {
kDefined_Kind
};
- Expression(Position position, Kind kind, const Type& type)
- : INHERITED(position)
+ Expression(int offset, Kind kind, const Type& type)
+ : INHERITED(offset)
, fKind(kind)
, fType(std::move(type)) {}
diff --git a/src/sksl/ir/SkSLExpressionStatement.h b/src/sksl/ir/SkSLExpressionStatement.h
index d1ab8e9ed9..215763b8fd 100644
--- a/src/sksl/ir/SkSLExpressionStatement.h
+++ b/src/sksl/ir/SkSLExpressionStatement.h
@@ -18,7 +18,7 @@ namespace SkSL {
*/
struct ExpressionStatement : public Statement {
ExpressionStatement(std::unique_ptr<Expression> expression)
- : INHERITED(expression->fPosition, kExpression_Kind)
+ : INHERITED(expression->fOffset, kExpression_Kind)
, fExpression(std::move(expression)) {}
String description() const override {
diff --git a/src/sksl/ir/SkSLExtension.h b/src/sksl/ir/SkSLExtension.h
index 70dc6b3eaf..b5a48b94ab 100644
--- a/src/sksl/ir/SkSLExtension.h
+++ b/src/sksl/ir/SkSLExtension.h
@@ -16,8 +16,8 @@ namespace SkSL {
* An extension declaration.
*/
struct Extension : public ProgramElement {
- Extension(Position position, String name)
- : INHERITED(position, kExtension_Kind)
+ Extension(int offset, String name)
+ : INHERITED(offset, kExtension_Kind)
, fName(std::move(name)) {}
String description() const override {
diff --git a/src/sksl/ir/SkSLField.h b/src/sksl/ir/SkSLField.h
index abea730da1..fe2af7fa6e 100644
--- a/src/sksl/ir/SkSLField.h
+++ b/src/sksl/ir/SkSLField.h
@@ -22,8 +22,8 @@ namespace SkSL {
* result of declaring anonymous interface blocks.
*/
struct Field : public Symbol {
- Field(Position position, const Variable& owner, int fieldIndex)
- : INHERITED(position, kField_Kind, owner.fType.fields()[fieldIndex].fName)
+ Field(int offset, const Variable& owner, int fieldIndex)
+ : INHERITED(offset, kField_Kind, owner.fType.fields()[fieldIndex].fName)
, fOwner(owner)
, fFieldIndex(fieldIndex) {}
diff --git a/src/sksl/ir/SkSLFieldAccess.h b/src/sksl/ir/SkSLFieldAccess.h
index e0a335f528..0f66dec5a4 100644
--- a/src/sksl/ir/SkSLFieldAccess.h
+++ b/src/sksl/ir/SkSLFieldAccess.h
@@ -26,7 +26,7 @@ struct FieldAccess : public Expression {
FieldAccess(std::unique_ptr<Expression> base, int fieldIndex,
OwnerKind ownerKind = kDefault_OwnerKind)
- : INHERITED(base->fPosition, kFieldAccess_Kind, *base->fType.fields()[fieldIndex].fType)
+ : INHERITED(base->fOffset, kFieldAccess_Kind, *base->fType.fields()[fieldIndex].fType)
, fBase(std::move(base))
, fFieldIndex(fieldIndex)
, fOwnerKind(ownerKind) {}
diff --git a/src/sksl/ir/SkSLFloatLiteral.h b/src/sksl/ir/SkSLFloatLiteral.h
index 21a485fb0a..e6a3062f36 100644
--- a/src/sksl/ir/SkSLFloatLiteral.h
+++ b/src/sksl/ir/SkSLFloatLiteral.h
@@ -17,9 +17,9 @@ namespace SkSL {
* A literal floating point number.
*/
struct FloatLiteral : public Expression {
- FloatLiteral(const Context& context, Position position, double value,
+ FloatLiteral(const Context& context, int offset, double value,
const Type* type = nullptr)
- : INHERITED(position, kFloatLiteral_Kind, type ? *type : *context.fFloat_Type)
+ : INHERITED(offset, kFloatLiteral_Kind, type ? *type : *context.fFloat_Type)
, fValue(value) {}
String description() const override {
diff --git a/src/sksl/ir/SkSLForStatement.h b/src/sksl/ir/SkSLForStatement.h
index ca3e6cfb7a..6896ceb902 100644
--- a/src/sksl/ir/SkSLForStatement.h
+++ b/src/sksl/ir/SkSLForStatement.h
@@ -18,10 +18,10 @@ namespace SkSL {
* A 'for' statement.
*/
struct ForStatement : public Statement {
- ForStatement(Position position, std::unique_ptr<Statement> initializer,
+ ForStatement(int offset, std::unique_ptr<Statement> initializer,
std::unique_ptr<Expression> test, std::unique_ptr<Expression> next,
std::unique_ptr<Statement> statement, std::shared_ptr<SymbolTable> symbols)
- : INHERITED(position, kFor_Kind)
+ : INHERITED(offset, kFor_Kind)
, fSymbols(symbols)
, fInitializer(std::move(initializer))
, fTest(std::move(test))
diff --git a/src/sksl/ir/SkSLFunctionCall.h b/src/sksl/ir/SkSLFunctionCall.h
index 44f8c7ed5a..115281d63d 100644
--- a/src/sksl/ir/SkSLFunctionCall.h
+++ b/src/sksl/ir/SkSLFunctionCall.h
@@ -17,9 +17,9 @@ namespace SkSL {
* A function invocation.
*/
struct FunctionCall : public Expression {
- FunctionCall(Position position, const Type& type, const FunctionDeclaration& function,
+ FunctionCall(int offset, const Type& type, const FunctionDeclaration& function,
std::vector<std::unique_ptr<Expression>> arguments)
- : INHERITED(position, kFunctionCall_Kind, type)
+ : INHERITED(offset, kFunctionCall_Kind, type)
, fFunction(std::move(function))
, fArguments(std::move(arguments)) {}
@@ -33,7 +33,7 @@ struct FunctionCall : public Expression {
}
String description() const override {
- String result = fFunction.fName + "(";
+ String result = String(fFunction.fName) + "(";
String separator;
for (size_t i = 0; i < fArguments.size(); i++) {
result += separator;
diff --git a/src/sksl/ir/SkSLFunctionDeclaration.h b/src/sksl/ir/SkSLFunctionDeclaration.h
index 64236d3980..d0f9d240d7 100644
--- a/src/sksl/ir/SkSLFunctionDeclaration.h
+++ b/src/sksl/ir/SkSLFunctionDeclaration.h
@@ -21,9 +21,9 @@ namespace SkSL {
* A function declaration (not a definition -- does not contain a body).
*/
struct FunctionDeclaration : public Symbol {
- FunctionDeclaration(Position position, Modifiers modifiers, String name,
+ FunctionDeclaration(int offset, Modifiers modifiers, StringFragment name,
std::vector<const Variable*> parameters, const Type& returnType)
- : INHERITED(position, kFunctionDeclaration_Kind, std::move(name))
+ : INHERITED(offset, kFunctionDeclaration_Kind, std::move(name))
, fDefined(false)
, fBuiltin(false)
, fModifiers(modifiers)
diff --git a/src/sksl/ir/SkSLFunctionDefinition.h b/src/sksl/ir/SkSLFunctionDefinition.h
index 0277db1f07..e0dabc5791 100644
--- a/src/sksl/ir/SkSLFunctionDefinition.h
+++ b/src/sksl/ir/SkSLFunctionDefinition.h
@@ -18,9 +18,9 @@ namespace SkSL {
* A function definition (a declaration plus an associated block of code).
*/
struct FunctionDefinition : public ProgramElement {
- FunctionDefinition(Position position, const FunctionDeclaration& declaration,
+ FunctionDefinition(int offset, const FunctionDeclaration& declaration,
std::unique_ptr<Statement> body)
- : INHERITED(position, kFunction_Kind)
+ : INHERITED(offset, kFunction_Kind)
, fDeclaration(declaration)
, fBody(std::move(body)) {}
diff --git a/src/sksl/ir/SkSLFunctionReference.h b/src/sksl/ir/SkSLFunctionReference.h
index ee761c2639..58831c5e99 100644
--- a/src/sksl/ir/SkSLFunctionReference.h
+++ b/src/sksl/ir/SkSLFunctionReference.h
@@ -19,9 +19,9 @@ namespace SkSL {
* always eventually replaced by FunctionCalls in valid programs.
*/
struct FunctionReference : public Expression {
- FunctionReference(const Context& context, Position position,
+ FunctionReference(const Context& context, int offset,
std::vector<const FunctionDeclaration*> function)
- : INHERITED(position, kFunctionReference_Kind, *context.fInvalid_Type)
+ : INHERITED(offset, kFunctionReference_Kind, *context.fInvalid_Type)
, fFunctions(function) {}
bool hasSideEffects() const override {
diff --git a/src/sksl/ir/SkSLIRNode.h b/src/sksl/ir/SkSLIRNode.h
index 139be32f44..5ada50607e 100644
--- a/src/sksl/ir/SkSLIRNode.h
+++ b/src/sksl/ir/SkSLIRNode.h
@@ -8,7 +8,7 @@
#ifndef SKSL_IRNODE
#define SKSL_IRNODE
-#include "../SkSLPosition.h"
+#include "../SkSLLexer.h"
namespace SkSL {
@@ -17,14 +17,16 @@ namespace SkSL {
* version of the program (all types determined, everything validated), ready for code generation.
*/
struct IRNode {
- IRNode(Position position)
- : fPosition(position) {}
+ IRNode(int offset)
+ : fOffset(offset) {}
virtual ~IRNode() {}
virtual String description() const = 0;
- 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/ir/SkSLIfStatement.h b/src/sksl/ir/SkSLIfStatement.h
index b09c10ee95..4c2ca0b1fa 100644
--- a/src/sksl/ir/SkSLIfStatement.h
+++ b/src/sksl/ir/SkSLIfStatement.h
@@ -17,9 +17,9 @@ namespace SkSL {
* An 'if' statement.
*/
struct IfStatement : public Statement {
- IfStatement(Position position, bool isStatic, std::unique_ptr<Expression> test,
+ IfStatement(int offset, bool isStatic, std::unique_ptr<Expression> test,
std::unique_ptr<Statement> ifTrue, std::unique_ptr<Statement> ifFalse)
- : INHERITED(position, kIf_Kind)
+ : INHERITED(offset, kIf_Kind)
, fIsStatic(isStatic)
, fTest(std::move(test))
, fIfTrue(std::move(ifTrue))
diff --git a/src/sksl/ir/SkSLIndexExpression.h b/src/sksl/ir/SkSLIndexExpression.h
index c305365049..2daf1b552a 100644
--- a/src/sksl/ir/SkSLIndexExpression.h
+++ b/src/sksl/ir/SkSLIndexExpression.h
@@ -45,7 +45,7 @@ static const Type& index_type(const Context& context, const Type& type) {
struct IndexExpression : public Expression {
IndexExpression(const Context& context, std::unique_ptr<Expression> base,
std::unique_ptr<Expression> index)
- : INHERITED(base->fPosition, kIndex_Kind, index_type(context, base->fType))
+ : INHERITED(base->fOffset, kIndex_Kind, index_type(context, base->fType))
, fBase(std::move(base))
, fIndex(std::move(index)) {
ASSERT(fIndex->fType == *context.fInt_Type || fIndex->fType == *context.fUInt_Type);
diff --git a/src/sksl/ir/SkSLIntLiteral.h b/src/sksl/ir/SkSLIntLiteral.h
index 6199f96610..da2b4082de 100644
--- a/src/sksl/ir/SkSLIntLiteral.h
+++ b/src/sksl/ir/SkSLIntLiteral.h
@@ -19,8 +19,8 @@ namespace SkSL {
struct IntLiteral : public Expression {
// FIXME: we will need to revisit this if/when we add full support for both signed and unsigned
// 64-bit integers, but for right now an int64_t will hold every value we care about
- IntLiteral(const Context& context, Position position, int64_t value, const Type* type = nullptr)
- : INHERITED(position, kIntLiteral_Kind, type ? *type : *context.fInt_Type)
+ IntLiteral(const Context& context, int offset, int64_t value, const Type* type = nullptr)
+ : INHERITED(offset, kIntLiteral_Kind, type ? *type : *context.fInt_Type)
, fValue(value) {}
String description() const override {
diff --git a/src/sksl/ir/SkSLInterfaceBlock.h b/src/sksl/ir/SkSLInterfaceBlock.h
index a28a6a1b54..03986b87cd 100644
--- a/src/sksl/ir/SkSLInterfaceBlock.h
+++ b/src/sksl/ir/SkSLInterfaceBlock.h
@@ -25,10 +25,10 @@ namespace SkSL {
* At the IR level, this is represented by a single variable of struct type.
*/
struct InterfaceBlock : public ProgramElement {
- InterfaceBlock(Position position, const Variable* var, String typeName, String instanceName,
+ InterfaceBlock(int offset, const Variable* var, String typeName, String instanceName,
std::vector<std::unique_ptr<Expression>> sizes,
std::shared_ptr<SymbolTable> typeOwner)
- : INHERITED(position, kInterfaceBlock_Kind)
+ : INHERITED(offset, kInterfaceBlock_Kind)
, fVariable(*var)
, fTypeName(std::move(typeName))
, fInstanceName(std::move(instanceName))
diff --git a/src/sksl/ir/SkSLModifiersDeclaration.h b/src/sksl/ir/SkSLModifiersDeclaration.h
index a0ce74852d..5c9608f02f 100644
--- a/src/sksl/ir/SkSLModifiersDeclaration.h
+++ b/src/sksl/ir/SkSLModifiersDeclaration.h
@@ -20,7 +20,7 @@ namespace SkSL {
*/
struct ModifiersDeclaration : public ProgramElement {
ModifiersDeclaration(Modifiers modifiers)
- : INHERITED(Position(), kModifiers_Kind)
+ : INHERITED(-1, kModifiers_Kind)
, fModifiers(modifiers) {}
String description() const {
diff --git a/src/sksl/ir/SkSLNop.h b/src/sksl/ir/SkSLNop.h
index 5ebea40583..e7aae9b7b8 100644
--- a/src/sksl/ir/SkSLNop.h
+++ b/src/sksl/ir/SkSLNop.h
@@ -18,7 +18,7 @@ namespace SkSL {
*/
struct Nop : public Statement {
Nop()
- : INHERITED(Position(), kNop_Kind) {}
+ : INHERITED(-1, kNop_Kind) {}
virtual bool isEmpty() const override {
return true;
diff --git a/src/sksl/ir/SkSLPostfixExpression.h b/src/sksl/ir/SkSLPostfixExpression.h
index e02555db70..c53f1de507 100644
--- a/src/sksl/ir/SkSLPostfixExpression.h
+++ b/src/sksl/ir/SkSLPostfixExpression.h
@@ -9,7 +9,7 @@
#define SKSL_POSTFIXEXPRESSION
#include "SkSLExpression.h"
-#include "SkSLToken.h"
+#include "SkSLLexer.h"
namespace SkSL {
@@ -18,7 +18,7 @@ namespace SkSL {
*/
struct PostfixExpression : public Expression {
PostfixExpression(std::unique_ptr<Expression> operand, Token::Kind op)
- : INHERITED(operand->fPosition, kPostfix_Kind, operand->fType)
+ : INHERITED(operand->fOffset, kPostfix_Kind, operand->fType)
, fOperand(std::move(operand))
, fOperator(op) {}
@@ -27,7 +27,7 @@ struct PostfixExpression : public Expression {
}
String description() const override {
- return fOperand->description() + Token::OperatorName(fOperator);
+ return fOperand->description() + Compiler::OperatorName(fOperator);
}
std::unique_ptr<Expression> fOperand;
diff --git a/src/sksl/ir/SkSLPrefixExpression.h b/src/sksl/ir/SkSLPrefixExpression.h
index 5ac84c66b1..d5d97b2517 100644
--- a/src/sksl/ir/SkSLPrefixExpression.h
+++ b/src/sksl/ir/SkSLPrefixExpression.h
@@ -11,7 +11,7 @@
#include "SkSLExpression.h"
#include "SkSLFloatLiteral.h"
#include "SkSLIRGenerator.h"
-#include "SkSLToken.h"
+#include "SkSLLexer.h"
namespace SkSL {
@@ -20,7 +20,7 @@ namespace SkSL {
*/
struct PrefixExpression : public Expression {
PrefixExpression(Token::Kind op, std::unique_ptr<Expression> operand)
- : INHERITED(operand->fPosition, kPrefix_Kind, operand->fType)
+ : INHERITED(operand->fOffset, kPrefix_Kind, operand->fType)
, fOperand(std::move(operand))
, fOperator(op) {}
@@ -38,7 +38,7 @@ struct PrefixExpression : public Expression {
if (fOperand->fKind == Expression::kFloatLiteral_Kind) {
return std::unique_ptr<Expression>(new FloatLiteral(
irGenerator.fContext,
- Position(),
+ fOffset,
-((FloatLiteral&) *fOperand).fValue));
}
@@ -46,7 +46,7 @@ struct PrefixExpression : public Expression {
}
String description() const override {
- return Token::OperatorName(fOperator) + fOperand->description();
+ return Compiler::OperatorName(fOperator) + fOperand->description();
}
std::unique_ptr<Expression> fOperand;
diff --git a/src/sksl/ir/SkSLProgram.h b/src/sksl/ir/SkSLProgram.h
index a3eeaa3612..639e09b16a 100644
--- a/src/sksl/ir/SkSLProgram.h
+++ b/src/sksl/ir/SkSLProgram.h
@@ -39,15 +39,15 @@ struct Program {
: fKind(kInt_Kind)
, fValue(i) {}
- std::unique_ptr<Expression> literal(const Context& context, Position position) const {
+ std::unique_ptr<Expression> literal(const Context& context, int offset) const {
switch (fKind) {
case Program::Settings::Value::kBool_Kind:
return std::unique_ptr<Expression>(new BoolLiteral(context,
- position,
+ offset,
fValue));
case Program::Settings::Value::kInt_Kind:
return std::unique_ptr<Expression>(new IntLiteral(context,
- position,
+ offset,
fValue));
default:
ASSERT(false);
@@ -103,6 +103,7 @@ struct Program {
};
Program(Kind kind,
+ std::unique_ptr<String> source,
Settings settings,
Modifiers::Flag defaultPrecision,
Context* context,
@@ -110,6 +111,7 @@ struct Program {
std::shared_ptr<SymbolTable> symbols,
Inputs inputs)
: fKind(kind)
+ , fSource(std::move(source))
, fSettings(settings)
, fDefaultPrecision(defaultPrecision)
, fContext(context)
@@ -118,6 +120,7 @@ struct Program {
, fInputs(inputs) {}
Kind fKind;
+ std::unique_ptr<String> fSource;
Settings fSettings;
// FIXME handle different types; currently it assumes this is for floats
Modifiers::Flag fDefaultPrecision;
diff --git a/src/sksl/ir/SkSLProgramElement.h b/src/sksl/ir/SkSLProgramElement.h
index 1e2bb48641..4a3566d287 100644
--- a/src/sksl/ir/SkSLProgramElement.h
+++ b/src/sksl/ir/SkSLProgramElement.h
@@ -25,8 +25,8 @@ struct ProgramElement : public IRNode {
kSection_Kind
};
- ProgramElement(Position position, Kind kind)
- : INHERITED(position)
+ ProgramElement(int offset, Kind kind)
+ : INHERITED(offset)
, fKind(kind) {}
Kind fKind;
diff --git a/src/sksl/ir/SkSLReturnStatement.h b/src/sksl/ir/SkSLReturnStatement.h
index 841db94669..1b479b8097 100644
--- a/src/sksl/ir/SkSLReturnStatement.h
+++ b/src/sksl/ir/SkSLReturnStatement.h
@@ -17,11 +17,11 @@ namespace SkSL {
* A 'return' statement.
*/
struct ReturnStatement : public Statement {
- ReturnStatement(Position position)
- : INHERITED(position, kReturn_Kind) {}
+ ReturnStatement(int offset)
+ : INHERITED(offset, kReturn_Kind) {}
ReturnStatement(std::unique_ptr<Expression> expression)
- : INHERITED(expression->fPosition, kReturn_Kind)
+ : INHERITED(expression->fOffset, kReturn_Kind)
, fExpression(std::move(expression)) {}
String description() const override {
diff --git a/src/sksl/ir/SkSLSection.h b/src/sksl/ir/SkSLSection.h
index f9815b1caa..96c257b1f8 100644
--- a/src/sksl/ir/SkSLSection.h
+++ b/src/sksl/ir/SkSLSection.h
@@ -16,8 +16,8 @@ namespace SkSL {
* A section declaration (e.g. @body { body code here })..
*/
struct Section : public ProgramElement {
- Section(Position position, String name, String arg, String text)
- : INHERITED(position, kSection_Kind)
+ Section(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/ir/SkSLSetting.h b/src/sksl/ir/SkSLSetting.h
index 995fcf55bf..f479ad167b 100644
--- a/src/sksl/ir/SkSLSetting.h
+++ b/src/sksl/ir/SkSLSetting.h
@@ -18,8 +18,8 @@ namespace SkSL {
* collapsed down to their constant representations during the compilation process.
*/
struct Setting : public Expression {
- Setting(Position position, String name, std::unique_ptr<Expression> value)
- : INHERITED(position, kSetting_Kind, value->fType)
+ Setting(int offset, String name, std::unique_ptr<Expression> value)
+ : INHERITED(offset, kSetting_Kind, value->fType)
, fName(std::move(name))
, fValue(std::move(value)) {
ASSERT(fValue->isConstant());
diff --git a/src/sksl/ir/SkSLStatement.h b/src/sksl/ir/SkSLStatement.h
index 1bc524451b..a116cc1c4c 100644
--- a/src/sksl/ir/SkSLStatement.h
+++ b/src/sksl/ir/SkSLStatement.h
@@ -35,8 +35,8 @@ struct Statement : public IRNode {
kWhile_Kind
};
- Statement(Position position, Kind kind)
- : INHERITED(position)
+ Statement(int offset, Kind kind)
+ : INHERITED(offset)
, fKind(kind) {}
virtual bool isEmpty() const {
diff --git a/src/sksl/ir/SkSLSwitchCase.h b/src/sksl/ir/SkSLSwitchCase.h
index 8043f2e787..c33224bdbb 100644
--- a/src/sksl/ir/SkSLSwitchCase.h
+++ b/src/sksl/ir/SkSLSwitchCase.h
@@ -17,9 +17,9 @@ namespace SkSL {
* A single case of a 'switch' statement.
*/
struct SwitchCase : public Statement {
- SwitchCase(Position position, std::unique_ptr<Expression> value,
+ SwitchCase(int offset, std::unique_ptr<Expression> value,
std::vector<std::unique_ptr<Statement>> statements)
- : INHERITED(position, kSwitch_Kind)
+ : INHERITED(offset, kSwitch_Kind)
, fValue(std::move(value))
, fStatements(std::move(statements)) {}
diff --git a/src/sksl/ir/SkSLSwitchStatement.h b/src/sksl/ir/SkSLSwitchStatement.h
index dec5b749a5..68d0ef02df 100644
--- a/src/sksl/ir/SkSLSwitchStatement.h
+++ b/src/sksl/ir/SkSLSwitchStatement.h
@@ -17,10 +17,10 @@ namespace SkSL {
* A 'switch' statement.
*/
struct SwitchStatement : public Statement {
- SwitchStatement(Position position, bool isStatic, std::unique_ptr<Expression> value,
+ SwitchStatement(int offset, bool isStatic, std::unique_ptr<Expression> value,
std::vector<std::unique_ptr<SwitchCase>> cases,
const std::shared_ptr<SymbolTable> symbols)
- : INHERITED(position, kSwitch_Kind)
+ : INHERITED(offset, kSwitch_Kind)
, fIsStatic(isStatic)
, fValue(std::move(value))
, fSymbols(std::move(symbols))
diff --git a/src/sksl/ir/SkSLSwizzle.h b/src/sksl/ir/SkSLSwizzle.h
index 9d7ca37bdc..3256ef211a 100644
--- a/src/sksl/ir/SkSLSwizzle.h
+++ b/src/sksl/ir/SkSLSwizzle.h
@@ -65,7 +65,7 @@ static const Type& get_type(const Context& context, Expression& value, size_t co
*/
struct Swizzle : public Expression {
Swizzle(const Context& context, std::unique_ptr<Expression> base, std::vector<int> components)
- : INHERITED(base->fPosition, kSwizzle_Kind, get_type(context, *base, components.size()))
+ : INHERITED(base->fOffset, kSwizzle_Kind, get_type(context, *base, components.size()))
, fBase(std::move(base))
, fComponents(std::move(components)) {
ASSERT(fComponents.size() >= 1 && fComponents.size() <= 4);
@@ -80,13 +80,13 @@ struct Swizzle : public Expression {
ASSERT(fComponents.size() == 1);
int64_t value = ((Constructor&) *fBase).getIVecComponent(fComponents[0]);
return std::unique_ptr<Expression>(new IntLiteral(irGenerator.fContext,
- Position(),
- value));
+ -1,
+ value));
} else if (fType == *irGenerator.fContext.fFloat_Type) {
ASSERT(fComponents.size() == 1);
double value = ((Constructor&) *fBase).getFVecComponent(fComponents[0]);
return std::unique_ptr<Expression>(new FloatLiteral(irGenerator.fContext,
- Position(),
+ -1,
value));
}
}
diff --git a/src/sksl/ir/SkSLSymbol.h b/src/sksl/ir/SkSLSymbol.h
index e883ea7555..f4c675319b 100644
--- a/src/sksl/ir/SkSLSymbol.h
+++ b/src/sksl/ir/SkSLSymbol.h
@@ -24,13 +24,13 @@ struct Symbol : public IRNode {
kField_Kind
};
- Symbol(Position position, Kind kind, String name)
- : INHERITED(position)
+ Symbol(int offset, Kind kind, StringFragment name)
+ : INHERITED(offset)
, fKind(kind)
- , fName(std::move(name)) {}
+ , fName(name) {}
const Kind fKind;
- const String fName;
+ StringFragment fName;
typedef IRNode INHERITED;
};
diff --git a/src/sksl/ir/SkSLSymbolTable.cpp b/src/sksl/ir/SkSLSymbolTable.cpp
index 4d39e8bc9d..40e8e66c9f 100644
--- a/src/sksl/ir/SkSLSymbolTable.cpp
+++ b/src/sksl/ir/SkSLSymbolTable.cpp
@@ -21,7 +21,7 @@ std::vector<const FunctionDeclaration*> SymbolTable::GetFunctions(const Symbol&
}
}
-const Symbol* SymbolTable::operator[](const String& name) {
+const Symbol* SymbolTable::operator[](StringFragment name) {
const auto& entry = fSymbols.find(name);
if (entry == fSymbols.end()) {
if (fParent) {
@@ -64,12 +64,12 @@ Symbol* SymbolTable::takeOwnership(Symbol* s) {
return s;
}
-void SymbolTable::add(const String& name, std::unique_ptr<Symbol> symbol) {
+void SymbolTable::add(StringFragment name, std::unique_ptr<Symbol> symbol) {
this->addWithoutOwnership(name, symbol.get());
fOwnedPointers.push_back(std::move(symbol));
}
-void SymbolTable::addWithoutOwnership(const String& name, const Symbol* symbol) {
+void SymbolTable::addWithoutOwnership(StringFragment name, const Symbol* symbol) {
const auto& existing = fSymbols.find(name);
if (existing == fSymbols.end()) {
fSymbols[name] = symbol;
@@ -93,7 +93,7 @@ void SymbolTable::addWithoutOwnership(const String& name, const Symbol* symbol)
this->takeOwnership(u);
}
} else {
- fErrorReporter.error(symbol->fPosition, "symbol '" + name + "' was already defined");
+ fErrorReporter.error(symbol->fOffset, "symbol '" + name + "' was already defined");
}
}
diff --git a/src/sksl/ir/SkSLSymbolTable.h b/src/sksl/ir/SkSLSymbolTable.h
index 6bafef259d..241631db80 100644
--- a/src/sksl/ir/SkSLSymbolTable.h
+++ b/src/sksl/ir/SkSLSymbolTable.h
@@ -31,11 +31,11 @@ public:
: fParent(parent)
, fErrorReporter(*errorReporter) {}
- const Symbol* operator[](const String& name);
+ const Symbol* operator[](StringFragment name);
- void add(const String& name, std::unique_ptr<Symbol> symbol);
+ void add(StringFragment name, std::unique_ptr<Symbol> symbol);
- void addWithoutOwnership(const String& name, const Symbol* symbol);
+ void addWithoutOwnership(StringFragment name, const Symbol* symbol);
Symbol* takeOwnership(Symbol* s);
@@ -48,7 +48,7 @@ private:
std::vector<std::unique_ptr<Symbol>> fOwnedPointers;
- std::unordered_map<String, const Symbol*> fSymbols;
+ std::unordered_map<StringFragment, const Symbol*> fSymbols;
ErrorReporter& fErrorReporter;
};
diff --git a/src/sksl/ir/SkSLTernaryExpression.h b/src/sksl/ir/SkSLTernaryExpression.h
index 567af56e8e..282a3221db 100644
--- a/src/sksl/ir/SkSLTernaryExpression.h
+++ b/src/sksl/ir/SkSLTernaryExpression.h
@@ -17,9 +17,9 @@ namespace SkSL {
* A ternary expression (test ? ifTrue : ifFalse).
*/
struct TernaryExpression : public Expression {
- TernaryExpression(Position position, std::unique_ptr<Expression> test,
+ TernaryExpression(int offset, std::unique_ptr<Expression> test,
std::unique_ptr<Expression> ifTrue, std::unique_ptr<Expression> ifFalse)
- : INHERITED(position, kTernary_Kind, ifTrue->fType)
+ : INHERITED(offset, kTernary_Kind, ifTrue->fType)
, fTest(std::move(test))
, fIfTrue(std::move(ifTrue))
, fIfFalse(std::move(ifFalse)) {
diff --git a/src/sksl/ir/SkSLType.h b/src/sksl/ir/SkSLType.h
index 6ea4c5694c..b0474216c1 100644
--- a/src/sksl/ir/SkSLType.h
+++ b/src/sksl/ir/SkSLType.h
@@ -27,9 +27,9 @@ class Context;
class Type : public Symbol {
public:
struct Field {
- Field(Modifiers modifiers, String name, const Type* type)
+ Field(Modifiers modifiers, StringFragment name, const Type* type)
: fModifiers(modifiers)
- , fName(std::move(name))
+ , fName(name)
, fType(std::move(type)) {}
const String description() const {
@@ -37,7 +37,7 @@ public:
}
Modifiers fModifiers;
- String fName;
+ StringFragment fName;
const Type* fType;
};
@@ -62,40 +62,60 @@ public:
// Create an "other" (special) type with the given name. These types cannot be directly
// referenced from user code.
Type(String name)
- : INHERITED(Position(), kType_Kind, std::move(name))
+ : INHERITED(-1, kType_Kind, StringFragment())
+ , fNameString(std::move(name))
, fTypeKind(kOther_Kind)
- , fNumberKind(kNonnumeric_NumberKind) {}
+ , fNumberKind(kNonnumeric_NumberKind) {
+ fName.fChars = fNameString.c_str();
+ fName.fLength = fNameString.size();
+ }
// Create a generic type which maps to the listed types.
Type(String name, std::vector<const Type*> types)
- : INHERITED(Position(), kType_Kind, std::move(name))
+ : INHERITED(-1, kType_Kind, StringFragment())
+ , fNameString(std::move(name))
, fTypeKind(kGeneric_Kind)
, fNumberKind(kNonnumeric_NumberKind)
- , fCoercibleTypes(std::move(types)) {}
+ , fCoercibleTypes(std::move(types)) {
+ fName.fChars = fNameString.c_str();
+ fName.fLength = fNameString.size();
+ }
// Create a struct type with the given fields.
- Type(Position position, String name, std::vector<Field> fields)
- : INHERITED(position, kType_Kind, std::move(name))
+ Type(int offset, String name, std::vector<Field> fields)
+ : INHERITED(offset, kType_Kind, StringFragment())
+ , fNameString(std::move(name))
, fTypeKind(kStruct_Kind)
, fNumberKind(kNonnumeric_NumberKind)
- , fFields(std::move(fields)) {}
+ , fFields(std::move(fields)) {
+ fName.fChars = fNameString.c_str();
+ fName.fLength = fNameString.size();
+ }
// Create a scalar type.
Type(String name, NumberKind numberKind)
- : INHERITED(Position(), kType_Kind, std::move(name))
+ : INHERITED(-1, kType_Kind, StringFragment())
+ , fNameString(std::move(name))
, fTypeKind(kScalar_Kind)
, fNumberKind(numberKind)
, fColumns(1)
- , fRows(1) {}
+ , fRows(1) {
+ fName.fChars = fNameString.c_str();
+ fName.fLength = fNameString.size();
+ }
// Create a scalar type which can be coerced to the listed types.
Type(String name, NumberKind numberKind, std::vector<const Type*> coercibleTypes)
- : INHERITED(Position(), kType_Kind, std::move(name))
+ : INHERITED(-1, kType_Kind, StringFragment())
+ , fNameString(std::move(name))
, fTypeKind(kScalar_Kind)
, fNumberKind(numberKind)
, fCoercibleTypes(std::move(coercibleTypes))
, fColumns(1)
- , fRows(1) {}
+ , fRows(1) {
+ fName.fChars = fNameString.c_str();
+ fName.fLength = fNameString.size();
+ }
// Create a vector type.
Type(String name, const Type& componentType, int columns)
@@ -103,42 +123,54 @@ public:
// Create a vector or array type.
Type(String name, Kind kind, const Type& componentType, int columns)
- : INHERITED(Position(), kType_Kind, std::move(name))
+ : INHERITED(-1, kType_Kind, StringFragment())
+ , fNameString(std::move(name))
, fTypeKind(kind)
, fNumberKind(kNonnumeric_NumberKind)
, fComponentType(&componentType)
, fColumns(columns)
, fRows(1)
- , fDimensions(SpvDim1D) {}
+ , fDimensions(SpvDim1D) {
+ fName.fChars = fNameString.c_str();
+ fName.fLength = fNameString.size();
+ }
// Create a matrix type.
Type(String name, const Type& componentType, int columns, int rows)
- : INHERITED(Position(), kType_Kind, std::move(name))
+ : INHERITED(-1, kType_Kind, StringFragment())
+ , fNameString(std::move(name))
, fTypeKind(kMatrix_Kind)
, fNumberKind(kNonnumeric_NumberKind)
, fComponentType(&componentType)
, fColumns(columns)
, fRows(rows)
- , fDimensions(SpvDim1D) {}
+ , fDimensions(SpvDim1D) {
+ fName.fChars = fNameString.c_str();
+ fName.fLength = fNameString.size();
+ }
// Create a sampler type.
Type(String name, SpvDim_ dimensions, bool isDepth, bool isArrayed, bool isMultisampled,
bool isSampled)
- : INHERITED(Position(), kType_Kind, std::move(name))
+ : INHERITED(-1, kType_Kind, StringFragment())
+ , fNameString(std::move(name))
, fTypeKind(kSampler_Kind)
, fNumberKind(kNonnumeric_NumberKind)
, fDimensions(dimensions)
, fIsDepth(isDepth)
, fIsArrayed(isArrayed)
, fIsMultisampled(isMultisampled)
- , fIsSampled(isSampled) {}
+ , fIsSampled(isSampled) {
+ fName.fChars = fNameString.c_str();
+ fName.fLength = fNameString.size();
+ }
const String& name() const {
- return fName;
+ return fNameString;
}
String description() const override {
- return fName;
+ return fNameString;
}
bool operator==(const Type& other) const {
@@ -283,6 +315,7 @@ public:
private:
typedef Symbol INHERITED;
+ const String fNameString;
const Kind fTypeKind;
// always kNonnumeric_NumberKind for non-scalar values
const NumberKind fNumberKind;
diff --git a/src/sksl/ir/SkSLTypeReference.h b/src/sksl/ir/SkSLTypeReference.h
index eae19897c7..f7065b7c3f 100644
--- a/src/sksl/ir/SkSLTypeReference.h
+++ b/src/sksl/ir/SkSLTypeReference.h
@@ -18,8 +18,8 @@ namespace SkSL {
* always eventually replaced by Constructors in valid programs.
*/
struct TypeReference : public Expression {
- TypeReference(const Context& context, Position position, const Type& type)
- : INHERITED(position, kTypeReference_Kind, *context.fInvalid_Type)
+ TypeReference(const Context& context, int offset, const Type& type)
+ : INHERITED(offset, kTypeReference_Kind, *context.fInvalid_Type)
, fValue(type) {}
bool hasSideEffects() const override {
@@ -27,7 +27,7 @@ struct TypeReference : public Expression {
}
String description() const override {
- return fValue.name();
+ return String(fValue.fName);
}
const Type& fValue;
diff --git a/src/sksl/ir/SkSLUnresolvedFunction.h b/src/sksl/ir/SkSLUnresolvedFunction.h
index b222bc3053..62035da3a3 100644
--- a/src/sksl/ir/SkSLUnresolvedFunction.h
+++ b/src/sksl/ir/SkSLUnresolvedFunction.h
@@ -17,7 +17,7 @@ namespace SkSL {
*/
struct UnresolvedFunction : public Symbol {
UnresolvedFunction(std::vector<const FunctionDeclaration*> funcs)
- : INHERITED(Position(), kUnresolvedFunction_Kind, funcs[0]->fName)
+ : INHERITED(-1, kUnresolvedFunction_Kind, funcs[0]->fName)
, fFunctions(std::move(funcs)) {
#ifdef DEBUG
for (auto func : funcs) {
diff --git a/src/sksl/ir/SkSLVarDeclarations.h b/src/sksl/ir/SkSLVarDeclarations.h
index 1eda87e979..707715f6dc 100644
--- a/src/sksl/ir/SkSLVarDeclarations.h
+++ b/src/sksl/ir/SkSLVarDeclarations.h
@@ -24,7 +24,7 @@ struct VarDeclaration : public Statement {
VarDeclaration(const Variable* var,
std::vector<std::unique_ptr<Expression>> sizes,
std::unique_ptr<Expression> value)
- : INHERITED(var->fPosition, Statement::kVarDeclaration_Kind)
+ : INHERITED(var->fOffset, Statement::kVarDeclaration_Kind)
, fVar(var)
, fSizes(std::move(sizes))
, fValue(std::move(value)) {}
@@ -55,9 +55,9 @@ struct VarDeclaration : public Statement {
* A variable declaration statement, which may consist of one or more individual variables.
*/
struct VarDeclarations : public ProgramElement {
- VarDeclarations(Position position, const Type* baseType,
+ VarDeclarations(int offset, const Type* baseType,
std::vector<std::unique_ptr<VarDeclaration>> vars)
- : INHERITED(position, kVar_Kind)
+ : INHERITED(offset, kVar_Kind)
, fBaseType(*baseType) {
for (auto& var : vars) {
fVars.push_back(std::unique_ptr<Statement>(var.release()));
diff --git a/src/sksl/ir/SkSLVarDeclarationsStatement.h b/src/sksl/ir/SkSLVarDeclarationsStatement.h
index a6a95a9c08..0258e66c6e 100644
--- a/src/sksl/ir/SkSLVarDeclarationsStatement.h
+++ b/src/sksl/ir/SkSLVarDeclarationsStatement.h
@@ -18,7 +18,7 @@ namespace SkSL {
*/
struct VarDeclarationsStatement : public Statement {
VarDeclarationsStatement(std::unique_ptr<VarDeclarations> decl)
- : INHERITED(decl->fPosition, kVarDeclarations_Kind)
+ : INHERITED(decl->fOffset, kVarDeclarations_Kind)
, fDeclaration(std::move(decl)) {}
bool isEmpty() const override {
diff --git a/src/sksl/ir/SkSLVariable.h b/src/sksl/ir/SkSLVariable.h
index 05bba20a83..536d1e6b6d 100644
--- a/src/sksl/ir/SkSLVariable.h
+++ b/src/sksl/ir/SkSLVariable.h
@@ -27,9 +27,9 @@ struct Variable : public Symbol {
kParameter_Storage
};
- Variable(Position position, Modifiers modifiers, String name, const Type& type,
+ Variable(int offset, Modifiers modifiers, StringFragment name, const Type& type,
Storage storage)
- : INHERITED(position, kVariable_Kind, std::move(name))
+ : INHERITED(offset, kVariable_Kind, name)
, fModifiers(modifiers)
, fType(type)
, fStorage(storage)
diff --git a/src/sksl/ir/SkSLVariableReference.h b/src/sksl/ir/SkSLVariableReference.h
index ba17437e24..54917b0431 100644
--- a/src/sksl/ir/SkSLVariableReference.h
+++ b/src/sksl/ir/SkSLVariableReference.h
@@ -32,8 +32,8 @@ struct VariableReference : public Expression {
kReadWrite_RefKind
};
- VariableReference(Position position, const Variable& variable, RefKind refKind = kRead_RefKind)
- : INHERITED(position, kVariableReference_Kind, variable.fType)
+ VariableReference(int offset, const Variable& variable, RefKind refKind = kRead_RefKind)
+ : INHERITED(offset, kVariableReference_Kind, variable.fType)
, fVariable(variable)
, fRefKind(refKind) {
if (refKind != kRead_RefKind) {
@@ -83,18 +83,17 @@ struct VariableReference : public Expression {
ASSERT(expr->isConstant());
switch (expr->fKind) {
case Expression::kIntLiteral_Kind:
- return std::unique_ptr<Expression>(new IntLiteral(
- irGenerator.fContext,
- Position(),
- ((IntLiteral*) expr)->fValue));
+ return std::unique_ptr<Expression>(new IntLiteral(irGenerator.fContext,
+ -1,
+ ((IntLiteral*) expr)->fValue));
case Expression::kFloatLiteral_Kind:
return std::unique_ptr<Expression>(new FloatLiteral(
- irGenerator.fContext,
- Position(),
- ((FloatLiteral*) expr)->fValue));
+ irGenerator.fContext,
+ -1,
+ ((FloatLiteral*) expr)->fValue));
case Expression::kBoolLiteral_Kind:
return std::unique_ptr<Expression>(new BoolLiteral(irGenerator.fContext,
- Position(),
+ -1,
((BoolLiteral*) expr)->fValue));
case Expression::kConstructor_Kind: {
const Constructor* c = (const Constructor*) expr;
@@ -102,12 +101,12 @@ struct VariableReference : public Expression {
for (const auto& arg : c->fArguments) {
args.push_back(copy_constant(irGenerator, arg.get()));
}
- return std::unique_ptr<Expression>(new Constructor(Position(), c->fType,
+ return std::unique_ptr<Expression>(new Constructor(-1, c->fType,
std::move(args)));
}
case Expression::kSetting_Kind: {
const Setting* s = (const Setting*) expr;
- return std::unique_ptr<Expression>(new Setting(Position(), s->fName,
+ return std::unique_ptr<Expression>(new Setting(-1, s->fName,
copy_constant(irGenerator,
s->fValue.get())));
}
diff --git a/src/sksl/ir/SkSLWhileStatement.h b/src/sksl/ir/SkSLWhileStatement.h
index 6df1619a56..aed6494999 100644
--- a/src/sksl/ir/SkSLWhileStatement.h
+++ b/src/sksl/ir/SkSLWhileStatement.h
@@ -17,9 +17,9 @@ namespace SkSL {
* A 'while' loop.
*/
struct WhileStatement : public Statement {
- WhileStatement(Position position, std::unique_ptr<Expression> test,
+ WhileStatement(int offset, std::unique_ptr<Expression> test,
std::unique_ptr<Statement> statement)
- : INHERITED(position, kWhile_Kind)
+ : INHERITED(offset, kWhile_Kind)
, fTest(std::move(test))
, fStatement(std::move(statement)) {}