Renamed SkSL::PositionInfo to SkSL::Position

Change-Id: I1fa160941b18392616708f4e08a4ebbf7398480e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/518521
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
Ethan Nicholas 2022-03-09 10:22:44 -05:00 committed by SkCQ
parent 0284676042
commit 9cd8456afe
35 changed files with 382 additions and 382 deletions

View File

@ -37,10 +37,10 @@ public:
}
DSLCase(DSLExpression value, SkTArray<DSLStatement> statements,
PositionInfo info = PositionInfo::Capture());
Position pos = Position::Capture());
DSLCase(DSLExpression value, SkSL::StatementArray statements,
PositionInfo info = PositionInfo::Capture());
Position pos = Position::Capture());
DSLCase(DSLCase&&);
@ -53,7 +53,7 @@ public:
private:
DSLExpression fValue;
SkSL::StatementArray fStatements;
PositionInfo fPosition;
Position fPosition;
friend class DSLCore;

View File

@ -76,42 +76,42 @@ DSLExpression sk_Position();
/**
* #extension <name> : enable
*/
void AddExtension(std::string_view name, PositionInfo pos = PositionInfo::Capture());
void AddExtension(std::string_view name, Position pos = Position::Capture());
/**
* break;
*/
DSLStatement Break(PositionInfo pos = PositionInfo::Capture());
DSLStatement Break(Position pos = Position::Capture());
/**
* continue;
*/
DSLStatement Continue(PositionInfo pos = PositionInfo::Capture());
DSLStatement Continue(Position pos = Position::Capture());
/**
* Adds a modifiers declaration to the current program.
*/
void Declare(const DSLModifiers& modifiers, PositionInfo pos = PositionInfo::Capture());
void Declare(const DSLModifiers& modifiers, Position pos = Position::Capture());
/**
* Creates a local variable declaration statement.
*/
DSLStatement Declare(DSLVar& var, PositionInfo pos = PositionInfo::Capture());
DSLStatement Declare(DSLVar& var, Position pos = Position::Capture());
/**
* Creates a local variable declaration statement containing multiple variables.
*/
DSLStatement Declare(SkTArray<DSLVar>& vars, PositionInfo pos = PositionInfo::Capture());
DSLStatement Declare(SkTArray<DSLVar>& vars, Position pos = Position::Capture());
/**
* Declares a global variable.
*/
void Declare(DSLGlobalVar& var, PositionInfo pos = PositionInfo::Capture());
void Declare(DSLGlobalVar& var, Position pos = Position::Capture());
/**
* Declares a set of global variables.
*/
void Declare(SkTArray<DSLGlobalVar>& vars, PositionInfo pos = PositionInfo::Capture());
void Declare(SkTArray<DSLGlobalVar>& vars, Position pos = Position::Capture());
/**
* default: statements
@ -124,50 +124,50 @@ DSLCase Default(Statements... statements) {
/**
* discard;
*/
DSLStatement Discard(PositionInfo pos = PositionInfo::Capture());
DSLStatement Discard(Position pos = Position::Capture());
/**
* do stmt; while (test);
*/
DSLStatement Do(DSLStatement stmt, DSLExpression test, PositionInfo pos = PositionInfo::Capture());
DSLStatement Do(DSLStatement stmt, DSLExpression test, Position pos = Position::Capture());
/**
* for (initializer; test; next) stmt;
*/
DSLStatement For(DSLStatement initializer, DSLExpression test, DSLExpression next,
DSLStatement stmt, PositionInfo pos = PositionInfo::Capture());
DSLStatement stmt, Position pos = Position::Capture());
/**
* if (test) ifTrue; [else ifFalse;]
*/
DSLStatement If(DSLExpression test, DSLStatement ifTrue, DSLStatement ifFalse = DSLStatement(),
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
DSLGlobalVar InterfaceBlock(const DSLModifiers& modifiers, std::string_view typeName,
SkTArray<DSLField> fields, std::string_view varName = "",
int arraySize = 0, PositionInfo pos = PositionInfo::Capture());
int arraySize = 0, Position pos = Position::Capture());
/**
* return [value];
*/
DSLStatement Return(DSLExpression value = DSLExpression(),
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
/**
* test ? ifTrue : ifFalse
*/
DSLExpression Select(DSLExpression test, DSLExpression ifTrue, DSLExpression ifFalse,
PositionInfo info = PositionInfo::Capture());
Position = Position::Capture());
DSLStatement StaticIf(DSLExpression test, DSLStatement ifTrue,
DSLStatement ifFalse = DSLStatement(),
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
// Internal use only
DSLPossibleStatement PossibleStaticSwitch(DSLExpression value, SkTArray<DSLCase> cases);
DSLStatement StaticSwitch(DSLExpression value, SkTArray<DSLCase> cases,
PositionInfo info = PositionInfo::Capture());
Position pos = Position::Capture());
/**
* @switch (value) { cases }
@ -184,7 +184,7 @@ DSLPossibleStatement StaticSwitch(DSLExpression value, Cases... cases) {
DSLPossibleStatement PossibleSwitch(DSLExpression value, SkTArray<DSLCase> cases);
DSLStatement Switch(DSLExpression value, SkTArray<DSLCase> cases,
PositionInfo info = PositionInfo::Capture());
Position pos = Position::Capture());
/**
* switch (value) { cases }
@ -201,187 +201,187 @@ DSLPossibleStatement Switch(DSLExpression value, Cases... cases) {
* while (test) stmt;
*/
DSLStatement While(DSLExpression test, DSLStatement stmt,
PositionInfo info = PositionInfo::Capture());
Position pos = Position::Capture());
/**
* expression.xyz1
*/
DSLExpression Swizzle(DSLExpression base,
SkSL::SwizzleComponent::Type a,
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
DSLExpression Swizzle(DSLExpression base,
SkSL::SwizzleComponent::Type a,
SkSL::SwizzleComponent::Type b,
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
DSLExpression Swizzle(DSLExpression base,
SkSL::SwizzleComponent::Type a,
SkSL::SwizzleComponent::Type b,
SkSL::SwizzleComponent::Type c,
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
DSLExpression Swizzle(DSLExpression base,
SkSL::SwizzleComponent::Type a,
SkSL::SwizzleComponent::Type b,
SkSL::SwizzleComponent::Type c,
SkSL::SwizzleComponent::Type d,
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
/**
* Returns the absolute value of x. If x is a vector, operates componentwise.
*/
DSLExpression Abs(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Abs(DSLExpression x, Position pos = Position::Capture());
/**
* Returns true if all of the components of boolean vector x are true.
*/
DSLExpression All(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression All(DSLExpression x, Position pos = Position::Capture());
/**
* Returns true if any of the components of boolean vector x are true.
*/
DSLExpression Any(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Any(DSLExpression x, Position pos = Position::Capture());
/**
* Returns the arctangent of y over x. Operates componentwise on vectors.
*/
DSLExpression Atan(DSLExpression y_over_x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Atan(DSLExpression y, DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Atan(DSLExpression y_over_x, Position pos = Position::Capture());
DSLExpression Atan(DSLExpression y, DSLExpression x, Position pos = Position::Capture());
/**
* Returns x rounded towards positive infinity. If x is a vector, operates componentwise.
*/
DSLExpression Ceil(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Ceil(DSLExpression x, Position pos = Position::Capture());
/**
* Returns x clamped to between min and max. If x is a vector, operates componentwise.
*/
DSLExpression Clamp(DSLExpression x, DSLExpression min, DSLExpression max,
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
/**
* Returns the cosine of x. If x is a vector, operates componentwise.
*/
DSLExpression Cos(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Cos(DSLExpression x, Position pos = Position::Capture());
/**
* Returns the cross product of x and y.
*/
DSLExpression Cross(DSLExpression x, DSLExpression y, PositionInfo pos = PositionInfo::Capture());
DSLExpression Cross(DSLExpression x, DSLExpression y, Position pos = Position::Capture());
/**
* Returns x converted from radians to degrees. If x is a vector, operates componentwise.
*/
DSLExpression Degrees(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Degrees(DSLExpression x, Position pos = Position::Capture());
/**
* Returns the distance between x and y.
*/
DSLExpression Distance(DSLExpression x, DSLExpression y,
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
/**
* Returns the dot product of x and y.
*/
DSLExpression Dot(DSLExpression x, DSLExpression y, PositionInfo pos = PositionInfo::Capture());
DSLExpression Dot(DSLExpression x, DSLExpression y, Position pos = Position::Capture());
/**
* Returns a boolean vector indicating whether components of x are equal to the corresponding
* components of y.
*/
DSLExpression Equal(DSLExpression x, DSLExpression y, PositionInfo pos = PositionInfo::Capture());
DSLExpression Equal(DSLExpression x, DSLExpression y, Position pos = Position::Capture());
/**
* Returns e^x. If x is a vector, operates componentwise.
*/
DSLExpression Exp(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Exp(DSLExpression x, Position pos = Position::Capture());
/**
* Returns 2^x. If x is a vector, operates componentwise.
*/
DSLExpression Exp2(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Exp2(DSLExpression x, Position pos = Position::Capture());
/**
* If dot(i, nref) >= 0, returns n, otherwise returns -n.
*/
DSLExpression Faceforward(DSLExpression n, DSLExpression i, DSLExpression nref,
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
/**
* Returns x rounded towards negative infinity. If x is a vector, operates componentwise.
*/
DSLExpression Floor(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Floor(DSLExpression x, Position pos = Position::Capture());
/**
* Returns the fractional part of x. If x is a vector, operates componentwise.
*/
DSLExpression Fract(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Fract(DSLExpression x, Position pos = Position::Capture());
/**
* Returns a boolean vector indicating whether components of x are greater than the corresponding
* components of y.
*/
DSLExpression GreaterThan(DSLExpression x, DSLExpression y,
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
/**
* Returns a boolean vector indicating whether components of x are greater than or equal to the
* corresponding components of y.
*/
DSLExpression GreaterThanEqual(DSLExpression x, DSLExpression y,
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
/**
* Returns the 1/sqrt(x). If x is a vector, operates componentwise.
*/
DSLExpression Inversesqrt(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Inversesqrt(DSLExpression x, Position pos = Position::Capture());
/**
* Returns the inverse of the matrix x.
*/
DSLExpression Inverse(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Inverse(DSLExpression x, Position pos = Position::Capture());
/**
* Returns the length of the vector x.
*/
DSLExpression Length(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Length(DSLExpression x, Position pos = Position::Capture());
/**
* Returns a boolean vector indicating whether components of x are less than the corresponding
* components of y.
*/
DSLExpression LessThan(DSLExpression x, DSLExpression y,
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
/**
* Returns a boolean vector indicating whether components of x are less than or equal to the
* corresponding components of y.
*/
DSLExpression LessThanEqual(DSLExpression x, DSLExpression y,
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
/**
* Returns the log base e of x. If x is a vector, operates componentwise.
*/
DSLExpression Log(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Log(DSLExpression x, Position pos = Position::Capture());
/**
* Returns the log base 2 of x. If x is a vector, operates componentwise.
*/
DSLExpression Log2(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Log2(DSLExpression x, Position pos = Position::Capture());
/**
* Returns the larger (closer to positive infinity) of x and y. If x is a vector, operates
* componentwise. y may be either a vector of the same dimensions as x, or a scalar.
*/
DSLExpression Max(DSLExpression x, DSLExpression y, PositionInfo pos = PositionInfo::Capture());
DSLExpression Max(DSLExpression x, DSLExpression y, Position pos = Position::Capture());
/**
* Returns the smaller (closer to negative infinity) of x and y. If x is a vector, operates
* componentwise. y may be either a vector of the same dimensions as x, or a scalar.
*/
DSLExpression Min(DSLExpression x, DSLExpression y, PositionInfo pos = PositionInfo::Capture());
DSLExpression Min(DSLExpression x, DSLExpression y, Position pos = Position::Capture());
/**
* Returns a linear intepolation between x and y at position a, where a=0 results in x and a=1
@ -389,68 +389,68 @@ DSLExpression Min(DSLExpression x, DSLExpression y, PositionInfo pos = PositionI
* same dimensions as x and y, or a scalar.
*/
DSLExpression Mix(DSLExpression x, DSLExpression y, DSLExpression a,
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
/**
* Returns x modulo y. If x is a vector, operates componentwise. y may be either a vector of the
* same dimensions as x, or a scalar.
*/
DSLExpression Mod(DSLExpression x, DSLExpression y, PositionInfo pos = PositionInfo::Capture());
DSLExpression Mod(DSLExpression x, DSLExpression y, Position pos = Position::Capture());
/**
* Returns the vector x normalized to a length of 1.
*/
DSLExpression Normalize(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Normalize(DSLExpression x, Position pos = Position::Capture());
/**
* Returns a boolean vector indicating whether components of x are not equal to the corresponding
* components of y.
*/
DSLExpression NotEqual(DSLExpression x, DSLExpression y,
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
/**
* Returns x raised to the power y. If x is a vector, operates componentwise. y may be either a
* vector of the same dimensions as x, or a scalar.
*/
DSLExpression Pow(DSLExpression x, DSLExpression y, PositionInfo pos = PositionInfo::Capture());
DSLExpression Pow(DSLExpression x, DSLExpression y, Position pos = Position::Capture());
/**
* Returns x converted from degrees to radians. If x is a vector, operates componentwise.
*/
DSLExpression Radians(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Radians(DSLExpression x, Position pos = Position::Capture());
/**
* Returns i reflected from a surface with normal n.
*/
DSLExpression Reflect(DSLExpression i, DSLExpression n, PositionInfo pos = PositionInfo::Capture());
DSLExpression Reflect(DSLExpression i, DSLExpression n, Position pos = Position::Capture());
/**
* Returns i refracted across a surface with normal n and ratio of indices of refraction eta.
*/
DSLExpression Refract(DSLExpression i, DSLExpression n, DSLExpression eta,
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
/**
* Returns x, rounded to the nearest integer. If x is a vector, operates componentwise.
*/
DSLExpression Round(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Round(DSLExpression x, Position pos = Position::Capture());
/**
* Returns x clamped to the range [0, 1]. If x is a vector, operates componentwise.
*/
DSLExpression Saturate(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Saturate(DSLExpression x, Position pos = Position::Capture());
/**
* Returns -1, 0, or 1 depending on whether x is negative, zero, or positive, respectively. If x is
* a vector, operates componentwise.
*/
DSLExpression Sign(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Sign(DSLExpression x, Position pos = Position::Capture());
/**
* Returns the sine of x. If x is a vector, operates componentwise.
*/
DSLExpression Sin(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Sin(DSLExpression x, Position pos = Position::Capture());
/**
* Returns a smooth interpolation between 0 (at x=edge1) and 1 (at x=edge2). If x is a vector,
@ -458,28 +458,28 @@ DSLExpression Sin(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
* scalars.
*/
DSLExpression Smoothstep(DSLExpression edge1, DSLExpression edge2, DSLExpression x,
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
/**
* Returns the square root of x. If x is a vector, operates componentwise.
*/
DSLExpression Sqrt(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Sqrt(DSLExpression x, Position pos = Position::Capture());
/**
* Returns 0 if x < edge or 1 if x >= edge. If x is a vector, operates componentwise. edge may be
* either a vector of the same dimensions as x, or a scalar.
*/
DSLExpression Step(DSLExpression edge, DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Step(DSLExpression edge, DSLExpression x, Position pos = Position::Capture());
/**
* Returns the tangent of x. If x is a vector, operates componentwise.
*/
DSLExpression Tan(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Tan(DSLExpression x, Position pos = Position::Capture());
/**
* Returns x converted from premultipled to unpremultiplied alpha.
*/
DSLExpression Unpremul(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression Unpremul(DSLExpression x, Position pos = Position::Capture());
} // namespace dsl

View File

@ -49,46 +49,46 @@ public:
/**
* Creates an expression representing a literal float.
*/
DSLExpression(float value, PositionInfo pos = PositionInfo::Capture());
DSLExpression(float value, Position pos = Position::Capture());
/**
* Creates an expression representing a literal float.
*/
DSLExpression(double value, PositionInfo pos = PositionInfo::Capture())
DSLExpression(double value, Position pos = Position::Capture())
: DSLExpression((float) value) {}
/**
* Creates an expression representing a literal int.
*/
DSLExpression(int value, PositionInfo pos = PositionInfo::Capture());
DSLExpression(int value, Position pos = Position::Capture());
/**
* Creates an expression representing a literal int.
*/
DSLExpression(int64_t value, PositionInfo pos = PositionInfo::Capture());
DSLExpression(int64_t value, Position pos = Position::Capture());
/**
* Creates an expression representing a literal uint.
*/
DSLExpression(unsigned int value, PositionInfo pos = PositionInfo::Capture());
DSLExpression(unsigned int value, Position pos = Position::Capture());
/**
* Creates an expression representing a literal bool.
*/
DSLExpression(bool value, PositionInfo pos = PositionInfo::Capture());
DSLExpression(bool value, Position pos = Position::Capture());
/**
* Creates an expression representing a variable reference.
*/
DSLExpression(DSLVarBase& var, PositionInfo pos = PositionInfo::Capture());
DSLExpression(DSLVarBase& var, Position pos = Position::Capture());
DSLExpression(DSLVarBase&& var, PositionInfo pos = PositionInfo::Capture());
DSLExpression(DSLVarBase&& var, Position pos = Position::Capture());
DSLExpression(DSLPossibleExpression expr, PositionInfo pos = PositionInfo::Capture());
DSLExpression(DSLPossibleExpression expr, Position pos = Position::Capture());
explicit DSLExpression(std::unique_ptr<SkSL::Expression> expression);
static DSLExpression Poison(PositionInfo pos = PositionInfo::Capture());
static DSLExpression Poison(Position pos = Position::Capture());
~DSLExpression();
@ -99,26 +99,26 @@ public:
*/
DSLPossibleExpression operator=(DSLExpression other);
DSLExpression x(PositionInfo pos = PositionInfo::Capture());
DSLExpression x(Position pos = Position::Capture());
DSLExpression y(PositionInfo pos = PositionInfo::Capture());
DSLExpression y(Position pos = Position::Capture());
DSLExpression z(PositionInfo pos = PositionInfo::Capture());
DSLExpression z(Position pos = Position::Capture());
DSLExpression w(PositionInfo pos = PositionInfo::Capture());
DSLExpression w(Position pos = Position::Capture());
DSLExpression r(PositionInfo pos = PositionInfo::Capture());
DSLExpression r(Position pos = Position::Capture());
DSLExpression g(PositionInfo pos = PositionInfo::Capture());
DSLExpression g(Position pos = Position::Capture());
DSLExpression b(PositionInfo pos = PositionInfo::Capture());
DSLExpression b(Position pos = Position::Capture());
DSLExpression a(PositionInfo pos = PositionInfo::Capture());
DSLExpression a(Position pos = Position::Capture());
/**
* Creates an SkSL struct field access expression.
*/
DSLExpression field(std::string_view name, PositionInfo pos = PositionInfo::Capture());
DSLExpression field(std::string_view name, Position pos = Position::Capture());
/**
* Creates an SkSL array index expression.
@ -126,10 +126,10 @@ public:
DSLPossibleExpression operator[](DSLExpression index);
DSLPossibleExpression operator()(SkTArray<DSLWrapper<DSLExpression>> args,
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
DSLPossibleExpression operator()(ExpressionArray args,
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
/**
* Returns true if this object contains an expression. DSLExpressions which were created with
@ -216,12 +216,12 @@ DSLPossibleExpression operator--(DSLExpression expr, int);
/**
* Represents an Expression which may have failed and/or have pending errors to report. Converting a
* PossibleExpression into an Expression requires PositionInfo so that any pending errors can be
* PossibleExpression into an Expression requires a Position so that any pending errors can be
* reported at the correct position.
*
* PossibleExpression is used instead of Expression in situations where it is not possible to
* capture the PositionInfo at the time of Expression construction (notably in operator overloads,
* where we cannot add default parameters).
* capture the Position at the time of Expression construction (notably in operator overloads, where
* we cannot add default parameters).
*/
class DSLPossibleExpression {
public:
@ -238,27 +238,27 @@ public:
/**
* Reports any pending errors at the specified position.
*/
void reportErrors(PositionInfo pos);
void reportErrors(Position pos);
DSLType type();
DSLExpression x(PositionInfo pos = PositionInfo::Capture());
DSLExpression x(Position pos = Position::Capture());
DSLExpression y(PositionInfo pos = PositionInfo::Capture());
DSLExpression y(Position pos = Position::Capture());
DSLExpression z(PositionInfo pos = PositionInfo::Capture());
DSLExpression z(Position pos = Position::Capture());
DSLExpression w(PositionInfo pos = PositionInfo::Capture());
DSLExpression w(Position pos = Position::Capture());
DSLExpression r(PositionInfo pos = PositionInfo::Capture());
DSLExpression r(Position pos = Position::Capture());
DSLExpression g(PositionInfo pos = PositionInfo::Capture());
DSLExpression g(Position pos = Position::Capture());
DSLExpression b(PositionInfo pos = PositionInfo::Capture());
DSLExpression b(Position pos = Position::Capture());
DSLExpression a(PositionInfo pos = PositionInfo::Capture());
DSLExpression a(Position pos = Position::Capture());
DSLExpression field(std::string_view name, PositionInfo pos = PositionInfo::Capture());
DSLExpression field(std::string_view name, Position pos = Position::Capture());
DSLPossibleExpression operator=(DSLExpression expr);
@ -271,10 +271,10 @@ public:
DSLPossibleExpression operator[](DSLExpression index);
DSLPossibleExpression operator()(SkTArray<DSLWrapper<DSLExpression>> args,
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
DSLPossibleExpression operator()(ExpressionArray args,
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
DSLPossibleExpression operator++();
@ -284,7 +284,7 @@ public:
DSLPossibleExpression operator--(int);
std::unique_ptr<SkSL::Expression> release(PositionInfo pos = PositionInfo::Capture());
std::unique_ptr<SkSL::Expression> release(Position pos = Position::Capture());
private:
std::unique_ptr<SkSL::Expression> fExpression;

View File

@ -41,17 +41,17 @@ public:
int unused[] = {0, (static_cast<void>(parameterArray.push_back(&parameters)), 0)...};
static_cast<void>(unused);
// We can't have a default parameter and a template parameter pack at the same time, so
// unfortunately we can't capture position info from this overload.
this->init(modifiers, returnType, name, std::move(parameterArray), PositionInfo());
// unfortunately we can't capture position from this overload.
this->init(modifiers, returnType, name, std::move(parameterArray), Position());
}
DSLFunction(const DSLType& returnType, std::string_view name,
SkTArray<DSLParameter*> parameters, PositionInfo pos = PositionInfo::Capture()) {
SkTArray<DSLParameter*> parameters, Position pos = Position::Capture()) {
this->init(DSLModifiers(), returnType, name, std::move(parameters), pos);
}
DSLFunction(const DSLModifiers& modifiers, const DSLType& returnType, std::string_view name,
SkTArray<DSLParameter*> parameters, PositionInfo pos = PositionInfo::Capture()) {
SkTArray<DSLParameter*> parameters, Position pos = Position::Capture()) {
this->init(modifiers, returnType, name, std::move(parameters), pos);
}
@ -66,7 +66,7 @@ public:
this->define(std::move(block));
}
void define(DSLBlock block, PositionInfo pos = PositionInfo::Capture());
void define(DSLBlock block, Position pos = Position::Capture());
/**
* Invokes the function with the given arguments.
@ -83,9 +83,9 @@ public:
* Invokes the function with the given arguments.
*/
DSLExpression call(SkTArray<DSLWrapper<DSLExpression>> args,
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
DSLExpression call(ExpressionArray args, PositionInfo pos = PositionInfo::Capture());
DSLExpression call(ExpressionArray args, Position pos = Position::Capture());
private:
void collectArgs(ExpressionArray& args) {}
@ -103,10 +103,10 @@ private:
}
void init(DSLModifiers modifiers, const DSLType& returnType, std::string_view name,
SkTArray<DSLParameter*> params, PositionInfo pos);
SkTArray<DSLParameter*> params, Position pos);
const SkSL::FunctionDeclaration* fDecl = nullptr;
SkSL::PositionInfo fPosition;
SkSL::Position fPosition;
};
} // namespace dsl

View File

@ -21,53 +21,53 @@ class DSLLayout {
public:
DSLLayout() {}
DSLLayout& originUpperLeft(PositionInfo pos = PositionInfo::Capture()) {
DSLLayout& originUpperLeft(Position pos = Position::Capture()) {
return this->flag(SkSL::Layout::kOriginUpperLeft_Flag, "origin_upper_left", pos);
}
DSLLayout& pushConstant(PositionInfo pos = PositionInfo::Capture()) {
DSLLayout& pushConstant(Position pos = Position::Capture()) {
return this->flag(SkSL::Layout::kPushConstant_Flag, "push_constant", pos);
}
DSLLayout& blendSupportAllEquations(PositionInfo pos = PositionInfo::Capture()) {
DSLLayout& blendSupportAllEquations(Position pos = Position::Capture()) {
return this->flag(SkSL::Layout::kBlendSupportAllEquations_Flag,
"blend_support_all_equations", pos);
}
DSLLayout& color(PositionInfo pos = PositionInfo::Capture()) {
DSLLayout& color(Position pos = Position::Capture()) {
return this->flag(SkSL::Layout::kColor_Flag, "color", pos);
}
DSLLayout& location(int location, PositionInfo pos = PositionInfo::Capture()) {
DSLLayout& location(int location, Position pos = Position::Capture()) {
return this->intValue(&fSkSLLayout.fLocation, location, SkSL::Layout::kLocation_Flag,
"location", pos);
}
DSLLayout& offset(int offset, PositionInfo pos = PositionInfo::Capture()) {
DSLLayout& offset(int offset, Position pos = Position::Capture()) {
return this->intValue(&fSkSLLayout.fOffset, offset, SkSL::Layout::kOffset_Flag, "offset",
pos);
}
DSLLayout& binding(int binding, PositionInfo pos = PositionInfo::Capture()) {
DSLLayout& binding(int binding, Position pos = Position::Capture()) {
return this->intValue(&fSkSLLayout.fBinding, binding, SkSL::Layout::kBinding_Flag,
"binding", pos);
}
DSLLayout& index(int index, PositionInfo pos = PositionInfo::Capture()) {
DSLLayout& index(int index, Position pos = Position::Capture()) {
return this->intValue(&fSkSLLayout.fIndex, index, SkSL::Layout::kIndex_Flag, "index", pos);
}
DSLLayout& set(int set, PositionInfo pos = PositionInfo::Capture()) {
DSLLayout& set(int set, Position pos = Position::Capture()) {
return this->intValue(&fSkSLLayout.fSet, set, SkSL::Layout::kSet_Flag, "set", pos);
}
DSLLayout& builtin(int builtin, PositionInfo pos = PositionInfo::Capture()) {
DSLLayout& builtin(int builtin, Position pos = Position::Capture()) {
return this->intValue(&fSkSLLayout.fBuiltin, builtin, SkSL::Layout::kBuiltin_Flag,
"builtin", pos);
}
DSLLayout& inputAttachmentIndex(int inputAttachmentIndex,
PositionInfo pos = PositionInfo::Capture()) {
Position pos = Position::Capture()) {
return this->intValue(&fSkSLLayout.fInputAttachmentIndex, inputAttachmentIndex,
SkSL::Layout::kInputAttachmentIndex_Flag, "input_attachment_index",
pos);
@ -77,10 +77,10 @@ private:
explicit DSLLayout(SkSL::Layout skslLayout)
: fSkSLLayout(skslLayout) {}
DSLLayout& flag(SkSL::Layout::Flag mask, const char* name, PositionInfo pos);
DSLLayout& flag(SkSL::Layout::Flag mask, const char* name, Position pos);
DSLLayout& intValue(int* target, int value, SkSL::Layout::Flag flag, const char* name,
PositionInfo pos);
Position pos);
SkSL::Layout fSkSLLayout;

View File

@ -49,7 +49,7 @@ public:
private:
SkSL::Modifiers fModifiers;
friend DSLType Struct(std::string_view name, SkSpan<DSLField> fields, PositionInfo pos);
friend DSLType Struct(std::string_view name, SkSpan<DSLField> fields, Position pos);
friend class DSLCore;
friend class DSLFunction;
friend class DSLType;

View File

@ -36,9 +36,9 @@ public:
DSLStatement(DSLExpression expr);
DSLStatement(DSLPossibleExpression expr, PositionInfo pos = PositionInfo::Capture());
DSLStatement(DSLPossibleExpression expr, Position pos = Position::Capture());
DSLStatement(DSLPossibleStatement stmt, PositionInfo pos = PositionInfo::Capture());
DSLStatement(DSLPossibleStatement stmt, Position pos = Position::Capture());
DSLStatement(DSLBlock block);
@ -76,11 +76,11 @@ private:
/**
* Represents a Statement which may have failed and/or have pending errors to report. Converting a
* PossibleStatement into a Statement requires PositionInfo so that any pending errors can be
* PossibleStatement into a Statement requires a Position so that any pending errors can be
* reported at the correct position.
*
* PossibleStatement is used instead of Statement in situations where it is not possible to capture
* the PositionInfo at the time of Statement construction.
* the Position at the time of Statement construction.
*/
class DSLPossibleStatement {
public:

View File

@ -47,7 +47,7 @@ std::shared_ptr<SymbolTable> CurrentSymbolTable();
/**
* Returns an expression referring to the named symbol.
*/
DSLPossibleExpression Symbol(std::string_view name, PositionInfo pos = PositionInfo::Capture());
DSLPossibleExpression Symbol(std::string_view name, Position pos = Position::Capture());
/**
* Returns true if the name refers to a type (user or built-in) in the current symbol table.
@ -62,7 +62,7 @@ bool IsBuiltinType(std::string_view name);
/**
* Adds a variable to the current symbol table.
*/
void AddToSymbolTable(DSLVarBase& var, PositionInfo pos = PositionInfo::Capture());
void AddToSymbolTable(DSLVarBase& var, Position pos = Position::Capture());
} // namespace dsl

View File

@ -90,7 +90,7 @@ public:
DSLType(std::string_view name,
DSLModifiers* modifiers,
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
/**
* Returns true if this type is a bool.
@ -173,8 +173,8 @@ private:
TypeConstant fTypeConstant = kPoison_Type;
friend DSLType Array(const DSLType& base, int count, PositionInfo pos);
friend DSLType Struct(std::string_view name, SkSpan<DSLField> fields, PositionInfo pos);
friend DSLType Array(const DSLType& base, int count, Position pos);
friend DSLType Struct(std::string_view name, SkSpan<DSLField> fields, Position pos);
friend class DSLCore;
friend class DSLFunction;
friend class DSLVarBase;
@ -220,16 +220,16 @@ MATRIX_TYPE(Half)
#undef VECTOR_TYPE
#undef MATRIX_TYPE
DSLType Array(const DSLType& base, int count, PositionInfo pos = PositionInfo::Capture());
DSLType Array(const DSLType& base, int count, Position pos = Position::Capture());
class DSLField {
public:
DSLField(const DSLType type, std::string_view name,
PositionInfo pos = PositionInfo::Capture())
Position pos = Position::Capture())
: DSLField(DSLModifiers(), type, name, pos) {}
DSLField(const DSLModifiers& modifiers, const DSLType type, std::string_view name,
PositionInfo pos = PositionInfo::Capture())
Position pos = Position::Capture())
: fModifiers(modifiers)
, fType(type)
, fName(name)
@ -239,19 +239,19 @@ private:
DSLModifiers fModifiers;
const DSLType fType;
std::string_view fName;
PositionInfo fPosition;
Position fPosition;
friend class DSLCore;
friend DSLType Struct(std::string_view name, SkSpan<DSLField> fields, PositionInfo pos);
friend DSLType Struct(std::string_view name, SkSpan<DSLField> fields, Position pos);
};
DSLType Struct(std::string_view name, SkSpan<DSLField> fields,
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
template<typename... Field>
DSLType Struct(std::string_view name, Field... fields) {
DSLField fieldTypes[] = {std::move(fields)...};
return Struct(name, SkMakeSpan(fieldTypes), PositionInfo());
return Struct(name, SkMakeSpan(fieldTypes), Position());
}
} // namespace dsl

View File

@ -35,15 +35,15 @@ public:
* name conflicts and the variable's name is only important when debugging shaders, the name
* parameter is optional.
*/
DSLVarBase(DSLType type, std::string_view name, DSLExpression initialValue, PositionInfo pos);
DSLVarBase(DSLType type, std::string_view name, DSLExpression initialValue, Position pos);
DSLVarBase(DSLType type, DSLExpression initialValue, PositionInfo pos);
DSLVarBase(DSLType type, DSLExpression initialValue, Position pos);
DSLVarBase(const DSLModifiers& modifiers, DSLType type, std::string_view name,
DSLExpression initialValue, PositionInfo pos);
DSLExpression initialValue, Position pos);
DSLVarBase(const DSLModifiers& modifiers, DSLType type, DSLExpression initialValue,
PositionInfo pos);
Position pos);
DSLVarBase(DSLVarBase&&) = default;
@ -60,57 +60,57 @@ public:
virtual VariableStorage storage() const = 0;
DSLExpression x() {
return DSLExpression(*this, PositionInfo()).x();
return DSLExpression(*this, Position()).x();
}
DSLExpression y() {
return DSLExpression(*this, PositionInfo()).y();
return DSLExpression(*this, Position()).y();
}
DSLExpression z() {
return DSLExpression(*this, PositionInfo()).z();
return DSLExpression(*this, Position()).z();
}
DSLExpression w() {
return DSLExpression(*this, PositionInfo()).w();
return DSLExpression(*this, Position()).w();
}
DSLExpression r() {
return DSLExpression(*this, PositionInfo()).r();
return DSLExpression(*this, Position()).r();
}
DSLExpression g() {
return DSLExpression(*this, PositionInfo()).g();
return DSLExpression(*this, Position()).g();
}
DSLExpression b() {
return DSLExpression(*this, PositionInfo()).b();
return DSLExpression(*this, Position()).b();
}
DSLExpression a() {
return DSLExpression(*this, PositionInfo()).a();
return DSLExpression(*this, Position()).a();
}
DSLExpression field(std::string_view name) {
return DSLExpression(*this, PositionInfo()).field(name);
return DSLExpression(*this, Position()).field(name);
}
DSLPossibleExpression operator[](DSLExpression&& index);
DSLPossibleExpression operator++() {
return ++DSLExpression(*this, PositionInfo());
return ++DSLExpression(*this, Position());
}
DSLPossibleExpression operator++(int) {
return DSLExpression(*this, PositionInfo())++;
return DSLExpression(*this, Position())++;
}
DSLPossibleExpression operator--() {
return --DSLExpression(*this, PositionInfo());
return --DSLExpression(*this, Position());
}
DSLPossibleExpression operator--(int) {
return DSLExpression(*this, PositionInfo())--;
return DSLExpression(*this, Position())--;
}
protected:
@ -133,7 +133,7 @@ protected:
// true if we have attempted to create the SkSL var
bool fInitialized = false;
bool fDeclared = false;
PositionInfo fPosition;
Position fPosition;
friend class DSLCore;
friend class DSLExpression;
@ -152,22 +152,22 @@ public:
DSLVar(DSLType type, std::string_view name = "var",
DSLExpression initialValue = DSLExpression(),
PositionInfo pos = PositionInfo::Capture())
Position pos = Position::Capture())
: INHERITED(type, name, std::move(initialValue), pos) {}
DSLVar(DSLType type, const char* name, DSLExpression initialValue = DSLExpression(),
PositionInfo pos = PositionInfo::Capture())
Position pos = Position::Capture())
: DSLVar(type, std::string_view(name), std::move(initialValue), pos) {}
DSLVar(DSLType type, DSLExpression initialValue, PositionInfo pos = PositionInfo::Capture())
DSLVar(DSLType type, DSLExpression initialValue, Position pos = Position::Capture())
: INHERITED(type, std::move(initialValue), pos) {}
DSLVar(const DSLModifiers& modifiers, DSLType type, std::string_view name = "var",
DSLExpression initialValue = DSLExpression(), PositionInfo pos = PositionInfo::Capture())
DSLExpression initialValue = DSLExpression(), Position pos = Position::Capture())
: INHERITED(modifiers, type, name, std::move(initialValue), pos) {}
DSLVar(const DSLModifiers& modifiers, DSLType type, const char* name,
DSLExpression initialValue = DSLExpression(), PositionInfo pos = PositionInfo::Capture())
DSLExpression initialValue = DSLExpression(), Position pos = Position::Capture())
: DSLVar(modifiers, type, std::string_view(name), std::move(initialValue), pos) {}
DSLVar(DSLVar&&) = default;
@ -199,23 +199,23 @@ public:
DSLGlobalVar() = default;
DSLGlobalVar(DSLType type, std::string_view name = "var",
DSLExpression initialValue = DSLExpression(), PositionInfo pos = PositionInfo::Capture())
DSLExpression initialValue = DSLExpression(), Position pos = Position::Capture())
: INHERITED(type, name, std::move(initialValue), pos) {}
DSLGlobalVar(DSLType type, const char* name, DSLExpression initialValue = DSLExpression(),
PositionInfo pos = PositionInfo::Capture())
Position pos = Position::Capture())
: DSLGlobalVar(type, std::string_view(name), std::move(initialValue), pos) {}
DSLGlobalVar(DSLType type, DSLExpression initialValue,
PositionInfo pos = PositionInfo::Capture())
Position pos = Position::Capture())
: INHERITED(type, std::move(initialValue), pos) {}
DSLGlobalVar(const DSLModifiers& modifiers, DSLType type, std::string_view name = "var",
DSLExpression initialValue = DSLExpression(), PositionInfo pos = PositionInfo::Capture())
DSLExpression initialValue = DSLExpression(), Position pos = Position::Capture())
: INHERITED(modifiers, type, name, std::move(initialValue), pos) {}
DSLGlobalVar(const DSLModifiers& modifiers, DSLType type, const char* name,
DSLExpression initialValue = DSLExpression(), PositionInfo pos = PositionInfo::Capture())
DSLExpression initialValue = DSLExpression(), Position pos = Position::Capture())
: DSLGlobalVar(modifiers, type, std::string_view(name), std::move(initialValue), pos) {}
DSLGlobalVar(const char* name);
@ -242,19 +242,19 @@ public:
* half4 shader::eval(float2 coords);
* half4 colorFilter::eval(half4 input);
*/
DSLExpression eval(DSLExpression x, PositionInfo pos = PositionInfo::Capture());
DSLExpression eval(DSLExpression x, Position pos = Position::Capture());
/**
* Implements the following method call:
* half4 blender::eval(half4 src, half4 dst);
*/
DSLExpression eval(DSLExpression x, DSLExpression y,
PositionInfo pos = PositionInfo::Capture());
Position pos = Position::Capture());
private:
DSLExpression eval(ExpressionArray args, PositionInfo pos);
DSLExpression eval(ExpressionArray args, Position pos);
std::unique_ptr<SkSL::Expression> methodCall(std::string_view methodName, PositionInfo pos);
std::unique_ptr<SkSL::Expression> methodCall(std::string_view methodName, Position pos);
using INHERITED = DSLVarBase;
};
@ -267,18 +267,18 @@ public:
DSLParameter() = default;
DSLParameter(DSLType type, std::string_view name = "var",
PositionInfo pos = PositionInfo::Capture())
Position pos = Position::Capture())
: INHERITED(type, name, DSLExpression(), pos) {}
DSLParameter(DSLType type, const char* name, PositionInfo pos = PositionInfo::Capture())
DSLParameter(DSLType type, const char* name, Position pos = Position::Capture())
: DSLParameter(type, std::string_view(name), pos) {}
DSLParameter(const DSLModifiers& modifiers, DSLType type, std::string_view name = "var",
PositionInfo pos = PositionInfo::Capture())
Position pos = Position::Capture())
: INHERITED(modifiers, type, name, DSLExpression(), pos) {}
DSLParameter(const DSLModifiers& modifiers, DSLType type, const char* name,
PositionInfo pos = PositionInfo::Capture())
Position pos = Position::Capture())
: DSLParameter(modifiers, type, std::string_view(name), pos) {}
DSLParameter(DSLParameter&&) = default;

View File

@ -21,18 +21,18 @@ namespace SkSL {
#define __has_builtin(x) 0
#endif
class PositionInfo {
class Position {
public:
PositionInfo(const char* file = nullptr, int line = -1)
Position(const char* file = nullptr, int line = -1)
: fFile(file)
, fLine(line) {}
#if __has_builtin(__builtin_FILE) && __has_builtin(__builtin_LINE)
static PositionInfo Capture(const char* file = __builtin_FILE(), int line = __builtin_LINE()) {
return PositionInfo(file, line);
static Position Capture(const char* file = __builtin_FILE(), int line = __builtin_LINE()) {
return Position(file, line);
}
#else
static PositionInfo Capture() { return PositionInfo(); }
static Position Capture() { return Position(); }
#endif // __has_builtin(__builtin_FILE) && __has_builtin(__builtin_LINE)
const char* file_name() const {
@ -59,7 +59,7 @@ public:
SkASSERT(fPendingErrors.empty());
}
void error(std::string_view msg, PositionInfo position);
void error(std::string_view msg, Position position);
/**
* Reports an error message at the given line of the source text. Errors reported
@ -71,7 +71,7 @@ public:
void setSource(const char* source) { fSource = source; }
void reportPendingErrors(PositionInfo pos) {
void reportPendingErrors(Position pos) {
for (const std::string& msg : fPendingErrors) {
this->handleError(msg, pos);
}
@ -90,10 +90,10 @@ protected:
/**
* Called when an error is reported.
*/
virtual void handleError(std::string_view msg, PositionInfo position) = 0;
virtual void handleError(std::string_view msg, Position position) = 0;
private:
PositionInfo position(int offset) const;
Position position(int offset) const;
const char* fSource = nullptr;
std::vector<std::string> fPendingErrors;
@ -105,7 +105,7 @@ private:
*/
class TestingOnly_AbortErrorReporter : public ErrorReporter {
public:
void handleError(std::string_view msg, PositionInfo pos) override {
void handleError(std::string_view msg, Position pos) override {
SK_ABORT("%.*s", (int)msg.length(), msg.data());
}
};

View File

@ -250,7 +250,7 @@ sk_sp<SkRuntimeEffect> SkRuntimeEffect::MakeFromDSL(std::unique_ptr<SkSL::Progra
SkSL::ErrorReporter* errors) {
Result result = MakeFromDSL(std::move(program), options, kind);
if (!result.effect) {
errors->error(result.errorText.c_str(), SkSL::PositionInfo(nullptr, -1));
errors->error(result.errorText.c_str(), SkSL::Position(nullptr, -1));
}
return std::move(result.effect);
}

View File

@ -249,7 +249,7 @@ private:
class TrivialErrorReporter : public ErrorReporter {
public:
~TrivialErrorReporter() override { this->reportPendingErrors({}); }
void handleError(std::string_view, PositionInfo) override {}
void handleError(std::string_view, Position) override {}
};
// This isn't actually using ProgramVisitor, because it only considers a subset of the fields for

View File

@ -519,7 +519,7 @@ std::unique_ptr<Expression> Compiler::convertIdentifier(int line, std::string_vi
case Symbol::Kind::kType: {
// go through DSLType so we report errors on private types
dsl::DSLModifiers modifiers;
dsl::DSLType dslType(result->name(), &modifiers, PositionInfo(/*file=*/nullptr, line));
dsl::DSLType dslType(result->name(), &modifiers, Position(/*file=*/nullptr, line));
return TypeReference::Convert(*fContext, line, &dslType.skslType());
}
case Symbol::Kind::kExternal: {
@ -664,7 +664,7 @@ bool Compiler::toSPIRV(Program& program, OutputStream& out) {
errors.append(disassembly);
}
this->errorReporter().error(-1, errors);
this->errorReporter().reportPendingErrors(PositionInfo());
this->errorReporter().reportPendingErrors(Position());
#else
SkDEBUGFAILF("%s", errors.c_str());
#endif
@ -748,7 +748,7 @@ bool Compiler::toMetal(Program& program, std::string* out) {
#endif // defined(SKSL_STANDALONE) || SK_SUPPORT_GPU
void Compiler::handleError(std::string_view msg, PositionInfo pos) {
void Compiler::handleError(std::string_view msg, Position pos) {
fErrorText += "error: ";
if (pos.line() >= 1) {
fErrorText += std::to_string(pos.line()) + ": ";

View File

@ -160,7 +160,7 @@ public:
bool toMetal(Program& program, std::string* out);
void handleError(std::string_view msg, PositionInfo pos);
void handleError(std::string_view msg, Position pos);
std::string errorText(bool showCount = true);
@ -211,7 +211,7 @@ private:
CompilerErrorReporter(Compiler* compiler)
: fCompiler(*compiler) {}
void handleError(std::string_view msg, PositionInfo pos) override {
void handleError(std::string_view msg, Position pos) override {
fCompiler.handleError(msg, pos);
}

View File

@ -229,12 +229,12 @@ std::string_view DSLParser::text(Token token) {
return std::string_view(fText->data() + token.fOffset, token.fLength);
}
PositionInfo DSLParser::position(Token t) {
Position DSLParser::position(Token t) {
return this->position(t.fLine);
}
PositionInfo DSLParser::position(int line) {
return PositionInfo("<unknown>", line);
Position DSLParser::position(int line) {
return Position("<unknown>", line);
}
void DSLParser::error(Token token, std::string msg) {
@ -479,7 +479,7 @@ bool DSLParser::parseInitializer(int line, DSLExpression* initializer) {
/* (LBRACKET expression? RBRACKET)* (EQ assignmentExpression)? (COMMA IDENTIFER
(LBRACKET expression? RBRACKET)* (EQ assignmentExpression)?)* SEMICOLON */
void DSLParser::globalVarDeclarationEnd(PositionInfo pos, const dsl::DSLModifiers& mods,
void DSLParser::globalVarDeclarationEnd(Position pos, const dsl::DSLModifiers& mods,
dsl::DSLType baseType, std::string_view name) {
using namespace dsl;
int line = this->peek().fLine;
@ -518,7 +518,7 @@ void DSLParser::globalVarDeclarationEnd(PositionInfo pos, const dsl::DSLModifier
/* (LBRACKET expression? RBRACKET)* (EQ assignmentExpression)? (COMMA IDENTIFER
(LBRACKET expression? RBRACKET)* (EQ assignmentExpression)?)* SEMICOLON */
DSLStatement DSLParser::localVarDeclarationEnd(PositionInfo pos, const dsl::DSLModifiers& mods,
DSLStatement DSLParser::localVarDeclarationEnd(Position pos, const dsl::DSLModifiers& mods,
dsl::DSLType baseType, std::string_view name) {
using namespace dsl;
int line = this->peek().fLine;
@ -702,7 +702,7 @@ std::optional<DSLWrapper<DSLParameter>> DSLParser::parameter(size_t paramIndex)
}
Token name;
std::string_view paramText;
PositionInfo paramPos;
Position paramPos;
if (this->checkIdentifier(&name)) {
paramPos = this->position(name);
paramText = this->text(name);

View File

@ -54,9 +54,9 @@ public:
std::string_view text(Token token);
PositionInfo position(Token token);
Position position(Token token);
PositionInfo position(int line);
Position position(int line);
private:
static void InitLayoutMap();
@ -143,7 +143,7 @@ private:
const Token& name);
struct VarDeclarationsPrefix {
PositionInfo fPosition;
Position fPosition;
dsl::DSLModifiers fModifiers;
dsl::DSLType fType = dsl::DSLType(dsl::kVoid_Type);
Token fName;
@ -163,10 +163,10 @@ private:
bool parseInitializer(int line, dsl::DSLExpression* initializer);
void globalVarDeclarationEnd(PositionInfo position, const dsl::DSLModifiers& mods,
void globalVarDeclarationEnd(Position position, const dsl::DSLModifiers& mods,
dsl::DSLType baseType, std::string_view name);
dsl::DSLStatement localVarDeclarationEnd(PositionInfo position, const dsl::DSLModifiers& mods,
dsl::DSLStatement localVarDeclarationEnd(Position position, const dsl::DSLModifiers& mods,
dsl::DSLType baseType, std::string_view name);
std::optional<dsl::DSLWrapper<dsl::DSLParameter>> parameter(size_t paramIndex);
@ -291,7 +291,7 @@ private:
private:
class ForwardingErrorReporter : public ErrorReporter {
public:
void handleError(std::string_view msg, PositionInfo pos) override {
void handleError(std::string_view msg, Position pos) override {
fErrors.push_back({std::string(msg), pos});
}
@ -304,7 +304,7 @@ private:
private:
struct Error {
std::string fMsg;
PositionInfo fPos;
Position fPos;
};
SkTArray<Error> fErrors;
@ -312,7 +312,7 @@ private:
void restoreErrorReporter() {
SkASSERT(fOldErrorReporter);
fErrorReporter.reportPendingErrors(PositionInfo());
fErrorReporter.reportPendingErrors(Position());
dsl::SetErrorReporter(fOldErrorReporter);
fOldErrorReporter = nullptr;
}

View File

@ -13,7 +13,7 @@
namespace SkSL {
void ErrorReporter::error(std::string_view msg, PositionInfo position) {
void ErrorReporter::error(std::string_view msg, Position position) {
if (skstd::contains(msg, Compiler::POISON_TAG)) {
// don't report errors on poison values
return;
@ -31,7 +31,7 @@ void ErrorReporter::error(int line, std::string_view msg) {
++fErrorCount;
fPendingErrors.push_back(std::string(msg));
} else {
this->error(msg, PositionInfo(/*file=*/nullptr, line));
this->error(msg, Position(/*file=*/nullptr, line));
}
}

View File

@ -122,11 +122,11 @@ void ThreadContext::SetErrorReporter(ErrorReporter* errorReporter) {
Context().fErrors = errorReporter;
}
void ThreadContext::ReportError(std::string_view msg, PositionInfo info) {
GetErrorReporter().error(msg, info);
void ThreadContext::ReportError(std::string_view msg, Position pos) {
GetErrorReporter().error(msg, pos);
}
void ThreadContext::DefaultErrorReporter::handleError(std::string_view msg, PositionInfo pos) {
void ThreadContext::DefaultErrorReporter::handleError(std::string_view msg, Position pos) {
if (pos.line() > -1) {
SK_ABORT("error: %s: %d: %.*sNo SkSL error reporter configured, treating this as a fatal "
"error\n", pos.file_name(), pos.line(), (int)msg.length(), msg.data());
@ -137,7 +137,7 @@ void ThreadContext::DefaultErrorReporter::handleError(std::string_view msg, Posi
}
void ThreadContext::ReportErrors(PositionInfo pos) {
void ThreadContext::ReportErrors(Position pos) {
GetErrorReporter().reportPendingErrors(pos);
}

View File

@ -175,12 +175,12 @@ public:
* Notifies the current ErrorReporter that an error has occurred. The default error handler
* prints the message to stderr and aborts.
*/
static void ReportError(std::string_view msg, PositionInfo info = PositionInfo::Capture());
static void ReportError(std::string_view msg, Position pos = Position::Capture());
/**
* Forwards any pending errors to the DSL ErrorReporter.
*/
static void ReportErrors(PositionInfo pos);
static void ReportErrors(Position pos);
static ThreadContext& Instance();
@ -188,7 +188,7 @@ public:
private:
class DefaultErrorReporter : public ErrorReporter {
void handleError(std::string_view msg, PositionInfo pos) override;
void handleError(std::string_view msg, Position pos) override;
};
void setupSymbolTable();

View File

@ -2778,7 +2778,7 @@ bool MetalCodeGenerator::generateCode() {
write_stringstream(fExtraFunctionPrototypes, *fOut);
write_stringstream(fExtraFunctions, *fOut);
write_stringstream(body, *fOut);
fContext.fErrors->reportPendingErrors(PositionInfo());
fContext.fErrors->reportPendingErrors(Position());
return fContext.fErrors->errorCount() == 0;
}

View File

@ -3658,7 +3658,7 @@ bool SPIRVCodeGenerator::generateCode() {
this->writeWord(fIdCount, *fOut);
this->writeWord(0, *fOut); // reserved, always zero
write_stringstream(buffer, *fOut);
fContext.fErrors->reportPendingErrors(PositionInfo());
fContext.fErrors->reportPendingErrors(Position());
return fContext.fErrors->errorCount() == 0;
}

View File

@ -13,12 +13,12 @@ namespace SkSL {
namespace dsl {
DSLCase::DSLCase(DSLExpression value, SkSL::StatementArray statements, PositionInfo pos)
DSLCase::DSLCase(DSLExpression value, SkSL::StatementArray statements, Position pos)
: fValue(std::move(value))
, fStatements(std::move(statements))
, fPosition(pos) {}
DSLCase::DSLCase(DSLExpression value, SkTArray<DSLStatement> statements, PositionInfo pos)
DSLCase::DSLCase(DSLExpression value, SkTArray<DSLStatement> statements, Position pos)
: fValue(std::move(value))
, fPosition(pos) {
fStatements.reserve_back(statements.count());

View File

@ -97,7 +97,7 @@ public:
success = true;
}
if (!success) {
ThreadContext::ReportErrors(PositionInfo());
ThreadContext::ReportErrors(Position());
}
if (pool) {
pool->detachFromThread();
@ -133,11 +133,11 @@ public:
ThreadContext::Compiler().convertIdentifier(-1, name), std::move(argArray));
}
static DSLStatement Break(PositionInfo pos) {
static DSLStatement Break(Position pos) {
return SkSL::BreakStatement::Make(pos.line());
}
static DSLStatement Continue(PositionInfo pos) {
static DSLStatement Continue(Position pos) {
return SkSL::ContinueStatement::Make(pos.line());
}
@ -146,7 +146,7 @@ public:
ThreadContext::Modifiers(modifiers.fModifiers)));
}
static DSLStatement Declare(DSLVar& var, PositionInfo pos) {
static DSLStatement Declare(DSLVar& var, Position pos) {
if (var.fDeclared) {
ThreadContext::ReportError("variable has already been declared", pos);
}
@ -154,7 +154,7 @@ public:
return DSLWriter::Declaration(var);
}
static DSLStatement Declare(SkTArray<DSLVar>& vars, PositionInfo pos) {
static DSLStatement Declare(SkTArray<DSLVar>& vars, Position pos) {
StatementArray statements;
for (DSLVar& v : vars) {
statements.push_back(Declare(v, pos).release());
@ -162,7 +162,7 @@ public:
return SkSL::Block::MakeUnscoped(pos.line(), std::move(statements));
}
static void Declare(DSLGlobalVar& var, PositionInfo pos) {
static void Declare(DSLGlobalVar& var, Position pos) {
if (var.fDeclared) {
ThreadContext::ReportError("variable has already been declared", pos);
}
@ -185,13 +185,13 @@ public:
}
}
static void Declare(SkTArray<DSLGlobalVar>& vars, PositionInfo pos) {
static void Declare(SkTArray<DSLGlobalVar>& vars, Position pos) {
for (DSLGlobalVar& v : vars) {
Declare(v, pos);
}
}
static DSLStatement Discard(PositionInfo pos) {
static DSLStatement Discard(Position pos) {
return SkSL::DiscardStatement::Make(pos.line());
}
@ -200,7 +200,7 @@ public:
}
static DSLPossibleStatement For(DSLStatement initializer, DSLExpression test,
DSLExpression next, DSLStatement stmt, PositionInfo pos) {
DSLExpression next, DSLStatement stmt, Position pos) {
return ForStatement::Convert(ThreadContext::Context(), pos.line(),
initializer.releaseIfPossible(), test.releaseIfPossible(),
next.releaseIfPossible(), stmt.release(),
@ -213,7 +213,7 @@ public:
ifTrue.release(), ifFalse.releaseIfPossible());
}
static void FindRTAdjust(SkSL::InterfaceBlock& intf, PositionInfo pos) {
static void FindRTAdjust(SkSL::InterfaceBlock& intf, Position pos) {
const std::vector<SkSL::Type::Field>& fields =
intf.variable().type().componentType().fields();
const Context& context = ThreadContext::Context();
@ -234,7 +234,7 @@ public:
static DSLGlobalVar InterfaceBlock(const DSLModifiers& modifiers, std::string_view typeName,
SkTArray<DSLField> fields, std::string_view varName,
int arraySize, PositionInfo pos) {
int arraySize, Position pos) {
// We need to create a new struct type for the interface block, but we don't want it in the
// symbol table. Since dsl::Struct automatically sticks it in the symbol table, we create it
// the old fashioned way with MakeStructType.
@ -283,7 +283,7 @@ public:
return var;
}
static DSLStatement Return(DSLExpression value, PositionInfo pos) {
static DSLStatement Return(DSLExpression value, Position pos) {
// Note that because Return is called before the function in which it resides exists, at
// this point we do not know the function's return type. We therefore do not check for
// errors, or coerce the value to the correct type, until the return statement is actually
@ -292,7 +292,7 @@ public:
}
static DSLExpression Swizzle(DSLExpression base, SkSL::SwizzleComponent::Type a,
PositionInfo pos) {
Position pos) {
return DSLExpression(Swizzle::Convert(ThreadContext::Context(), base.release(),
ComponentArray{a}),
pos);
@ -301,7 +301,7 @@ public:
static DSLExpression Swizzle(DSLExpression base,
SkSL::SwizzleComponent::Type a,
SkSL::SwizzleComponent::Type b,
PositionInfo pos) {
Position pos) {
return DSLExpression(Swizzle::Convert(ThreadContext::Context(), base.release(),
ComponentArray{a, b}),
pos);
@ -311,7 +311,7 @@ public:
SkSL::SwizzleComponent::Type a,
SkSL::SwizzleComponent::Type b,
SkSL::SwizzleComponent::Type c,
PositionInfo pos) {
Position pos) {
return DSLExpression(Swizzle::Convert(ThreadContext::Context(), base.release(),
ComponentArray{a, b, c}),
pos);
@ -322,7 +322,7 @@ public:
SkSL::SwizzleComponent::Type b,
SkSL::SwizzleComponent::Type c,
SkSL::SwizzleComponent::Type d,
PositionInfo pos) {
Position pos) {
return DSLExpression(Swizzle::Convert(ThreadContext::Context(), base.release(),
ComponentArray{a,b,c,d}),
pos);
@ -372,20 +372,20 @@ DSLExpression sk_Position() {
return DSLCore::sk_Position();
}
void AddExtension(std::string_view name, PositionInfo pos) {
void AddExtension(std::string_view name, Position pos) {
ThreadContext::ProgramElements().push_back(std::make_unique<SkSL::Extension>(pos.line(), name));
ThreadContext::ReportErrors(pos);
}
DSLStatement Break(PositionInfo pos) {
DSLStatement Break(Position pos) {
return DSLCore::Break(pos);
}
DSLStatement Continue(PositionInfo pos) {
DSLStatement Continue(Position pos) {
return DSLCore::Continue(pos);
}
void Declare(const DSLModifiers& modifiers, PositionInfo pos) {
void Declare(const DSLModifiers& modifiers, Position pos) {
SkSL::ProgramKind kind = ThreadContext::GetProgramConfig()->fKind;
if (kind != ProgramKind::kFragment &&
kind != ProgramKind::kVertex) {
@ -408,40 +408,40 @@ void Declare(const DSLModifiers& modifiers, PositionInfo pos) {
//
// So, we put the initial value onto the Var itself instead of the Declare to guarantee that it is
// always executed in the correct order.
DSLStatement Declare(DSLVar& var, PositionInfo pos) {
DSLStatement Declare(DSLVar& var, Position pos) {
return DSLCore::Declare(var, pos);
}
DSLStatement Declare(SkTArray<DSLVar>& vars, PositionInfo pos) {
DSLStatement Declare(SkTArray<DSLVar>& vars, Position pos) {
return DSLCore::Declare(vars, pos);
}
void Declare(DSLGlobalVar& var, PositionInfo pos) {
void Declare(DSLGlobalVar& var, Position pos) {
DSLCore::Declare(var, pos);
}
void Declare(SkTArray<DSLGlobalVar>& vars, PositionInfo pos) {
void Declare(SkTArray<DSLGlobalVar>& vars, Position pos) {
DSLCore::Declare(vars, pos);
}
DSLStatement Discard(PositionInfo pos) {
DSLStatement Discard(Position pos) {
if (ThreadContext::GetProgramConfig()->fKind != ProgramKind::kFragment) {
ThreadContext::ReportError("discard statement is only permitted in fragment shaders", pos);
}
return DSLCore::Discard(pos);
}
DSLStatement Do(DSLStatement stmt, DSLExpression test, PositionInfo pos) {
DSLStatement Do(DSLStatement stmt, DSLExpression test, Position pos) {
return DSLStatement(DSLCore::Do(std::move(stmt), std::move(test)), pos);
}
DSLStatement For(DSLStatement initializer, DSLExpression test, DSLExpression next,
DSLStatement stmt, PositionInfo pos) {
DSLStatement stmt, Position pos) {
return DSLStatement(DSLCore::For(std::move(initializer), std::move(test), std::move(next),
std::move(stmt), pos), pos);
}
DSLStatement If(DSLExpression test, DSLStatement ifTrue, DSLStatement ifFalse, PositionInfo pos) {
DSLStatement If(DSLExpression test, DSLStatement ifTrue, DSLStatement ifFalse, Position pos) {
return DSLStatement(DSLCore::If(std::move(test), std::move(ifTrue), std::move(ifFalse),
/*isStatic=*/false),
pos);
@ -449,7 +449,7 @@ DSLStatement If(DSLExpression test, DSLStatement ifTrue, DSLStatement ifFalse, P
DSLGlobalVar InterfaceBlock(const DSLModifiers& modifiers, std::string_view typeName,
SkTArray<DSLField> fields, std::string_view varName, int arraySize,
PositionInfo pos) {
Position pos) {
SkSL::ProgramKind kind = ThreadContext::GetProgramConfig()->fKind;
if (kind != ProgramKind::kFragment &&
kind != ProgramKind::kVertex) {
@ -459,18 +459,18 @@ DSLGlobalVar InterfaceBlock(const DSLModifiers& modifiers, std::string_view typ
return DSLCore::InterfaceBlock(modifiers, typeName, std::move(fields), varName, arraySize, pos);
}
DSLStatement Return(DSLExpression expr, PositionInfo pos) {
DSLStatement Return(DSLExpression expr, Position pos) {
return DSLCore::Return(std::move(expr), pos);
}
DSLExpression Select(DSLExpression test, DSLExpression ifTrue, DSLExpression ifFalse,
PositionInfo pos) {
Position pos) {
return DSLExpression(DSLCore::Select(std::move(test), std::move(ifTrue), std::move(ifFalse)),
pos);
}
DSLStatement StaticIf(DSLExpression test, DSLStatement ifTrue, DSLStatement ifFalse,
PositionInfo pos) {
Position pos) {
return DSLStatement(DSLCore::If(std::move(test), std::move(ifTrue), std::move(ifFalse),
/*isStatic=*/true),
pos);
@ -480,7 +480,7 @@ DSLPossibleStatement PossibleStaticSwitch(DSLExpression value, SkTArray<DSLCase>
return DSLCore::Switch(std::move(value), std::move(cases), /*isStatic=*/true);
}
DSLStatement StaticSwitch(DSLExpression value, SkTArray<DSLCase> cases, PositionInfo pos) {
DSLStatement StaticSwitch(DSLExpression value, SkTArray<DSLCase> cases, Position pos) {
return DSLStatement(PossibleStaticSwitch(std::move(value), std::move(cases)), pos);
}
@ -488,203 +488,203 @@ DSLPossibleStatement PossibleSwitch(DSLExpression value, SkTArray<DSLCase> cases
return DSLCore::Switch(std::move(value), std::move(cases), /*isStatic=*/false);
}
DSLStatement Switch(DSLExpression value, SkTArray<DSLCase> cases, PositionInfo pos) {
DSLStatement Switch(DSLExpression value, SkTArray<DSLCase> cases, Position pos) {
return DSLStatement(PossibleSwitch(std::move(value), std::move(cases)), pos);
}
DSLStatement While(DSLExpression test, DSLStatement stmt, PositionInfo pos) {
DSLStatement While(DSLExpression test, DSLStatement stmt, Position pos) {
return DSLStatement(DSLCore::While(std::move(test), std::move(stmt)), pos);
}
DSLExpression Abs(DSLExpression x, PositionInfo pos) {
DSLExpression Abs(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("abs", std::move(x)), pos);
}
DSLExpression All(DSLExpression x, PositionInfo pos) {
DSLExpression All(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("all", std::move(x)), pos);
}
DSLExpression Any(DSLExpression x, PositionInfo pos) {
DSLExpression Any(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("any", std::move(x)), pos);
}
DSLExpression Atan(DSLExpression y_over_x, PositionInfo pos) {
DSLExpression Atan(DSLExpression y_over_x, Position pos) {
return DSLExpression(DSLCore::Call("atan", std::move(y_over_x)), pos);
}
DSLExpression Atan(DSLExpression y, DSLExpression x, PositionInfo pos) {
DSLExpression Atan(DSLExpression y, DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("atan", std::move(y), std::move(x)), pos);
}
DSLExpression Ceil(DSLExpression x, PositionInfo pos) {
DSLExpression Ceil(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("ceil", std::move(x)), pos);
}
DSLExpression Clamp(DSLExpression x, DSLExpression min, DSLExpression max, PositionInfo pos) {
DSLExpression Clamp(DSLExpression x, DSLExpression min, DSLExpression max, Position pos) {
return DSLExpression(DSLCore::Call("clamp", std::move(x), std::move(min), std::move(max)), pos);
}
DSLExpression Cos(DSLExpression x, PositionInfo pos) {
DSLExpression Cos(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("cos", std::move(x)), pos);
}
DSLExpression Cross(DSLExpression x, DSLExpression y, PositionInfo pos) {
DSLExpression Cross(DSLExpression x, DSLExpression y, Position pos) {
return DSLExpression(DSLCore::Call("cross", std::move(x), std::move(y)), pos);
}
DSLExpression Degrees(DSLExpression x, PositionInfo pos) {
DSLExpression Degrees(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("degrees", std::move(x)), pos);
}
DSLExpression Distance(DSLExpression x, DSLExpression y, PositionInfo pos) {
DSLExpression Distance(DSLExpression x, DSLExpression y, Position pos) {
return DSLExpression(DSLCore::Call("distance", std::move(x), std::move(y)), pos);
}
DSLExpression Dot(DSLExpression x, DSLExpression y, PositionInfo pos) {
DSLExpression Dot(DSLExpression x, DSLExpression y, Position pos) {
return DSLExpression(DSLCore::Call("dot", std::move(x), std::move(y)), pos);
}
DSLExpression Equal(DSLExpression x, DSLExpression y, PositionInfo pos) {
DSLExpression Equal(DSLExpression x, DSLExpression y, Position pos) {
return DSLExpression(DSLCore::Call("equal", std::move(x), std::move(y)), pos);
}
DSLExpression Exp(DSLExpression x, PositionInfo pos) {
DSLExpression Exp(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("exp", std::move(x)), pos);
}
DSLExpression Exp2(DSLExpression x, PositionInfo pos) {
DSLExpression Exp2(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("exp2", std::move(x)), pos);
}
DSLExpression Faceforward(DSLExpression n, DSLExpression i, DSLExpression nref, PositionInfo pos) {
DSLExpression Faceforward(DSLExpression n, DSLExpression i, DSLExpression nref, Position pos) {
return DSLExpression(DSLCore::Call("faceforward", std::move(n), std::move(i), std::move(nref)),
pos);
}
DSLExpression Fract(DSLExpression x, PositionInfo pos) {
DSLExpression Fract(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("fract", std::move(x)), pos);
}
DSLExpression Floor(DSLExpression x, PositionInfo pos) {
DSLExpression Floor(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("floor", std::move(x)), pos);
}
DSLExpression GreaterThan(DSLExpression x, DSLExpression y, PositionInfo pos) {
DSLExpression GreaterThan(DSLExpression x, DSLExpression y, Position pos) {
return DSLExpression(DSLCore::Call("greaterThan", std::move(x), std::move(y)), pos);
}
DSLExpression GreaterThanEqual(DSLExpression x, DSLExpression y, PositionInfo pos) {
DSLExpression GreaterThanEqual(DSLExpression x, DSLExpression y, Position pos) {
return DSLExpression(DSLCore::Call("greaterThanEqual", std::move(x), std::move(y)), pos);
}
DSLExpression Inverse(DSLExpression x, PositionInfo pos) {
DSLExpression Inverse(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("inverse", std::move(x)), pos);
}
DSLExpression Inversesqrt(DSLExpression x, PositionInfo pos) {
DSLExpression Inversesqrt(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("inversesqrt", std::move(x)), pos);
}
DSLExpression Length(DSLExpression x, PositionInfo pos) {
DSLExpression Length(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("length", std::move(x)), pos);
}
DSLExpression LessThan(DSLExpression x, DSLExpression y, PositionInfo pos) {
DSLExpression LessThan(DSLExpression x, DSLExpression y, Position pos) {
return DSLExpression(DSLCore::Call("lessThan", std::move(x), std::move(y)), pos);
}
DSLExpression LessThanEqual(DSLExpression x, DSLExpression y, PositionInfo pos) {
DSLExpression LessThanEqual(DSLExpression x, DSLExpression y, Position pos) {
return DSLExpression(DSLCore::Call("lessThanEqual", std::move(x), std::move(y)), pos);
}
DSLExpression Log(DSLExpression x, PositionInfo pos) {
DSLExpression Log(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("log", std::move(x)), pos);
}
DSLExpression Log2(DSLExpression x, PositionInfo pos) {
DSLExpression Log2(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("log2", std::move(x)), pos);
}
DSLExpression Max(DSLExpression x, DSLExpression y, PositionInfo pos) {
DSLExpression Max(DSLExpression x, DSLExpression y, Position pos) {
return DSLExpression(DSLCore::Call("max", std::move(x), std::move(y)), pos);
}
DSLExpression Min(DSLExpression x, DSLExpression y, PositionInfo pos) {
DSLExpression Min(DSLExpression x, DSLExpression y, Position pos) {
return DSLExpression(DSLCore::Call("min", std::move(x), std::move(y)), pos);
}
DSLExpression Mix(DSLExpression x, DSLExpression y, DSLExpression a, PositionInfo pos) {
DSLExpression Mix(DSLExpression x, DSLExpression y, DSLExpression a, Position pos) {
return DSLExpression(DSLCore::Call("mix", std::move(x), std::move(y), std::move(a)), pos);
}
DSLExpression Mod(DSLExpression x, DSLExpression y, PositionInfo pos) {
DSLExpression Mod(DSLExpression x, DSLExpression y, Position pos) {
return DSLExpression(DSLCore::Call("mod", std::move(x), std::move(y)), pos);
}
DSLExpression Normalize(DSLExpression x, PositionInfo pos) {
DSLExpression Normalize(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("normalize", std::move(x)), pos);
}
DSLExpression NotEqual(DSLExpression x, DSLExpression y, PositionInfo pos) {
DSLExpression NotEqual(DSLExpression x, DSLExpression y, Position pos) {
return DSLExpression(DSLCore::Call("notEqual", std::move(x), std::move(y)), pos);
}
DSLExpression Pow(DSLExpression x, DSLExpression y, PositionInfo pos) {
DSLExpression Pow(DSLExpression x, DSLExpression y, Position pos) {
return DSLExpression(DSLCore::Call("pow", std::move(x), std::move(y)), pos);
}
DSLExpression Radians(DSLExpression x, PositionInfo pos) {
DSLExpression Radians(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("radians", std::move(x)), pos);
}
DSLExpression Reflect(DSLExpression i, DSLExpression n, PositionInfo pos) {
DSLExpression Reflect(DSLExpression i, DSLExpression n, Position pos) {
return DSLExpression(DSLCore::Call("reflect", std::move(i), std::move(n)), pos);
}
DSLExpression Refract(DSLExpression i, DSLExpression n, DSLExpression eta, PositionInfo pos) {
DSLExpression Refract(DSLExpression i, DSLExpression n, DSLExpression eta, Position pos) {
return DSLExpression(DSLCore::Call("refract", std::move(i), std::move(n), std::move(eta)), pos);
}
DSLExpression Round(DSLExpression x, PositionInfo pos) {
DSLExpression Round(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("round", std::move(x)), pos);
}
DSLExpression Saturate(DSLExpression x, PositionInfo pos) {
DSLExpression Saturate(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("saturate", std::move(x)), pos);
}
DSLExpression Sign(DSLExpression x, PositionInfo pos) {
DSLExpression Sign(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("sign", std::move(x)), pos);
}
DSLExpression Sin(DSLExpression x, PositionInfo pos) {
DSLExpression Sin(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("sin", std::move(x)), pos);
}
DSLExpression Smoothstep(DSLExpression edge1, DSLExpression edge2, DSLExpression x,
PositionInfo pos) {
Position pos) {
return DSLExpression(DSLCore::Call("smoothstep", std::move(edge1), std::move(edge2),
std::move(x)),
pos);
}
DSLExpression Sqrt(DSLExpression x, PositionInfo pos) {
DSLExpression Sqrt(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("sqrt", std::move(x)), pos);
}
DSLExpression Step(DSLExpression edge, DSLExpression x, PositionInfo pos) {
DSLExpression Step(DSLExpression edge, DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("step", std::move(edge), std::move(x)), pos);
}
DSLExpression Swizzle(DSLExpression base, SkSL::SwizzleComponent::Type a,
PositionInfo pos) {
Position pos) {
return DSLCore::Swizzle(std::move(base), a, pos);
}
DSLExpression Swizzle(DSLExpression base,
SkSL::SwizzleComponent::Type a,
SkSL::SwizzleComponent::Type b,
PositionInfo pos) {
Position pos) {
return DSLCore::Swizzle(std::move(base), a, b, pos);
}
@ -692,7 +692,7 @@ DSLExpression Swizzle(DSLExpression base,
SkSL::SwizzleComponent::Type a,
SkSL::SwizzleComponent::Type b,
SkSL::SwizzleComponent::Type c,
PositionInfo pos) {
Position pos) {
return DSLCore::Swizzle(std::move(base), a, b, c, pos);
}
@ -701,15 +701,15 @@ DSLExpression Swizzle(DSLExpression base,
SkSL::SwizzleComponent::Type b,
SkSL::SwizzleComponent::Type c,
SkSL::SwizzleComponent::Type d,
PositionInfo pos) {
Position pos) {
return DSLCore::Swizzle(std::move(base), a, b, c, d, pos);
}
DSLExpression Tan(DSLExpression x, PositionInfo pos) {
DSLExpression Tan(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("tan", std::move(x)), pos);
}
DSLExpression Unpremul(DSLExpression x, PositionInfo pos) {
DSLExpression Unpremul(DSLExpression x, Position pos) {
return DSLExpression(DSLCore::Call("unpremul", std::move(x)), pos);
}

View File

@ -41,7 +41,7 @@ DSLExpression::DSLExpression(std::unique_ptr<SkSL::Expression> expression)
SkASSERT(this->hasValue());
}
DSLExpression::DSLExpression(float value, PositionInfo pos)
DSLExpression::DSLExpression(float value, Position pos)
: fExpression(SkSL::Literal::MakeFloat(ThreadContext::Context(),
pos.line(),
value)) {
@ -54,35 +54,35 @@ DSLExpression::DSLExpression(float value, PositionInfo pos)
}
}
DSLExpression::DSLExpression(int value, PositionInfo pos)
DSLExpression::DSLExpression(int value, Position pos)
: fExpression(SkSL::Literal::MakeInt(ThreadContext::Context(),
pos.line(),
value)) {}
DSLExpression::DSLExpression(int64_t value, PositionInfo pos)
DSLExpression::DSLExpression(int64_t value, Position pos)
: fExpression(SkSL::Literal::MakeInt(ThreadContext::Context(),
pos.line(),
value)) {}
DSLExpression::DSLExpression(unsigned int value, PositionInfo pos)
DSLExpression::DSLExpression(unsigned int value, Position pos)
: fExpression(SkSL::Literal::MakeInt(ThreadContext::Context(),
pos.line(),
value)) {}
DSLExpression::DSLExpression(bool value, PositionInfo pos)
DSLExpression::DSLExpression(bool value, Position pos)
: fExpression(SkSL::Literal::MakeBool(ThreadContext::Context(),
pos.line(),
value)) {}
DSLExpression::DSLExpression(DSLVarBase& var, PositionInfo pos) {
DSLExpression::DSLExpression(DSLVarBase& var, Position pos) {
fExpression = std::make_unique<SkSL::VariableReference>(pos.line(), DSLWriter::Var(var),
SkSL::VariableReference::RefKind::kRead);
}
DSLExpression::DSLExpression(DSLVarBase&& var, PositionInfo pos)
DSLExpression::DSLExpression(DSLVarBase&& var, Position pos)
: DSLExpression(var) {}
DSLExpression::DSLExpression(DSLPossibleExpression expr, PositionInfo pos) {
DSLExpression::DSLExpression(DSLPossibleExpression expr, Position pos) {
ThreadContext::ReportErrors(pos);
if (expr.valid()) {
fExpression = std::move(expr.fExpression);
@ -91,7 +91,7 @@ DSLExpression::DSLExpression(DSLPossibleExpression expr, PositionInfo pos) {
}
}
DSLExpression DSLExpression::Poison(PositionInfo pos) {
DSLExpression DSLExpression::Poison(Position pos) {
return DSLExpression(SkSL::Poison::Make(pos.line(), ThreadContext::Context()));
}
@ -132,39 +132,39 @@ DSLType DSLExpression::type() {
return &fExpression->type();
}
DSLExpression DSLExpression::x(PositionInfo pos) {
DSLExpression DSLExpression::x(Position pos) {
return Swizzle(std::move(*this), X, pos);
}
DSLExpression DSLExpression::y(PositionInfo pos) {
DSLExpression DSLExpression::y(Position pos) {
return Swizzle(std::move(*this), Y, pos);
}
DSLExpression DSLExpression::z(PositionInfo pos) {
DSLExpression DSLExpression::z(Position pos) {
return Swizzle(std::move(*this), Z, pos);
}
DSLExpression DSLExpression::w(PositionInfo pos) {
DSLExpression DSLExpression::w(Position pos) {
return Swizzle(std::move(*this), W, pos);
}
DSLExpression DSLExpression::r(PositionInfo pos) {
DSLExpression DSLExpression::r(Position pos) {
return Swizzle(std::move(*this), R, pos);
}
DSLExpression DSLExpression::g(PositionInfo pos) {
DSLExpression DSLExpression::g(Position pos) {
return Swizzle(std::move(*this), G, pos);
}
DSLExpression DSLExpression::b(PositionInfo pos) {
DSLExpression DSLExpression::b(Position pos) {
return Swizzle(std::move(*this), B, pos);
}
DSLExpression DSLExpression::a(PositionInfo pos) {
DSLExpression DSLExpression::a(Position pos) {
return Swizzle(std::move(*this), A, pos);
}
DSLExpression DSLExpression::field(std::string_view name, PositionInfo pos) {
DSLExpression DSLExpression::field(std::string_view name, Position pos) {
return DSLExpression(FieldAccess::Convert(ThreadContext::Context(),
*ThreadContext::SymbolTable(), this->release(), name), pos);
}
@ -180,7 +180,7 @@ DSLPossibleExpression DSLExpression::operator[](DSLExpression right) {
}
DSLPossibleExpression DSLExpression::operator()(SkTArray<DSLWrapper<DSLExpression>> args,
PositionInfo pos) {
Position pos) {
ExpressionArray converted;
converted.reserve_back(args.count());
for (DSLWrapper<DSLExpression>& arg : args) {
@ -189,7 +189,7 @@ DSLPossibleExpression DSLExpression::operator()(SkTArray<DSLWrapper<DSLExpressio
return (*this)(std::move(converted), pos);
}
DSLPossibleExpression DSLExpression::operator()(ExpressionArray args, PositionInfo pos) {
DSLPossibleExpression DSLExpression::operator()(ExpressionArray args, Position pos) {
return SkSL::FunctionCall::Convert(ThreadContext::Context(), pos.line(), this->release(),
std::move(args));
}
@ -288,7 +288,7 @@ DSLPossibleExpression::~DSLPossibleExpression() {
}
}
void DSLPossibleExpression::reportErrors(PositionInfo pos) {
void DSLPossibleExpression::reportErrors(Position pos) {
SkASSERT(!this->valid());
ThreadContext::ReportErrors(pos);
}
@ -300,39 +300,39 @@ DSLType DSLPossibleExpression::type() {
return &fExpression->type();
}
DSLExpression DSLPossibleExpression::x(PositionInfo pos) {
DSLExpression DSLPossibleExpression::x(Position pos) {
return DSLExpression(this->release()).x(pos);
}
DSLExpression DSLPossibleExpression::y(PositionInfo pos) {
DSLExpression DSLPossibleExpression::y(Position pos) {
return DSLExpression(this->release()).y(pos);
}
DSLExpression DSLPossibleExpression::z(PositionInfo pos) {
DSLExpression DSLPossibleExpression::z(Position pos) {
return DSLExpression(this->release()).z(pos);
}
DSLExpression DSLPossibleExpression::w(PositionInfo pos) {
DSLExpression DSLPossibleExpression::w(Position pos) {
return DSLExpression(this->release()).w(pos);
}
DSLExpression DSLPossibleExpression::r(PositionInfo pos) {
DSLExpression DSLPossibleExpression::r(Position pos) {
return DSLExpression(this->release()).r(pos);
}
DSLExpression DSLPossibleExpression::g(PositionInfo pos) {
DSLExpression DSLPossibleExpression::g(Position pos) {
return DSLExpression(this->release()).g(pos);
}
DSLExpression DSLPossibleExpression::b(PositionInfo pos) {
DSLExpression DSLPossibleExpression::b(Position pos) {
return DSLExpression(this->release()).b(pos);
}
DSLExpression DSLPossibleExpression::a(PositionInfo pos) {
DSLExpression DSLPossibleExpression::a(Position pos) {
return DSLExpression(this->release()).a(pos);
}
DSLExpression DSLPossibleExpression::field(std::string_view name, PositionInfo pos) {
DSLExpression DSLPossibleExpression::field(std::string_view name, Position pos) {
return DSLExpression(this->release()).field(name, pos);
}
@ -357,11 +357,11 @@ DSLPossibleExpression DSLPossibleExpression::operator[](DSLExpression index) {
}
DSLPossibleExpression DSLPossibleExpression::operator()(SkTArray<DSLWrapper<DSLExpression>> args,
PositionInfo pos) {
Position pos) {
return DSLExpression(this->release())(std::move(args), pos);
}
DSLPossibleExpression DSLPossibleExpression::operator()(ExpressionArray args, PositionInfo pos) {
DSLPossibleExpression DSLPossibleExpression::operator()(ExpressionArray args, Position pos) {
return DSLExpression(this->release())(std::move(args), pos);
}
@ -381,7 +381,7 @@ DSLPossibleExpression DSLPossibleExpression::operator--(int) {
return DSLExpression(this->release())--;
}
std::unique_ptr<SkSL::Expression> DSLPossibleExpression::release(PositionInfo pos) {
std::unique_ptr<SkSL::Expression> DSLPossibleExpression::release(Position pos) {
return DSLExpression(std::move(*this), pos).release();
}

View File

@ -22,7 +22,7 @@ namespace SkSL {
namespace dsl {
void DSLFunction::init(DSLModifiers modifiers, const DSLType& returnType, std::string_view name,
SkTArray<DSLParameter*> params, PositionInfo pos) {
SkTArray<DSLParameter*> params, Position pos) {
fPosition = pos;
// Conservatively assume all user-defined functions have side effects.
if (!ThreadContext::IsModule()) {
@ -72,7 +72,7 @@ void DSLFunction::init(DSLModifiers modifiers, const DSLType& returnType, std::s
}
}
void DSLFunction::define(DSLBlock block, PositionInfo pos) {
void DSLFunction::define(DSLBlock block, Position pos) {
std::unique_ptr<SkSL::Block> body = block.release();
if (!fDecl) {
// Evidently we failed to create the declaration; error should already have been reported.
@ -107,7 +107,7 @@ void DSLFunction::define(DSLBlock block, PositionInfo pos) {
ThreadContext::ProgramElements().push_back(std::move(function));
}
DSLExpression DSLFunction::call(SkTArray<DSLWrapper<DSLExpression>> args, PositionInfo pos) {
DSLExpression DSLFunction::call(SkTArray<DSLWrapper<DSLExpression>> args, Position pos) {
ExpressionArray released;
released.reserve_back(args.size());
for (DSLWrapper<DSLExpression>& arg : args) {
@ -116,7 +116,7 @@ DSLExpression DSLFunction::call(SkTArray<DSLWrapper<DSLExpression>> args, Positi
return this->call(std::move(released));
}
DSLExpression DSLFunction::call(ExpressionArray args, PositionInfo pos) {
DSLExpression DSLFunction::call(ExpressionArray args, Position pos) {
std::unique_ptr<SkSL::Expression> result = SkSL::FunctionCall::Convert(ThreadContext::Context(),
pos.line(), *fDecl, std::move(args));
return DSLExpression(std::move(result), pos);

View File

@ -13,7 +13,7 @@ namespace SkSL {
namespace dsl {
DSLLayout& DSLLayout::flag(SkSL::Layout::Flag mask, const char* name, PositionInfo pos) {
DSLLayout& DSLLayout::flag(SkSL::Layout::Flag mask, const char* name, Position pos) {
if (fSkSLLayout.fFlags & mask) {
ThreadContext::ReportError(
"layout qualifier '" + std::string(name) + "' appears more than once", pos);
@ -23,7 +23,7 @@ DSLLayout& DSLLayout::flag(SkSL::Layout::Flag mask, const char* name, PositionIn
}
DSLLayout& DSLLayout::intValue(int* target, int value, SkSL::Layout::Flag flag, const char* name,
PositionInfo pos) {
Position pos) {
this->flag(flag, name, pos);
*target = value;
return *this;

View File

@ -29,7 +29,7 @@ void StartRuntimeShader(SkSL::Compiler* compiler) {
sk_sp<SkRuntimeEffect> EndRuntimeShader(SkRuntimeEffect::Options options) {
std::unique_ptr<SkSL::Program> program = ReleaseProgram();
ThreadContext::ReportErrors(PositionInfo{});
ThreadContext::ReportErrors(Position{});
sk_sp<SkRuntimeEffect> result;
if (program) {
result = SkRuntimeEffect::MakeForShader(std::move(program), options, &GetErrorReporter());

View File

@ -45,10 +45,10 @@ DSLStatement::DSLStatement(std::unique_ptr<SkSL::Statement> stmt)
SkASSERT(this->hasValue());
}
DSLStatement::DSLStatement(DSLPossibleExpression expr, PositionInfo pos)
DSLStatement::DSLStatement(DSLPossibleExpression expr, Position pos)
: DSLStatement(DSLExpression(std::move(expr), pos)) {}
DSLStatement::DSLStatement(DSLPossibleStatement stmt, PositionInfo pos) {
DSLStatement::DSLStatement(DSLPossibleStatement stmt, Position pos) {
ThreadContext::ReportErrors(pos);
if (stmt.hasValue()) {
fStatement = std::move(stmt.fStatement);

View File

@ -33,7 +33,7 @@ std::shared_ptr<SymbolTable> CurrentSymbolTable() {
return ThreadContext::SymbolTable();
}
DSLPossibleExpression Symbol(std::string_view name, PositionInfo pos) {
DSLPossibleExpression Symbol(std::string_view name, Position pos) {
return ThreadContext::Compiler().convertIdentifier(pos.line(), name);
}
@ -45,7 +45,7 @@ bool IsBuiltinType(std::string_view name) {
return is_type_in_symbol_table(name, CurrentSymbolTable()->builtinParent());
}
void AddToSymbolTable(DSLVarBase& var, PositionInfo pos) {
void AddToSymbolTable(DSLVarBase& var, Position pos) {
const SkSL::Variable* skslVar = DSLWriter::Var(var);
if (skslVar) {
CurrentSymbolTable()->addWithoutOwnership(skslVar);

View File

@ -18,7 +18,7 @@ namespace dsl {
static const SkSL::Type* verify_type(const Context& context,
const SkSL::Type* type,
bool allowPrivateTypes,
PositionInfo pos) {
Position pos) {
if (!context.fConfig->fIsBuiltinCode) {
if (!allowPrivateTypes && type->isPrivate()) {
context.fErrors->error("type '" + std::string(type->name()) + "' is private", pos);
@ -35,7 +35,7 @@ static const SkSL::Type* verify_type(const Context& context,
static const SkSL::Type* find_type(const Context& context,
std::string_view name,
PositionInfo pos) {
Position pos) {
const Symbol* symbol = (*ThreadContext::SymbolTable())[name];
if (!symbol) {
context.fErrors->error(String::printf("no symbol named '%.*s'",
@ -54,7 +54,7 @@ static const SkSL::Type* find_type(const Context& context,
static const SkSL::Type* find_type(const Context& context,
std::string_view name,
Modifiers* modifiers,
PositionInfo pos) {
Position pos) {
const Type* type = find_type(context, name, pos);
type = type->applyPrecisionQualifiers(context, modifiers, ThreadContext::SymbolTable().get(),
pos.line());
@ -168,14 +168,14 @@ static const SkSL::Type* get_type_from_type_constant(const Context& context, Typ
}
DSLType::DSLType(std::string_view name)
: fSkSLType(find_type(ThreadContext::Context(), name, PositionInfo())) {}
: fSkSLType(find_type(ThreadContext::Context(), name, Position())) {}
DSLType::DSLType(std::string_view name, DSLModifiers* modifiers, PositionInfo position)
: fSkSLType(find_type(ThreadContext::Context(), name, &modifiers->fModifiers, position)) {}
DSLType::DSLType(std::string_view name, DSLModifiers* modifiers, Position pos)
: fSkSLType(find_type(ThreadContext::Context(), name, &modifiers->fModifiers, pos)) {}
DSLType::DSLType(const SkSL::Type* type)
: fSkSLType(verify_type(ThreadContext::Context(), type, /*allowPrivateTypes=*/true,
PositionInfo())) {}
Position())) {}
bool DSLType::isBoolean() const {
return this->skslType().isBoolean();
@ -233,7 +233,7 @@ const SkSL::Type& DSLType::skslType() const {
return *verify_type(context,
get_type_from_type_constant(context, fTypeConstant),
/*allowPrivateTypes=*/true,
PositionInfo());
Position());
}
DSLPossibleExpression DSLType::Construct(DSLType type, SkSpan<DSLExpression> argArray) {
@ -250,7 +250,7 @@ DSLPossibleExpression DSLType::Construct(DSLType type, SkSpan<DSLExpression> arg
std::move(skslArgs));
}
DSLType Array(const DSLType& base, int count, PositionInfo pos) {
DSLType Array(const DSLType& base, int count, Position pos) {
count = base.skslType().convertArraySize(ThreadContext::Context(),
DSLExpression(count, pos).release());
ThreadContext::ReportErrors(pos);
@ -260,7 +260,7 @@ DSLType Array(const DSLType& base, int count, PositionInfo pos) {
return ThreadContext::SymbolTable()->addArrayDimension(&base.skslType(), count);
}
DSLType Struct(std::string_view name, SkSpan<DSLField> fields, PositionInfo pos) {
DSLType Struct(std::string_view name, SkSpan<DSLField> fields, Position pos) {
std::vector<SkSL::Type::Field> skslFields;
skslFields.reserve(fields.size());
for (const DSLField& field : fields) {

View File

@ -24,18 +24,18 @@ namespace SkSL {
namespace dsl {
DSLVarBase::DSLVarBase(DSLType type, std::string_view name, DSLExpression initialValue,
PositionInfo pos)
Position pos)
: DSLVarBase(DSLModifiers(), std::move(type), name, std::move(initialValue), pos) {}
DSLVarBase::DSLVarBase(DSLType type, DSLExpression initialValue, PositionInfo pos)
DSLVarBase::DSLVarBase(DSLType type, DSLExpression initialValue, Position pos)
: DSLVarBase(type, "var", std::move(initialValue), pos) {}
DSLVarBase::DSLVarBase(const DSLModifiers& modifiers, DSLType type, DSLExpression initialValue,
PositionInfo pos)
Position pos)
: DSLVarBase(modifiers, type, "var", std::move(initialValue), pos) {}
DSLVarBase::DSLVarBase(const DSLModifiers& modifiers, DSLType type, std::string_view name,
DSLExpression initialValue, PositionInfo pos)
DSLExpression initialValue, Position pos)
: fModifiers(std::move(modifiers))
, fType(std::move(type))
, fRawName(name)
@ -103,7 +103,7 @@ VariableStorage DSLVar::storage() const {
}
DSLGlobalVar::DSLGlobalVar(const char* name)
: INHERITED(kVoid_Type, name, DSLExpression(), PositionInfo()) {
: INHERITED(kVoid_Type, name, DSLExpression(), Position()) {
fName = name;
DSLWriter::MarkDeclared(*this);
#if SK_SUPPORT_GPU && !defined(SKSL_STANDALONE)
@ -155,12 +155,12 @@ VariableStorage DSLParameter::storage() const {
DSLPossibleExpression DSLVarBase::operator[](DSLExpression&& index) {
return DSLExpression(*this, PositionInfo())[std::move(index)];
return DSLExpression(*this, Position())[std::move(index)];
}
DSLPossibleExpression DSLVarBase::assign(DSLExpression expr) {
return BinaryExpression::Convert(ThreadContext::Context(),
DSLExpression(*this, PositionInfo()).release(), SkSL::Token::Kind::TK_EQ,
DSLExpression(*this, Position()).release(), SkSL::Token::Kind::TK_EQ,
expr.release());
}
@ -177,16 +177,16 @@ DSLPossibleExpression DSLParameter::operator=(DSLExpression expr) {
}
std::unique_ptr<SkSL::Expression> DSLGlobalVar::methodCall(std::string_view methodName,
PositionInfo pos) {
Position pos) {
if (!this->fType.isEffectChild()) {
ThreadContext::ReportError("type does not support method calls", pos);
return nullptr;
}
return FieldAccess::Convert(ThreadContext::Context(), *ThreadContext::SymbolTable(),
DSLExpression(*this, PositionInfo()).release(), methodName);
DSLExpression(*this, Position()).release(), methodName);
}
DSLExpression DSLGlobalVar::eval(ExpressionArray args, PositionInfo pos) {
DSLExpression DSLGlobalVar::eval(ExpressionArray args, Position pos) {
auto method = this->methodCall("eval", pos);
return DSLExpression(
method ? SkSL::FunctionCall::Convert(ThreadContext::Context(), pos.line(),
@ -195,13 +195,13 @@ DSLExpression DSLGlobalVar::eval(ExpressionArray args, PositionInfo pos) {
pos);
}
DSLExpression DSLGlobalVar::eval(DSLExpression x, PositionInfo pos) {
DSLExpression DSLGlobalVar::eval(DSLExpression x, Position pos) {
ExpressionArray converted;
converted.push_back(x.release());
return this->eval(std::move(converted), pos);
}
DSLExpression DSLGlobalVar::eval(DSLExpression x, DSLExpression y, PositionInfo pos) {
DSLExpression DSLGlobalVar::eval(DSLExpression x, DSLExpression y, Position pos) {
ExpressionArray converted;
converted.push_back(x.release());
converted.push_back(y.release());

View File

@ -202,7 +202,7 @@ static void test_RuntimeEffect_Shaders(skiatest::Reporter* r, GrRecordingContext
{
class SimpleErrorReporter : public SkSL::ErrorReporter {
public:
void handleError(std::string_view msg, SkSL::PositionInfo pos) override {
void handleError(std::string_view msg, SkSL::Position pos) override {
fMsg += msg;
}

View File

@ -36,7 +36,7 @@ public:
SetErrorReporter(fOldReporter);
}
void handleError(std::string_view msg, SkSL::PositionInfo pos) override {
void handleError(std::string_view msg, SkSL::Position pos) override {
REPORTER_ASSERT(fReporter, msg == fMsg,
"Error mismatch: expected:\n%sbut received:\n%.*s", fMsg, (int)msg.length(),
msg.data());

View File

@ -69,7 +69,7 @@ public:
SetErrorReporter(fOldReporter);
}
void handleError(std::string_view msg, SkSL::PositionInfo pos) override {
void handleError(std::string_view msg, SkSL::Position pos) override {
REPORTER_ASSERT(fReporter, fMsg, "Received unexpected extra error: %.*s\n",
(int)msg.length(), msg.data());
REPORTER_ASSERT(fReporter, !fMsg || msg == fMsg,