Reland "Renamed SkSL "offset" to "line""
This reverts commit cc91452f0a65f261283615db9ed3d37b1c3acd15.
Change-Id: I7eff0ddeebef4ce298893f9b3ba410b09647e9a4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/453138
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/include/private/SkSLIRNode.h b/include/private/SkSLIRNode.h
index 8539bd8..450c549 100644
--- a/include/private/SkSLIRNode.h
+++ b/include/private/SkSLIRNode.h
@@ -48,13 +48,12 @@
IRNode(const IRNode&) = delete;
IRNode& operator=(const IRNode&) = delete;
- // character offset of this element within the program being compiled, for error reporting
- // purposes
- int fOffset;
+ // line of this element within the program being compiled, for error reporting purposes
+ int fLine;
protected:
- IRNode(int offset, int kind)
- : fOffset(offset)
+ IRNode(int line, int kind)
+ : fLine(line)
, fKind(kind) {}
int fKind;
diff --git a/include/private/SkSLStatement.h b/include/private/SkSLStatement.h
index dab0d0e..8913369 100644
--- a/include/private/SkSLStatement.h
+++ b/include/private/SkSLStatement.h
@@ -38,8 +38,8 @@
kLast = kVarDeclaration,
};
- Statement(int offset, Kind kind)
- : INHERITED(offset, (int) kind) {
+ Statement(int line, Kind kind)
+ : INHERITED(line, (int) kind) {
SkASSERT(kind >= Kind::kFirst && kind <= Kind::kLast);
}
diff --git a/include/sksl/SkSLErrorReporter.h b/include/sksl/SkSLErrorReporter.h
index af949c3..79a7650 100644
--- a/include/sksl/SkSLErrorReporter.h
+++ b/include/sksl/SkSLErrorReporter.h
@@ -43,11 +43,6 @@
return fLine;
}
- // Temporary method until we finish replacing offset with line
- int offset() {
- return fLine;
- }
-
private:
const char* fFile = nullptr;
int32_t fLine = -1;
@@ -67,10 +62,10 @@
void error(skstd::string_view msg, PositionInfo position);
/**
- * Reports an error message at the given character offset of the source text. Errors reported
- * with an offset of -1 will be queued until line number information can be determined.
+ * Reports an error message at the given line of the source text. Errors reported
+ * with a line of -1 will be queued until line number information can be determined.
*/
- void error(int offset, skstd::string_view msg);
+ void error(int line, skstd::string_view msg);
const char* source() const { return fSource; }
diff --git a/src/sksl/SkSLASTNode.h b/src/sksl/SkSLASTNode.h
index 38f7c15..153fe77 100644
--- a/src/sksl/SkSLASTNode.h
+++ b/src/sksl/SkSLASTNode.h
@@ -311,12 +311,12 @@
};
ASTNode()
- : fOffset(-1)
+ : fLine(-1)
, fKind(Kind::kNull) {}
- ASTNode(std::vector<ASTNode>* nodes, int offset, Kind kind)
+ ASTNode(std::vector<ASTNode>* nodes, int line, Kind kind)
: fNodes(nodes)
- , fOffset(offset)
+ , fLine(line)
, fKind(kind) {
switch (kind) {
@@ -372,46 +372,46 @@
}
}
- ASTNode(std::vector<ASTNode>* nodes, int offset, Kind kind, Operator op)
+ ASTNode(std::vector<ASTNode>* nodes, int line, Kind kind, Operator op)
: fNodes(nodes)
, fData(op)
- , fOffset(offset)
+ , fLine(line)
, fKind(kind) {}
- ASTNode(std::vector<ASTNode>* nodes, int offset, Kind kind, skstd::string_view s)
+ ASTNode(std::vector<ASTNode>* nodes, int line, Kind kind, skstd::string_view s)
: fNodes(nodes)
, fData(s)
- , fOffset(offset)
+ , fLine(line)
, fKind(kind) {}
- ASTNode(std::vector<ASTNode>* nodes, int offset, Kind kind, const char* s)
+ ASTNode(std::vector<ASTNode>* nodes, int line, Kind kind, const char* s)
: fNodes(nodes)
, fData(skstd::string_view(s))
- , fOffset(offset)
+ , fLine(line)
, fKind(kind) {}
- ASTNode(std::vector<ASTNode>* nodes, int offset, Kind kind, bool b)
+ ASTNode(std::vector<ASTNode>* nodes, int line, Kind kind, bool b)
: fNodes(nodes)
, fData(b)
- , fOffset(offset)
+ , fLine(line)
, fKind(kind) {}
- ASTNode(std::vector<ASTNode>* nodes, int offset, Kind kind, SKSL_INT i)
+ ASTNode(std::vector<ASTNode>* nodes, int line, Kind kind, SKSL_INT i)
: fNodes(nodes)
, fData(i)
- , fOffset(offset)
+ , fLine(line)
, fKind(kind) {}
- ASTNode(std::vector<ASTNode>* nodes, int offset, Kind kind, SKSL_FLOAT f)
+ ASTNode(std::vector<ASTNode>* nodes, int line, Kind kind, SKSL_FLOAT f)
: fNodes(nodes)
, fData(f)
- , fOffset(offset)
+ , fLine(line)
, fKind(kind) {}
- ASTNode(std::vector<ASTNode>* nodes, int offset, Kind kind, Modifiers m)
+ ASTNode(std::vector<ASTNode>* nodes, int line, Kind kind, Modifiers m)
: fNodes(nodes)
, fData(m)
- , fOffset(offset)
+ , fLine(line)
, fKind(kind) {}
operator bool() const {
@@ -512,7 +512,7 @@
NodeData fData;
- int fOffset;
+ int fLine;
Kind fKind;
diff --git a/src/sksl/SkSLAnalysis.cpp b/src/sksl/SkSLAnalysis.cpp
index 8a7d5d7..6a98b64 100644
--- a/src/sksl/SkSLAnalysis.cpp
+++ b/src/sksl/SkSLAnalysis.cpp
@@ -317,7 +317,7 @@
VariableReference& varRef = expr.as<VariableReference>();
const Variable* var = varRef.variable();
if (var->modifiers().fFlags & (Modifiers::kConst_Flag | Modifiers::kUniform_Flag)) {
- fErrors->error(expr.fOffset,
+ fErrors->error(expr.fLine,
"cannot modify immutable variable '" + var->name() + "'");
} else {
SkASSERT(fAssignedVar == nullptr);
@@ -343,7 +343,7 @@
break;
default:
- fErrors->error(expr.fOffset, "cannot assign to this expression");
+ fErrors->error(expr.fLine, "cannot assign to this expression");
break;
}
}
@@ -355,7 +355,7 @@
SkASSERT(idx >= SwizzleComponent::X && idx <= SwizzleComponent::W);
int bit = 1 << idx;
if (bits & bit) {
- fErrors->error(swizzle.fOffset,
+ fErrors->error(swizzle.fLine,
"cannot write to the same swizzle field more than once");
break;
}
@@ -652,7 +652,7 @@
}
}
msg = "potential recursion (function call cycle) not allowed:" + msg;
- fContext.fErrors->error(pe.fOffset, std::move(msg));
+ fContext.fErrors->error(pe.fLine, std::move(msg));
fFunctionSize = iter->second = 0;
return true;
}
@@ -668,7 +668,7 @@
msg += "\n\t" + (*unwind)->description();
}
msg += "\n\t" + decl->description();
- fContext.fErrors->error(pe.fOffset, std::move(msg));
+ fContext.fErrors->error(pe.fLine, std::move(msg));
fFunctionSize = iter->second = 0;
return true;
}
@@ -780,7 +780,7 @@
// Report an error when main()'s flattened size is larger than our program limit.
if (visitor.functionSize() > kProgramSizeLimit &&
element->as<FunctionDefinition>().declaration().isMain()) {
- context.fErrors->error(/*offset=*/-1, "program is too large");
+ context.fErrors->error(/*line=*/-1, "program is too large");
}
}
}
@@ -815,7 +815,7 @@
// Report an error.
SkASSERT(var);
if (errors) {
- errors->error(stmt.fOffset, "variable '" + var->name() + "' must be created in a scope");
+ errors->error(stmt.fLine, "variable '" + var->name() + "' must be created in a scope");
}
return true;
}
@@ -919,8 +919,7 @@
}
if (!info.fAssignedVar) {
if (errors) {
- errors->error(expr->fOffset, "can't assign to expression '" +
- expr->description() + "'");
+ errors->error(expr->fLine, "can't assign to expression '" + expr->description() + "'");
}
return false;
}
@@ -1008,7 +1007,7 @@
}
}
-static const char* invalid_for_ES2(int offset,
+static const char* invalid_for_ES2(int line,
const Statement* loopInitializer,
const Expression* loopTest,
const Expression* loopNext,
@@ -1222,18 +1221,18 @@
return nullptr; // All checks pass
}
-std::unique_ptr<LoopUnrollInfo> Analysis::GetLoopUnrollInfo(int offset,
+std::unique_ptr<LoopUnrollInfo> Analysis::GetLoopUnrollInfo(int line,
const Statement* loopInitializer,
const Expression* loopTest,
const Expression* loopNext,
const Statement* loopStatement,
ErrorReporter* errors) {
auto result = std::make_unique<LoopUnrollInfo>();
- if (const char* msg = invalid_for_ES2(offset, loopInitializer, loopTest, loopNext,
+ if (const char* msg = invalid_for_ES2(line, loopInitializer, loopTest, loopNext,
loopStatement, *result)) {
result = nullptr;
if (errors) {
- errors->error(offset, msg);
+ errors->error(line, msg);
}
}
return result;
@@ -1340,7 +1339,7 @@
const IndexExpression& i = e.as<IndexExpression>();
ConstantExpressionVisitor indexerInvalid(&fLoopIndices);
if (indexerInvalid.visitExpression(*i.index())) {
- fErrors.error(i.fOffset, "index expression must be constant");
+ fErrors.error(i.fLine, "index expression must be constant");
return true;
}
}
@@ -1388,13 +1387,13 @@
switch (stmt.kind()) {
case Statement::Kind::kIf:
if (stmt.as<IfStatement>().isStatic()) {
- fContext.fErrors->error(stmt.fOffset, "static if has non-static test");
+ fContext.fErrors->error(stmt.fLine, "static if has non-static test");
}
break;
case Statement::Kind::kSwitch:
if (stmt.as<SwitchStatement>().isStatic()) {
- fContext.fErrors->error(stmt.fOffset,
+ fContext.fErrors->error(stmt.fLine,
"static switch has non-static test");
}
break;
@@ -1411,8 +1410,8 @@
case Expression::Kind::kFunctionCall: {
const FunctionDeclaration& decl = expr.as<FunctionCall>().function();
if (!decl.isBuiltin() && !decl.definition()) {
- fContext.fErrors->error(expr.fOffset, "function '" + decl.description() +
- "' is not defined");
+ fContext.fErrors->error(expr.fLine, "function '" + decl.description() +
+ "' is not defined");
}
break;
}
@@ -1421,11 +1420,11 @@
case Expression::Kind::kMethodReference:
case Expression::Kind::kTypeReference:
SkDEBUGFAIL("invalid reference-expr, should have been reported by coerce()");
- fContext.fErrors->error(expr.fOffset, "invalid expression");
+ fContext.fErrors->error(expr.fLine, "invalid expression");
break;
default:
if (expr.type() == *fContext.fTypes.fInvalid) {
- fContext.fErrors->error(expr.fOffset, "invalid expression");
+ fContext.fErrors->error(expr.fLine, "invalid expression");
}
break;
}
diff --git a/src/sksl/SkSLAnalysis.h b/src/sksl/SkSLAnalysis.h
index d3c3f3b..d367034 100644
--- a/src/sksl/SkSLAnalysis.h
+++ b/src/sksl/SkSLAnalysis.h
@@ -157,7 +157,7 @@
* If the requirements are not met, the problem is reported via `errors` (if not nullptr), and
* null is returned.
*/
- static std::unique_ptr<LoopUnrollInfo> GetLoopUnrollInfo(int offset,
+ static std::unique_ptr<LoopUnrollInfo> GetLoopUnrollInfo(int line,
const Statement* loopInitializer,
const Expression* loopTest,
const Expression* loopNext,
diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp
index c0486d0..676e3f2 100644
--- a/src/sksl/SkSLCompiler.cpp
+++ b/src/sksl/SkSLCompiler.cpp
@@ -203,7 +203,7 @@
// sk_Caps is "builtin", but all references to it are resolved to Settings, so we don't need to
// treat it as builtin (ie, no need to clone it into the Program).
- privateSymbolTable->add(std::make_unique<Variable>(/*offset=*/-1,
+ privateSymbolTable->add(std::make_unique<Variable>(/*line=*/-1,
fCoreModifiers.add(Modifiers{}),
"sk_Caps",
fContext->fTypes.fSkCaps.get(),
diff --git a/src/sksl/SkSLConstantFolder.cpp b/src/sksl/SkSLConstantFolder.cpp
index c540cd1..e50d093 100644
--- a/src/sksl/SkSLConstantFolder.cpp
+++ b/src/sksl/SkSLConstantFolder.cpp
@@ -72,7 +72,7 @@
[[fallthrough]];
case Expression::ComparisonResult::kEqual:
- return Literal::MakeBool(context, left.fOffset, equality);
+ return Literal::MakeBool(context, left.fLine, equality);
case Expression::ComparisonResult::kUnknown:
break;
@@ -112,9 +112,9 @@
for (int i = 0; i < type.columns(); i++) {
double value = foldFn(left.getConstantSubexpression(i)->as<Literal>().value(),
right.getConstantSubexpression(i)->as<Literal>().value());
- args.push_back(Literal::Make(left.fOffset, value, &componentType));
+ args.push_back(Literal::Make(left.fLine, value, &componentType));
}
- return ConstructorCompound::Make(context, left.fOffset, type, std::move(args));
+ return ConstructorCompound::Make(context, left.fLine, type, std::move(args));
}
static std::unique_ptr<Expression> cast_expression(const Context& context,
@@ -122,7 +122,7 @@
const Type& type) {
ExpressionArray ctorArgs;
ctorArgs.push_back(expr.clone());
- std::unique_ptr<Expression> ctor = Constructor::Convert(context, expr.fOffset, type,
+ std::unique_ptr<Expression> ctor = Constructor::Convert(context, expr.fLine, type,
std::move(ctorArgs));
SkASSERT(ctor);
return ctor;
@@ -133,7 +133,7 @@
SkASSERT(type.componentType() == scalar.type());
// Use a constructor to splat the scalar expression across a vector.
- return ConstructorSplat{scalar.fOffset, type, scalar.clone()};
+ return ConstructorSplat{scalar.fLine, type, scalar.clone()};
}
bool ConstantFolder::GetConstantInt(const Expression& value, SKSL_INT* out) {
@@ -181,7 +181,7 @@
return true;
}
-bool ConstantFolder::ErrorOnDivideByZero(const Context& context, int offset, Operator op,
+bool ConstantFolder::ErrorOnDivideByZero(const Context& context, int line, Operator op,
const Expression& right) {
switch (op.kind()) {
case Token::Kind::TK_SLASH:
@@ -189,7 +189,7 @@
case Token::Kind::TK_PERCENT:
case Token::Kind::TK_PERCENTEQ:
if (contains_constant_zero(right)) {
- context.fErrors->error(offset, "division by zero");
+ context.fErrors->error(line, "division by zero");
return true;
}
return false;
@@ -305,7 +305,7 @@
}
template <typename T>
-static std::unique_ptr<Expression> fold_float_expression(int offset,
+static std::unique_ptr<Expression> fold_float_expression(int line,
T result,
const Type* resultType) {
// If constant-folding this expression would generate a NaN/infinite result, leave it as-is.
@@ -315,11 +315,11 @@
}
}
- return Literal::Make(offset, result, resultType);
+ return Literal::Make(line, result, resultType);
}
template <typename T>
-static std::unique_ptr<Expression> fold_int_expression(int offset,
+static std::unique_ptr<Expression> fold_int_expression(int line,
T result,
const Type* resultType) {
// If constant-folding this expression would overflow the result type, leave it as-is.
@@ -329,11 +329,11 @@
}
}
- return Literal::Make(offset, result, resultType);
+ return Literal::Make(line, result, resultType);
}
std::unique_ptr<Expression> ConstantFolder::Simplify(const Context& context,
- int offset,
+ int line,
const Expression& leftExpr,
Operator op,
const Expression& rightExpr,
@@ -375,7 +375,7 @@
case Token::Kind::TK_NEQ: result = leftVal != rightVal; break;
default: return nullptr;
}
- return Literal::MakeBool(context, offset, result);
+ return Literal::MakeBool(context, line, result);
}
// If the left side is a Boolean literal, apply short-circuit optimizations.
@@ -398,16 +398,16 @@
if (op.kind() == Token::Kind::TK_EQEQ && Analysis::IsSameExpressionTree(*left, *right)) {
// With == comparison, if both sides are the same trivial expression, this is self-
// comparison and is always true. (We are not concerned with NaN.)
- return Literal::MakeBool(context, leftExpr.fOffset, /*value=*/true);
+ return Literal::MakeBool(context, leftExpr.fLine, /*value=*/true);
}
if (op.kind() == Token::Kind::TK_NEQ && Analysis::IsSameExpressionTree(*left, *right)) {
// With != comparison, if both sides are the same trivial expression, this is self-
// comparison and is always false. (We are not concerned with NaN.)
- return Literal::MakeBool(context, leftExpr.fOffset, /*value=*/false);
+ return Literal::MakeBool(context, leftExpr.fLine, /*value=*/false);
}
- if (ErrorOnDivideByZero(context, offset, op, *right)) {
+ if (ErrorOnDivideByZero(context, line, op, *right)) {
return nullptr;
}
@@ -436,9 +436,9 @@
SKSL_INT leftVal = left->as<Literal>().intValue();
SKSL_INT rightVal = right->as<Literal>().intValue();
- #define RESULT(Op) fold_int_expression(offset, \
+ #define RESULT(Op) fold_int_expression(line, \
(SKSL_INT)(leftVal) Op (SKSL_INT)(rightVal), &resultType)
- #define URESULT(Op) fold_int_expression(offset, \
+ #define URESULT(Op) fold_int_expression(line, \
(SKSL_INT)((SKSL_UINT)(leftVal) Op (SKSL_UINT)(rightVal)), &resultType)
switch (op.kind()) {
case Token::Kind::TK_PLUS: return URESULT(+);
@@ -446,13 +446,13 @@
case Token::Kind::TK_STAR: return URESULT(*);
case Token::Kind::TK_SLASH:
if (leftVal == std::numeric_limits<SKSL_INT>::min() && rightVal == -1) {
- context.fErrors->error(offset, "arithmetic overflow");
+ context.fErrors->error(line, "arithmetic overflow");
return nullptr;
}
return RESULT(/);
case Token::Kind::TK_PERCENT:
if (leftVal == std::numeric_limits<SKSL_INT>::min() && rightVal == -1) {
- context.fErrors->error(offset, "arithmetic overflow");
+ context.fErrors->error(line, "arithmetic overflow");
return nullptr;
}
return RESULT(%);
@@ -471,13 +471,13 @@
// in C++, but not GLSL. Do the shift on unsigned values, to avoid UBSAN.
return URESULT(<<);
}
- context.fErrors->error(offset, "shift value out of range");
+ context.fErrors->error(line, "shift value out of range");
return nullptr;
case Token::Kind::TK_SHR:
if (rightVal >= 0 && rightVal <= 31) {
return RESULT(>>);
}
- context.fErrors->error(offset, "shift value out of range");
+ context.fErrors->error(line, "shift value out of range");
return nullptr;
default:
@@ -492,7 +492,7 @@
SKSL_FLOAT leftVal = left->as<Literal>().floatValue();
SKSL_FLOAT rightVal = right->as<Literal>().floatValue();
- #define RESULT(Op) fold_float_expression(offset, leftVal Op rightVal, &resultType)
+ #define RESULT(Op) fold_float_expression(line, leftVal Op rightVal, &resultType)
switch (op.kind()) {
case Token::Kind::TK_PLUS: return RESULT(+);
case Token::Kind::TK_MINUS: return RESULT(-);
@@ -574,7 +574,7 @@
[[fallthrough]];
case Expression::ComparisonResult::kEqual:
- return Literal::MakeBool(context, offset, equality);
+ return Literal::MakeBool(context, line, equality);
case Expression::ComparisonResult::kUnknown:
return nullptr;
diff --git a/src/sksl/SkSLConstantFolder.h b/src/sksl/SkSLConstantFolder.h
index 0b50a25..6692dd2 100644
--- a/src/sksl/SkSLConstantFolder.h
+++ b/src/sksl/SkSLConstantFolder.h
@@ -53,12 +53,12 @@
* Reports an error and returns true if op is a division / mod operator and right is zero or
* contains a zero element.
*/
- static bool ErrorOnDivideByZero(const Context& context, int offset, Operator op,
+ static bool ErrorOnDivideByZero(const Context& context, int line, Operator op,
const Expression& right);
/** Simplifies the binary expression `left OP right`. Returns null if it can't be simplified. */
static std::unique_ptr<Expression> Simplify(const Context& context,
- int offset,
+ int line,
const Expression& left,
Operator op,
const Expression& right,
diff --git a/src/sksl/SkSLDSLParser.cpp b/src/sksl/SkSLDSLParser.cpp
index 8b283e9..6ae114f 100644
--- a/src/sksl/SkSLDSLParser.cpp
+++ b/src/sksl/SkSLDSLParser.cpp
@@ -196,16 +196,16 @@
return this->position(t.fLine);
}
-PositionInfo DSLParser::position(int offset) {
- return PositionInfo("<unknown>", offset);
+PositionInfo DSLParser::position(int line) {
+ return PositionInfo("<unknown>", line);
}
void DSLParser::error(Token token, String msg) {
this->error(token.fLine, msg);
}
-void DSLParser::error(int offset, String msg) {
- GetErrorReporter().error(msg.c_str(), this->position(offset));
+void DSLParser::error(int line, String msg) {
+ GetErrorReporter().error(msg.c_str(), this->position(line));
}
/* declaration* END_OF_FILE */
@@ -413,12 +413,12 @@
}
}
-bool DSLParser::parseArrayDimensions(int offset, DSLType* type) {
+bool DSLParser::parseArrayDimensions(int line, DSLType* type) {
while (this->checkNext(Token::Kind::TK_LBRACKET)) {
if (this->checkNext(Token::Kind::TK_RBRACKET)) {
- this->error(offset, "expected array dimension");
+ this->error(line, "expected array dimension");
} else {
- *type = Array(*type, this->arraySize(), this->position(offset));
+ *type = Array(*type, this->arraySize(), this->position(line));
if (!this->expect(Token::Kind::TK_RBRACKET, "']'")) {
return false;
}
@@ -427,7 +427,7 @@
return true;
}
-bool DSLParser::parseInitializer(int offset, DSLExpression* initializer) {
+bool DSLParser::parseInitializer(int line, DSLExpression* initializer) {
if (this->checkNext(Token::Kind::TK_EQ)) {
DSLExpression value = this->assignmentExpression();
if (!value.hasValue()) {
@@ -1583,17 +1583,17 @@
}
}
-DSLExpression DSLParser::swizzle(int offset, DSLExpression base,
+DSLExpression DSLParser::swizzle(int line, DSLExpression base,
skstd::string_view swizzleMask) {
SkASSERT(swizzleMask.length() > 0);
if (!base.type().isVector() && !base.type().isScalar()) {
- return base.field(swizzleMask, this->position(offset));
+ return base.field(swizzleMask, this->position(line));
}
int length = swizzleMask.length();
SkSL::SwizzleComponent::Type components[4];
for (int i = 0; i < length; ++i) {
if (i >= 4) {
- this->error(offset, "too many components in swizzle mask");
+ this->error(line, "too many components in swizzle mask");
return DSLExpression::Poison();
}
switch (swizzleMask[i]) {
@@ -1616,7 +1616,7 @@
case 'q': components[i] = SwizzleComponent::Q; break;
case 'B': components[i] = SwizzleComponent::UB; break;
default:
- this->error(offset,
+ this->error(line,
String::printf("invalid swizzle component '%c'", swizzleMask[i]).c_str());
return DSLExpression::Poison();
}
@@ -1631,8 +1631,8 @@
}
}
-dsl::DSLExpression DSLParser::call(int offset, dsl::DSLExpression base, ExpressionArray args) {
- return DSLExpression(base(std::move(args), this->position(offset)), this->position(offset));
+dsl::DSLExpression DSLParser::call(int line, dsl::DSLExpression base, ExpressionArray args) {
+ return DSLExpression(base(std::move(args), this->position(line)), this->position(line));
}
/* LBRACKET expression? RBRACKET | DOT IDENTIFIER | LPAREN arguments RPAREN |
diff --git a/src/sksl/SkSLDSLParser.h b/src/sksl/SkSLDSLParser.h
index aed2a19..2e254ec 100644
--- a/src/sksl/SkSLDSLParser.h
+++ b/src/sksl/SkSLDSLParser.h
@@ -73,7 +73,7 @@
PositionInfo position(Token token);
- PositionInfo position(int offset);
+ PositionInfo position(int line);
private:
static void InitLayoutMap();
@@ -127,7 +127,7 @@
bool expectIdentifier(Token* result);
void error(Token token, String msg);
- void error(int offset, String msg);
+ void error(int line, String msg);
SymbolTable& symbols() {
return *dsl::CurrentSymbolTable();
@@ -168,9 +168,9 @@
SkTArray<dsl::DSLGlobalVar> structVarDeclaration(const dsl::DSLModifiers& modifiers);
- bool parseArrayDimensions(int offset, dsl::DSLType* type);
+ bool parseArrayDimensions(int line, dsl::DSLType* type);
- bool parseInitializer(int offset, dsl::DSLExpression* initializer);
+ bool parseInitializer(int line, dsl::DSLExpression* initializer);
void globalVarDeclarationEnd(PositionInfo position, const dsl::DSLModifiers& mods,
dsl::DSLType baseType, skstd::string_view name);
@@ -252,9 +252,9 @@
dsl::DSLExpression postfixExpression();
- dsl::DSLExpression swizzle(int offset, dsl::DSLExpression base, skstd::string_view swizzleMask);
+ dsl::DSLExpression swizzle(int line, dsl::DSLExpression base, skstd::string_view swizzleMask);
- dsl::DSLExpression call(int offset, dsl::DSLExpression base, ExpressionArray args);
+ dsl::DSLExpression call(int line, dsl::DSLExpression base, ExpressionArray args);
dsl::DSLExpression suffix(dsl::DSLExpression base);
diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp
index 56153fb..cb48d6a 100644
--- a/src/sksl/SkSLIRGenerator.cpp
+++ b/src/sksl/SkSLIRGenerator.cpp
@@ -65,14 +65,14 @@
IRGenerator::IRGenerator(const Context* context)
: fContext(*context) {}
-std::unique_ptr<Extension> IRGenerator::convertExtension(int offset, skstd::string_view name) {
+std::unique_ptr<Extension> IRGenerator::convertExtension(int line, skstd::string_view name) {
if (this->programKind() != ProgramKind::kFragment &&
this->programKind() != ProgramKind::kVertex) {
- this->errorReporter().error(offset, "extensions are not allowed in this kind of program");
+ this->errorReporter().error(line, "extensions are not allowed in this kind of program");
return nullptr;
}
- return std::make_unique<Extension>(offset, name);
+ return std::make_unique<Extension>(line, name);
}
std::unique_ptr<Statement> IRGenerator::convertStatement(const ASTNode& statement) {
@@ -118,7 +118,7 @@
statements.push_back(std::move(statement));
}
}
- return Block::Make(block.fOffset, std::move(statements), fSymbolTable);
+ return Block::Make(block.fLine, std::move(statements), fSymbolTable);
}
std::unique_ptr<Statement> IRGenerator::convertVarDeclarationStatement(const ASTNode& s) {
@@ -127,12 +127,12 @@
if (decls.empty()) {
return nullptr;
}
- return Block::MakeUnscoped(s.fOffset, std::move(decls));
+ return Block::MakeUnscoped(s.fLine, std::move(decls));
}
-int IRGenerator::convertArraySize(const Type& type, int offset, const ASTNode& s) {
+int IRGenerator::convertArraySize(const Type& type, int line, const ASTNode& s) {
if (!s) {
- this->errorReporter().error(offset, "array must have a size");
+ this->errorReporter().error(line, "array must have a size");
return 0;
}
auto size = this->convertExpression(s);
@@ -142,39 +142,39 @@
return type.convertArraySize(fContext, std::move(size));
}
-void IRGenerator::checkVarDeclaration(int offset, const Modifiers& modifiers, const Type* baseType,
+void IRGenerator::checkVarDeclaration(int line, const Modifiers& modifiers, const Type* baseType,
Variable::Storage storage) {
if (this->strictES2Mode() && baseType->isArray()) {
- this->errorReporter().error(offset, "array size must appear after variable name");
+ this->errorReporter().error(line, "array size must appear after variable name");
}
if (baseType->componentType().isOpaque() && storage != Variable::Storage::kGlobal) {
this->errorReporter().error(
- offset,
+ line,
"variables of type '" + baseType->displayName() + "' must be global");
}
if ((modifiers.fFlags & Modifiers::kIn_Flag) && baseType->isMatrix()) {
- this->errorReporter().error(offset, "'in' variables may not have matrix type");
+ this->errorReporter().error(line, "'in' variables may not have matrix type");
}
if ((modifiers.fFlags & Modifiers::kIn_Flag) && (modifiers.fFlags & Modifiers::kUniform_Flag)) {
- this->errorReporter().error(offset, "'in uniform' variables not permitted");
+ this->errorReporter().error(line, "'in uniform' variables not permitted");
}
if (this->isRuntimeEffect()) {
if (modifiers.fFlags & Modifiers::kIn_Flag) {
- this->errorReporter().error(offset, "'in' variables not permitted in runtime effects");
+ this->errorReporter().error(line, "'in' variables not permitted in runtime effects");
}
}
if (baseType->isEffectChild() && !(modifiers.fFlags & Modifiers::kUniform_Flag)) {
this->errorReporter().error(
- offset, "variables of type '" + baseType->displayName() + "' must be uniform");
+ line, "variables of type '" + baseType->displayName() + "' must be uniform");
}
if (modifiers.fLayout.fFlags & Layout::kSRGBUnpremul_Flag) {
if (!this->isRuntimeEffect()) {
- this->errorReporter().error(offset,
+ this->errorReporter().error(line,
"'srgb_unpremul' is only permitted in runtime effects");
}
if (!(modifiers.fFlags & Modifiers::kUniform_Flag)) {
- this->errorReporter().error(offset,
+ this->errorReporter().error(line,
"'srgb_unpremul' is only permitted on 'uniform' variables");
}
auto validColorXformType = [](const Type& t) {
@@ -183,7 +183,7 @@
};
if (!validColorXformType(*baseType) && !(baseType->isArray() &&
validColorXformType(baseType->componentType()))) {
- this->errorReporter().error(offset,
+ this->errorReporter().error(line,
"'srgb_unpremul' is only permitted on half3, half4, "
"float3, or float4 variables");
}
@@ -195,10 +195,10 @@
Modifiers::kFlat_Flag | Modifiers::kNoPerspective_Flag;
}
// TODO(skbug.com/11301): Migrate above checks into building a mask of permitted layout flags
- CheckModifiers(fContext, offset, modifiers, permitted, /*permittedLayoutFlags=*/~0);
+ CheckModifiers(fContext, line, modifiers, permitted, /*permittedLayoutFlags=*/~0);
}
-std::unique_ptr<Variable> IRGenerator::convertVar(int offset, const Modifiers& modifiers,
+std::unique_ptr<Variable> IRGenerator::convertVar(int line, const Modifiers& modifiers,
const Type* baseType, skstd::string_view name,
bool isArray,
std::unique_ptr<Expression> arraySize,
@@ -206,7 +206,7 @@
if (modifiers.fLayout.fLocation == 0 && modifiers.fLayout.fIndex == 0 &&
(modifiers.fFlags & Modifiers::kOut_Flag) &&
this->programKind() == ProgramKind::kFragment && name != Compiler::FRAGCOLOR_NAME) {
- this->errorReporter().error(offset,
+ this->errorReporter().error(line,
"out location=0, index=0 is reserved for sk_FragColor");
}
const Type* type = baseType;
@@ -219,7 +219,7 @@
}
type = fSymbolTable->addArrayDimension(type, arraySizeValue);
}
- return std::make_unique<Variable>(offset, this->modifiersPool().add(modifiers), name,
+ return std::make_unique<Variable>(line, this->modifiersPool().add(modifiers), name,
type, fIsBuiltinCode, storage);
}
@@ -244,11 +244,11 @@
var->name() == Compiler::RTADJUST_NAME) {
// `sk_RTAdjust` is special, and makes the IR generator emit position-fixup expressions.
if (fRTAdjust) {
- this->errorReporter().error(var->fOffset, "duplicate definition of 'sk_RTAdjust'");
+ this->errorReporter().error(var->fLine, "duplicate definition of 'sk_RTAdjust'");
return nullptr;
}
if (var->type() != *fContext.fTypes.fFloat4) {
- this->errorReporter().error(var->fOffset, "sk_RTAdjust must have type 'float4'");
+ this->errorReporter().error(var->fLine, "sk_RTAdjust must have type 'float4'");
return nullptr;
}
fRTAdjust = var.get();
@@ -262,7 +262,7 @@
return varDecl;
}
-std::unique_ptr<Statement> IRGenerator::convertVarDeclaration(int offset,
+std::unique_ptr<Statement> IRGenerator::convertVarDeclaration(int line,
const Modifiers& modifiers,
const Type* baseType,
skstd::string_view name,
@@ -270,7 +270,7 @@
std::unique_ptr<Expression> arraySize,
std::unique_ptr<Expression> value,
Variable::Storage storage) {
- std::unique_ptr<Variable> var = this->convertVar(offset, modifiers, baseType, name, isArray,
+ std::unique_ptr<Variable> var = this->convertVar(line, modifiers, baseType, name, isArray,
std::move(arraySize), storage);
if (!var) {
return nullptr;
@@ -289,12 +289,12 @@
return {};
}
baseType = baseType->applyPrecisionQualifiers(fContext, modifiers, fSymbolTable.get(),
- decls.fOffset);
+ decls.fLine);
if (!baseType) {
return {};
}
- this->checkVarDeclaration(decls.fOffset, modifiers, baseType, storage);
+ this->checkVarDeclaration(decls.fLine, modifiers, baseType, storage);
StatementArray varDecls;
for (; declarationsIter != decls.end(); ++declarationsIter) {
@@ -305,7 +305,7 @@
auto iter = varDecl.begin();
if (iter != varDecl.end() && varData.fIsArray) {
if (!*iter) {
- this->errorReporter().error(decls.fOffset, "array must have a size");
+ this->errorReporter().error(decls.fLine, "array must have a size");
continue;
}
arraySize = this->convertExpression(*iter++);
@@ -319,7 +319,7 @@
continue;
}
}
- std::unique_ptr<Statement> varDeclStmt = this->convertVarDeclaration(varDecl.fOffset,
+ std::unique_ptr<Statement> varDeclStmt = this->convertVarDeclaration(varDecl.fLine,
modifiers,
baseType,
varData.fName,
@@ -337,7 +337,7 @@
std::unique_ptr<ModifiersDeclaration> IRGenerator::convertModifiersDeclaration(const ASTNode& m) {
if (this->programKind() != ProgramKind::kFragment &&
this->programKind() != ProgramKind::kVertex) {
- this->errorReporter().error(m.fOffset,
+ this->errorReporter().error(m.fLine,
"layout qualifiers are not allowed in this kind of program");
return nullptr;
}
@@ -366,7 +366,7 @@
}
}
bool isStatic = n.getBool();
- return IfStatement::Convert(fContext, n.fOffset, isStatic, std::move(test),
+ return IfStatement::Convert(fContext, n.fLine, isStatic, std::move(test),
std::move(ifTrue), std::move(ifFalse));
}
@@ -403,7 +403,7 @@
return nullptr;
}
- return ForStatement::Convert(fContext, f.fOffset, std::move(initializer), std::move(test),
+ return ForStatement::Convert(fContext, f.fLine, std::move(initializer), std::move(test),
std::move(next), std::move(statement), fSymbolTable);
}
@@ -418,7 +418,7 @@
if (!statement) {
return nullptr;
}
- return ForStatement::ConvertWhile(fContext, w.fOffset, std::move(test), std::move(statement),
+ return ForStatement::ConvertWhile(fContext, w.fLine, std::move(test), std::move(statement),
fSymbolTable);
}
@@ -469,9 +469,9 @@
statements.push_back(std::move(converted));
}
- caseStatements.push_back(Block::MakeUnscoped(c.fOffset, std::move(statements)));
+ caseStatements.push_back(Block::MakeUnscoped(c.fLine, std::move(statements)));
}
- return SwitchStatement::Convert(fContext, s.fOffset, s.getBool(), std::move(value),
+ return SwitchStatement::Convert(fContext, s.fLine, s.getBool(), std::move(value),
std::move(caseValues), std::move(caseStatements), fSymbolTable);
}
@@ -483,42 +483,42 @@
return ExpressionStatement::Make(fContext, std::move(e));
}
-std::unique_ptr<Statement> IRGenerator::convertReturn(int offset,
+std::unique_ptr<Statement> IRGenerator::convertReturn(int line,
std::unique_ptr<Expression> result) {
- return ReturnStatement::Make(offset, std::move(result));
+ return ReturnStatement::Make(line, std::move(result));
}
std::unique_ptr<Statement> IRGenerator::convertReturn(const ASTNode& r) {
SkASSERT(r.fKind == ASTNode::Kind::kReturn);
if (r.begin() != r.end()) {
if (std::unique_ptr<Expression> value = this->convertExpression(*r.begin())) {
- return this->convertReturn(r.fOffset, std::move(value));
+ return this->convertReturn(r.fLine, std::move(value));
} else {
- return this->convertReturn(r.fOffset, Poison::Make(r.fOffset, fContext));
+ return this->convertReturn(r.fLine, Poison::Make(r.fLine, fContext));
}
}
- return this->convertReturn(r.fOffset, /*result=*/nullptr);
+ return this->convertReturn(r.fLine, /*result=*/nullptr);
}
std::unique_ptr<Statement> IRGenerator::convertBreak(const ASTNode& b) {
SkASSERT(b.fKind == ASTNode::Kind::kBreak);
- return BreakStatement::Make(b.fOffset);
+ return BreakStatement::Make(b.fLine);
}
std::unique_ptr<Statement> IRGenerator::convertContinue(const ASTNode& c) {
SkASSERT(c.fKind == ASTNode::Kind::kContinue);
- return ContinueStatement::Make(c.fOffset);
+ return ContinueStatement::Make(c.fLine);
}
std::unique_ptr<Statement> IRGenerator::convertDiscard(const ASTNode& d) {
SkASSERT(d.fKind == ASTNode::Kind::kDiscard);
if (this->programKind() != ProgramKind::kFragment) {
- this->errorReporter().error(d.fOffset,
+ this->errorReporter().error(d.fLine,
"discard statement is only permitted in fragment shaders");
return nullptr;
}
- return DiscardStatement::Make(d.fOffset);
+ return DiscardStatement::Make(d.fLine);
}
void IRGenerator::appendRTAdjustFixupToVertexMain(const FunctionDeclaration& decl, Block* body) {
@@ -538,7 +538,7 @@
SkASSERT(skPerVertex);
auto Ref = [](const Variable* var) -> std::unique_ptr<Expression> {
- return VariableReference::Make(/*offset=*/-1, var);
+ return VariableReference::Make(/*line=*/-1, var);
};
auto Field = [&](const Variable* var, int idx) -> std::unique_ptr<Expression> {
return FieldAccess::Make(fContext, Ref(var), idx, OwnerKind::kAnonymousInterfaceBlock);
@@ -565,7 +565,7 @@
}
void IRGenerator::CheckModifiers(const Context& context,
- int offset,
+ int line,
const Modifiers& modifiers,
int permittedModifierFlags,
int permittedLayoutFlags) {
@@ -589,7 +589,7 @@
for (const auto& f : kModifierFlags) {
if (modifierFlags & f.flag) {
if (!(permittedModifierFlags & f.flag)) {
- context.fErrors->error(offset, "'" + String(f.name) + "' is not permitted here");
+ context.fErrors->error(line, "'" + String(f.name) + "' is not permitted here");
}
modifierFlags &= ~f.flag;
}
@@ -615,7 +615,7 @@
if (layoutFlags & lf.flag) {
if (!(permittedLayoutFlags & lf.flag)) {
context.fErrors->error(
- offset, "layout qualifier '" + String(lf.name) + "' is not permitted here");
+ line, "layout qualifier '" + String(lf.name) + "' is not permitted here");
}
layoutFlags &= ~lf.flag;
}
@@ -642,14 +642,14 @@
return;
}
if (pd.fIsArray) {
- int arraySize = this->convertArraySize(*type, param.fOffset, *paramIter++);
+ int arraySize = this->convertArraySize(*type, param.fLine, *paramIter++);
if (!arraySize) {
return;
}
type = fSymbolTable->addArrayDimension(type, arraySize);
}
- parameters.push_back(std::make_unique<Variable>(param.fOffset,
+ parameters.push_back(std::make_unique<Variable>(param.fLine,
this->modifiersPool().add(pd.fModifiers),
pd.fName,
type,
@@ -673,7 +673,7 @@
const FunctionDeclaration* decl = FunctionDeclaration::Convert(
fContext,
*fSymbolTable,
- f.fOffset,
+ f.fLine,
this->modifiersPool().add(declModifiers),
funcData.fName,
std::move(parameters),
@@ -684,7 +684,7 @@
}
if (iter == f.end()) {
// If there's no body, we've found a prototype.
- fProgramElements->push_back(std::make_unique<FunctionPrototype>(f.fOffset, decl,
+ fProgramElements->push_back(std::make_unique<FunctionPrototype>(f.fLine, decl,
fIsBuiltinCode));
} else {
// Compile function body.
@@ -698,7 +698,7 @@
}
this->appendRTAdjustFixupToVertexMain(*decl, body.get());
std::unique_ptr<FunctionDefinition> result = FunctionDefinition::Convert(
- fContext, f.fOffset, *decl, std::move(body), fIsBuiltinCode);
+ fContext, f.fLine, *decl, std::move(body), fIsBuiltinCode);
decl->setDefinition(result.get());
result->setSource(&f);
fProgramElements->push_back(std::move(result));
@@ -713,13 +713,13 @@
return nullptr;
}
if (!type->isStruct()) {
- this->errorReporter().error(node.fOffset,
+ this->errorReporter().error(node.fLine,
"expected a struct here, found '" + type->name() + "'");
return nullptr;
}
SkDEBUGCODE(auto [iter, wasInserted] =) fDefinedStructs.insert(type);
SkASSERT(wasInserted);
- return std::make_unique<StructDefinition>(node.fOffset, *type);
+ return std::make_unique<StructDefinition>(node.fLine, *type);
}
void IRGenerator::scanInterfaceBlock(SkSL::InterfaceBlock& intf) {
@@ -731,7 +731,7 @@
fRTAdjustInterfaceBlock = &intf.variable();
fRTAdjustFieldIndex = i;
} else {
- this->errorReporter().error(intf.fOffset, "sk_RTAdjust must have type 'float4'");
+ this->errorReporter().error(intf.fLine, "sk_RTAdjust must have type 'float4'");
}
}
}
@@ -740,7 +740,7 @@
std::unique_ptr<SkSL::InterfaceBlock> IRGenerator::convertInterfaceBlock(const ASTNode& intf) {
if (this->programKind() != ProgramKind::kFragment &&
this->programKind() != ProgramKind::kVertex) {
- this->errorReporter().error(intf.fOffset,
+ this->errorReporter().error(intf.fLine,
"interface blocks are not allowed in this kind of program");
return nullptr;
}
@@ -767,20 +767,20 @@
}
}
}
- const Type* type = old->takeOwnershipOfSymbol(Type::MakeStructType(intf.fOffset,
+ const Type* type = old->takeOwnershipOfSymbol(Type::MakeStructType(intf.fLine,
id.fTypeName,
fields));
int arraySize = 0;
if (id.fIsArray) {
const ASTNode& size = *(iter++);
- arraySize = this->convertArraySize(*type, size.fOffset, size);
+ arraySize = this->convertArraySize(*type, size.fLine, size);
if (!arraySize) {
return nullptr;
}
type = symbols->addArrayDimension(type, arraySize);
}
const Variable* var = old->takeOwnershipOfSymbol(
- std::make_unique<Variable>(intf.fOffset,
+ std::make_unique<Variable>(intf.fLine,
this->modifiersPool().add(id.fModifiers),
id.fInstanceName.length() ? id.fInstanceName : id.fTypeName,
type,
@@ -790,11 +790,11 @@
old->addWithoutOwnership(var);
} else {
for (size_t i = 0; i < fields.size(); i++) {
- old->add(std::make_unique<Field>(intf.fOffset, var, (int)i));
+ old->add(std::make_unique<Field>(intf.fLine, var, (int)i));
}
}
std::unique_ptr<SkSL::InterfaceBlock> result = std::make_unique<SkSL::InterfaceBlock>(
- intf.fOffset, *var, id.fTypeName, id.fInstanceName, arraySize, symbols);
+ intf.fLine, *var, id.fTypeName, id.fInstanceName, arraySize, symbols);
this->scanInterfaceBlock(*result);
return result;
}
@@ -807,7 +807,7 @@
auto [iter, wasInserted] = fDefinedStructs.insert(type);
if (wasInserted) {
fProgramElements->push_back(
- std::make_unique<StructDefinition>(decl.fOffset, *type));
+ std::make_unique<StructDefinition>(decl.fLine, *type));
}
}
fProgramElements->push_back(std::make_unique<GlobalVarDeclaration>(std::move(stmt)));
@@ -818,29 +818,29 @@
skstd::string_view name = type.getStringView();
const Symbol* symbol = (*fSymbolTable)[name];
if (!symbol || !symbol->is<Type>()) {
- this->errorReporter().error(type.fOffset, "unknown type '" + name + "'");
+ this->errorReporter().error(type.fLine, "unknown type '" + name + "'");
return nullptr;
}
const Type* result = &symbol->as<Type>();
const bool isArray = (type.begin() != type.end());
if (result->isVoid() && !allowVoid) {
- this->errorReporter().error(type.fOffset,
+ this->errorReporter().error(type.fLine,
"type '" + name + "' not allowed in this context");
return nullptr;
}
if (!fIsBuiltinCode) {
if (result->containsPrivateFields()) {
- this->errorReporter().error(type.fOffset, "type '" + name + "' is private");
+ this->errorReporter().error(type.fLine, "type '" + name + "' is private");
return nullptr;
}
if (this->strictES2Mode() && !result->allowedInES2()) {
- this->errorReporter().error(type.fOffset, "type '" + name + "' is not supported");
+ this->errorReporter().error(type.fLine, "type '" + name + "' is not supported");
return nullptr;
}
}
if (isArray) {
auto iter = type.begin();
- int arraySize = this->convertArraySize(*result, type.fOffset, *iter);
+ int arraySize = this->convertArraySize(*result, type.fLine, *iter);
if (!arraySize) {
return nullptr;
}
@@ -854,19 +854,19 @@
case ASTNode::Kind::kBinary:
return this->convertBinaryExpression(expr);
case ASTNode::Kind::kBool:
- return Literal::MakeBool(fContext, expr.fOffset, expr.getBool());
+ return Literal::MakeBool(fContext, expr.fLine, expr.getBool());
case ASTNode::Kind::kCall:
return this->convertCallExpression(expr);
case ASTNode::Kind::kField:
return this->convertFieldExpression(expr);
case ASTNode::Kind::kFloat:
- return Literal::MakeFloat(fContext, expr.fOffset, expr.getFloat());
+ return Literal::MakeFloat(fContext, expr.fLine, expr.getFloat());
case ASTNode::Kind::kIdentifier:
return this->convertIdentifier(expr);
case ASTNode::Kind::kIndex:
return this->convertIndexExpression(expr);
case ASTNode::Kind::kInt:
- return Literal::MakeInt(fContext, expr.fOffset, expr.getInt());
+ return Literal::MakeInt(fContext, expr.fLine, expr.getInt());
case ASTNode::Kind::kPostfix:
return this->convertPostfixExpression(expr);
case ASTNode::Kind::kPrefix:
@@ -879,10 +879,10 @@
}
}
-std::unique_ptr<Expression> IRGenerator::convertIdentifier(int offset, skstd::string_view name) {
+std::unique_ptr<Expression> IRGenerator::convertIdentifier(int line, skstd::string_view name) {
const Symbol* result = (*fSymbolTable)[name];
if (!result) {
- this->errorReporter().error(offset, "unknown identifier '" + name + "'");
+ this->errorReporter().error(line, "unknown identifier '" + name + "'");
return nullptr;
}
switch (result->kind()) {
@@ -890,11 +890,11 @@
std::vector<const FunctionDeclaration*> f = {
&result->as<FunctionDeclaration>()
};
- return std::make_unique<FunctionReference>(fContext, offset, f);
+ return std::make_unique<FunctionReference>(fContext, line, f);
}
case Symbol::Kind::kUnresolvedFunction: {
const UnresolvedFunction* f = &result->as<UnresolvedFunction>();
- return std::make_unique<FunctionReference>(fContext, offset, f->functions());
+ return std::make_unique<FunctionReference>(fContext, line, f->functions());
}
case Symbol::Kind::kVariable: {
const Variable* var = &result->as<Variable>();
@@ -910,22 +910,22 @@
break;
}
// default to kRead_RefKind; this will be corrected later if the variable is written to
- return VariableReference::Make(offset, var, VariableReference::RefKind::kRead);
+ return VariableReference::Make(line, var, VariableReference::RefKind::kRead);
}
case Symbol::Kind::kField: {
const Field* field = &result->as<Field>();
- auto base = VariableReference::Make(offset, &field->owner(),
+ auto base = VariableReference::Make(line, &field->owner(),
VariableReference::RefKind::kRead);
return FieldAccess::Make(fContext, std::move(base), field->fieldIndex(),
FieldAccess::OwnerKind::kAnonymousInterfaceBlock);
}
case Symbol::Kind::kType: {
const Type* t = &result->as<Type>();
- return std::make_unique<TypeReference>(fContext, offset, t);
+ return std::make_unique<TypeReference>(fContext, line, t);
}
case Symbol::Kind::kExternal: {
const ExternalFunction* r = &result->as<ExternalFunction>();
- return std::make_unique<ExternalFunctionReference>(offset, r);
+ return std::make_unique<ExternalFunctionReference>(line, r);
}
default:
SK_ABORT("unsupported symbol type %d\n", (int) result->kind());
@@ -933,7 +933,7 @@
}
std::unique_ptr<Expression> IRGenerator::convertIdentifier(const ASTNode& identifier) {
- return this->convertIdentifier(identifier.fOffset, identifier.getStringView());
+ return this->convertIdentifier(identifier.fLine, identifier.getStringView());
}
std::unique_ptr<Expression> IRGenerator::convertBinaryExpression(const ASTNode& expression) {
@@ -983,8 +983,8 @@
if (a->isBuiltin() != b->isBuiltin()) {
return a->isBuiltin() < b->isBuiltin();
}
- if (a->fOffset != b->fOffset) {
- return a->fOffset < b->fOffset;
+ if (a->fLine != b->fLine) {
+ return a->fLine < b->fLine;
}
if (a->name() != b->name()) {
return a->name() < b->name();
@@ -999,7 +999,7 @@
}
}
-std::unique_ptr<Expression> IRGenerator::call(int offset,
+std::unique_ptr<Expression> IRGenerator::call(int line,
const FunctionDeclaration& function,
ExpressionArray arguments) {
if (function.isBuiltin()) {
@@ -1011,7 +1011,7 @@
}
}
- return FunctionCall::Convert(fContext, offset, function, std::move(arguments));
+ return FunctionCall::Convert(fContext, line, function, std::move(arguments));
}
/**
@@ -1057,22 +1057,22 @@
return best;
}
-std::unique_ptr<Expression> IRGenerator::call(int offset,
+std::unique_ptr<Expression> IRGenerator::call(int line,
std::unique_ptr<Expression> functionValue,
ExpressionArray arguments) {
switch (functionValue->kind()) {
case Expression::Kind::kTypeReference:
return Constructor::Convert(fContext,
- offset,
+ line,
functionValue->as<TypeReference>().value(),
std::move(arguments));
case Expression::Kind::kExternalFunctionReference: {
const ExternalFunction& f = functionValue->as<ExternalFunctionReference>().function();
int count = f.callParameterCount();
if (count != (int) arguments.size()) {
- this->errorReporter().error(offset, "external function expected " +
- to_string(count) + " arguments, but found " +
- to_string((int)arguments.size()));
+ this->errorReporter().error(line, "external function expected " +
+ to_string(count) + " arguments, but found " +
+ to_string((int)arguments.size()));
return nullptr;
}
static constexpr int PARAMETER_MAX = 16;
@@ -1085,14 +1085,14 @@
return nullptr;
}
}
- return std::make_unique<ExternalFunctionCall>(offset, &f, std::move(arguments));
+ return std::make_unique<ExternalFunctionCall>(line, &f, std::move(arguments));
}
case Expression::Kind::kFunctionReference: {
const FunctionReference& ref = functionValue->as<FunctionReference>();
const std::vector<const FunctionDeclaration*>& functions = ref.functions();
const FunctionDeclaration* best = this->findBestFunctionForCall(functions, arguments);
if (best) {
- return this->call(offset, *best, std::move(arguments));
+ return this->call(line, *best, std::move(arguments));
}
String msg = "no match for " + functions[0]->name() + "(";
String separator;
@@ -1102,7 +1102,7 @@
msg += arguments[i]->type().displayName();
}
msg += ")";
- this->errorReporter().error(offset, msg);
+ this->errorReporter().error(line, msg);
return nullptr;
}
case Expression::Kind::kMethodReference: {
@@ -1112,7 +1112,7 @@
const std::vector<const FunctionDeclaration*>& functions = ref.functions();
const FunctionDeclaration* best = this->findBestFunctionForCall(functions, arguments);
if (best) {
- return this->call(offset, *best, std::move(arguments));
+ return this->call(line, *best, std::move(arguments));
}
String msg = "no match for " + arguments.back()->type().displayName() +
"::" + functions[0]->name().substr(1) + "(";
@@ -1123,13 +1123,13 @@
msg += arguments[i]->type().displayName();
}
msg += ")";
- this->errorReporter().error(offset, msg);
+ this->errorReporter().error(line, msg);
return nullptr;
}
case Expression::Kind::kPoison:
return functionValue;
default:
- this->errorReporter().error(offset, "not a function");
+ this->errorReporter().error(line, "not a function");
return nullptr;
}
}
@@ -1157,9 +1157,9 @@
}
if (iter == index.end()) {
if (base->is<TypeReference>()) {
- this->errorReporter().error(index.fOffset, "array must have a size");
+ this->errorReporter().error(index.fLine, "array must have a size");
} else {
- this->errorReporter().error(base->fOffset, "missing index in '[]'");
+ this->errorReporter().error(base->fLine, "missing index in '[]'");
}
return nullptr;
}
@@ -1185,7 +1185,7 @@
}
arguments.push_back(std::move(converted));
}
- return this->call(callNode.fOffset, std::move(base), std::move(arguments));
+ return this->call(callNode.fLine, std::move(base), std::move(arguments));
}
std::unique_ptr<Expression> IRGenerator::convertFieldExpression(const ASTNode& fieldNode) {
@@ -1394,7 +1394,7 @@
break;
}
case ASTNode::Kind::kExtension: {
- std::unique_ptr<Extension> e = this->convertExtension(decl.fOffset,
+ std::unique_ptr<Extension> e = this->convertExtension(decl.fLine,
decl.getStringView());
if (e) {
fProgramElements->push_back(std::move(e));
diff --git a/src/sksl/SkSLIRGenerator.h b/src/sksl/SkSLIRGenerator.h
index 35458ae..289bb58 100644
--- a/src/sksl/SkSLIRGenerator.h
+++ b/src/sksl/SkSLIRGenerator.h
@@ -134,12 +134,12 @@
}
static void CheckModifiers(const Context& context,
- int offset,
+ int line,
const Modifiers& modifiers,
int permittedModifierFlags,
int permittedLayoutFlags);
- std::unique_ptr<Expression> convertIdentifier(int offset, skstd::string_view identifier);
+ std::unique_ptr<Expression> convertIdentifier(int line, skstd::string_view identifier);
bool haveRTAdjustInterfaceBlock() { return fRTAdjustInterfaceBlock != nullptr; }
@@ -155,18 +155,18 @@
IRGenerator::IRBundle finish();
- void checkVarDeclaration(int offset,
+ void checkVarDeclaration(int line,
const Modifiers& modifiers,
const Type* baseType,
Variable::Storage storage);
- std::unique_ptr<Variable> convertVar(int offset, const Modifiers& modifiers,
+ std::unique_ptr<Variable> convertVar(int line, const Modifiers& modifiers,
const Type* baseType, skstd::string_view name,
bool isArray, std::unique_ptr<Expression> arraySize,
Variable::Storage storage);
std::unique_ptr<Statement> convertVarDeclaration(std::unique_ptr<Variable> var,
std::unique_ptr<Expression> value,
bool addToSymbolTable = true);
- std::unique_ptr<Statement> convertVarDeclaration(int offset, const Modifiers& modifiers,
+ std::unique_ptr<Statement> convertVarDeclaration(int line, const Modifiers& modifiers,
const Type* baseType, skstd::string_view name,
bool isArray,
std::unique_ptr<Expression> arraySize,
@@ -179,10 +179,10 @@
std::unique_ptr<ModifiersDeclaration> convertModifiersDeclaration(const ASTNode& m);
const Type* convertType(const ASTNode& type, bool allowVoid = false);
- std::unique_ptr<Expression> call(int offset,
+ std::unique_ptr<Expression> call(int line,
std::unique_ptr<Expression> function,
ExpressionArray arguments);
- std::unique_ptr<Expression> call(int offset,
+ std::unique_ptr<Expression> call(int line,
const FunctionDeclaration& function,
ExpressionArray arguments);
CoercionCost callCost(const FunctionDeclaration& function,
@@ -191,7 +191,7 @@
const std::vector<const FunctionDeclaration*>& functions,
const ExpressionArray& arguments) const;
CoercionCost coercionCost(const Expression& expr, const Type& type);
- int convertArraySize(const Type& type, int offset, const ASTNode& s);
+ int convertArraySize(const Type& type, int line, const ASTNode& s);
bool containsConstantZero(Expression& expr);
bool dividesByZero(Operator op, Expression& right);
std::unique_ptr<Block> convertBlock(const ASTNode& block);
@@ -201,7 +201,7 @@
std::unique_ptr<Statement> convertDo(const ASTNode& d);
std::unique_ptr<Statement> convertSwitch(const ASTNode& s);
std::unique_ptr<Expression> convertBinaryExpression(const ASTNode& expression);
- std::unique_ptr<Extension> convertExtension(int offset, skstd::string_view name);
+ std::unique_ptr<Extension> convertExtension(int line, skstd::string_view name);
std::unique_ptr<Statement> convertExpressionStatement(const ASTNode& s);
std::unique_ptr<Expression> convertField(std::unique_ptr<Expression> base,
skstd::string_view field);
@@ -212,7 +212,7 @@
std::unique_ptr<InterfaceBlock> convertInterfaceBlock(const ASTNode& s);
Modifiers convertModifiers(const Modifiers& m);
std::unique_ptr<Expression> convertPrefixExpression(const ASTNode& expression);
- std::unique_ptr<Statement> convertReturn(int offset, std::unique_ptr<Expression> result);
+ std::unique_ptr<Statement> convertReturn(int line, std::unique_ptr<Expression> result);
std::unique_ptr<Statement> convertReturn(const ASTNode& r);
std::unique_ptr<Expression> convertCallExpression(const ASTNode& expression);
std::unique_ptr<Expression> convertFieldExpression(const ASTNode& expression);
diff --git a/src/sksl/SkSLInliner.cpp b/src/sksl/SkSLInliner.cpp
index 4b77f3c..4c71157 100644
--- a/src/sksl/SkSLInliner.cpp
+++ b/src/sksl/SkSLInliner.cpp
@@ -279,13 +279,13 @@
fInlinedStatementCounter = 0;
}
-std::unique_ptr<Expression> Inliner::inlineExpression(int offset,
+std::unique_ptr<Expression> Inliner::inlineExpression(int line,
VariableRewriteMap* varMap,
SymbolTable* symbolTableForExpression,
const Expression& expression) {
auto expr = [&](const std::unique_ptr<Expression>& e) -> std::unique_ptr<Expression> {
if (e) {
- return this->inlineExpression(offset, varMap, symbolTableForExpression, *e);
+ return this->inlineExpression(line, varMap, symbolTableForExpression, *e);
}
return nullptr;
};
@@ -311,68 +311,68 @@
case Expression::Kind::kChildCall: {
const ChildCall& childCall = expression.as<ChildCall>();
return ChildCall::Make(*fContext,
- offset,
+ line,
childCall.type().clone(symbolTableForExpression),
childCall.child(),
argList(childCall.arguments()));
}
case Expression::Kind::kConstructorArray: {
const ConstructorArray& ctor = expression.as<ConstructorArray>();
- return ConstructorArray::Make(*fContext, offset,
+ return ConstructorArray::Make(*fContext, line,
*ctor.type().clone(symbolTableForExpression),
argList(ctor.arguments()));
}
case Expression::Kind::kConstructorArrayCast: {
const ConstructorArrayCast& ctor = expression.as<ConstructorArrayCast>();
- return ConstructorArrayCast::Make(*fContext, offset,
+ return ConstructorArrayCast::Make(*fContext, line,
*ctor.type().clone(symbolTableForExpression),
expr(ctor.argument()));
}
case Expression::Kind::kConstructorCompound: {
const ConstructorCompound& ctor = expression.as<ConstructorCompound>();
- return ConstructorCompound::Make(*fContext, offset,
+ return ConstructorCompound::Make(*fContext, line,
*ctor.type().clone(symbolTableForExpression),
argList(ctor.arguments()));
}
case Expression::Kind::kConstructorCompoundCast: {
const ConstructorCompoundCast& ctor = expression.as<ConstructorCompoundCast>();
- return ConstructorCompoundCast::Make(*fContext, offset,
+ return ConstructorCompoundCast::Make(*fContext, line,
*ctor.type().clone(symbolTableForExpression),
expr(ctor.argument()));
}
case Expression::Kind::kConstructorDiagonalMatrix: {
const ConstructorDiagonalMatrix& ctor = expression.as<ConstructorDiagonalMatrix>();
- return ConstructorDiagonalMatrix::Make(*fContext, offset,
+ return ConstructorDiagonalMatrix::Make(*fContext, line,
*ctor.type().clone(symbolTableForExpression),
expr(ctor.argument()));
}
case Expression::Kind::kConstructorMatrixResize: {
const ConstructorMatrixResize& ctor = expression.as<ConstructorMatrixResize>();
- return ConstructorMatrixResize::Make(*fContext, offset,
+ return ConstructorMatrixResize::Make(*fContext, line,
*ctor.type().clone(symbolTableForExpression),
expr(ctor.argument()));
}
case Expression::Kind::kConstructorScalarCast: {
const ConstructorScalarCast& ctor = expression.as<ConstructorScalarCast>();
- return ConstructorScalarCast::Make(*fContext, offset,
+ return ConstructorScalarCast::Make(*fContext, line,
*ctor.type().clone(symbolTableForExpression),
expr(ctor.argument()));
}
case Expression::Kind::kConstructorSplat: {
const ConstructorSplat& ctor = expression.as<ConstructorSplat>();
- return ConstructorSplat::Make(*fContext, offset,
+ return ConstructorSplat::Make(*fContext, line,
*ctor.type().clone(symbolTableForExpression),
expr(ctor.argument()));
}
case Expression::Kind::kConstructorStruct: {
const ConstructorStruct& ctor = expression.as<ConstructorStruct>();
- return ConstructorStruct::Make(*fContext, offset,
+ return ConstructorStruct::Make(*fContext, line,
*ctor.type().clone(symbolTableForExpression),
argList(ctor.arguments()));
}
case Expression::Kind::kExternalFunctionCall: {
const ExternalFunctionCall& externalCall = expression.as<ExternalFunctionCall>();
- return std::make_unique<ExternalFunctionCall>(offset, &externalCall.function(),
+ return std::make_unique<ExternalFunctionCall>(line, &externalCall.function(),
argList(externalCall.arguments()));
}
case Expression::Kind::kExternalFunctionReference:
@@ -384,7 +384,7 @@
case Expression::Kind::kFunctionCall: {
const FunctionCall& funcCall = expression.as<FunctionCall>();
return FunctionCall::Make(*fContext,
- offset,
+ line,
funcCall.type().clone(symbolTableForExpression),
funcCall.function(),
argList(funcCall.arguments()));
@@ -432,7 +432,7 @@
}
}
-std::unique_ptr<Statement> Inliner::inlineStatement(int offset,
+std::unique_ptr<Statement> Inliner::inlineStatement(int line,
VariableRewriteMap* varMap,
SymbolTable* symbolTableForStatement,
std::unique_ptr<Expression>* resultExpr,
@@ -441,7 +441,7 @@
bool isBuiltinCode) {
auto stmt = [&](const std::unique_ptr<Statement>& s) -> std::unique_ptr<Statement> {
if (s) {
- return this->inlineStatement(offset, varMap, symbolTableForStatement, resultExpr,
+ return this->inlineStatement(line, varMap, symbolTableForStatement, resultExpr,
returnComplexity, *s, isBuiltinCode);
}
return nullptr;
@@ -456,7 +456,7 @@
};
auto expr = [&](const std::unique_ptr<Expression>& e) -> std::unique_ptr<Expression> {
if (e) {
- return this->inlineExpression(offset, varMap, symbolTableForStatement, *e);
+ return this->inlineExpression(line, varMap, symbolTableForStatement, *e);
}
return nullptr;
};
@@ -466,7 +466,7 @@
switch (statement.kind()) {
case Statement::Kind::kBlock: {
const Block& b = statement.as<Block>();
- return Block::Make(offset, blockStmts(b),
+ return Block::Make(line, blockStmts(b),
SymbolTable::WrapIfBuiltin(b.symbolTable()),
b.isScope());
}
@@ -491,13 +491,13 @@
std::unique_ptr<Statement> initializer = stmt(f.initializer());
// We can't reuse the unroll info from the original for loop, because it uses a
// different induction variable. Ours is a clone.
- return ForStatement::Make(*fContext, offset, std::move(initializer), expr(f.test()),
+ return ForStatement::Make(*fContext, line, std::move(initializer), expr(f.test()),
expr(f.next()), stmt(f.statement()), /*unrollInfo=*/nullptr,
SymbolTable::WrapIfBuiltin(f.symbols()));
}
case Statement::Kind::kIf: {
const IfStatement& i = statement.as<IfStatement>();
- return IfStatement::Make(*fContext, offset, i.isStatic(), expr(i.test()),
+ return IfStatement::Make(*fContext, line, i.isStatic(), expr(i.test()),
stmt(i.ifTrue()), stmt(i.ifFalse()));
}
case Statement::Kind::kInlineMarker:
@@ -541,10 +541,10 @@
cases.reserve_back(ss.cases().size());
for (const std::unique_ptr<Statement>& switchCaseStmt : ss.cases()) {
const SwitchCase& sc = switchCaseStmt->as<SwitchCase>();
- cases.push_back(std::make_unique<SwitchCase>(offset, expr(sc.value()),
+ cases.push_back(std::make_unique<SwitchCase>(line, expr(sc.value()),
stmt(sc.statement())));
}
- return SwitchStatement::Make(*fContext, offset, ss.isStatic(), expr(ss.value()),
+ return SwitchStatement::Make(*fContext, line, ss.isStatic(), expr(ss.value()),
std::move(cases), SymbolTable::WrapIfBuiltin(ss.symbols()));
}
case Statement::Kind::kVarDeclaration: {
@@ -558,13 +558,13 @@
const String* name = symbolTableForStatement->takeOwnershipOfString(
fContext->fMangler->uniqueName(variable.name(), symbolTableForStatement));
auto clonedVar = std::make_unique<Variable>(
- offset,
+ line,
&variable.modifiers(),
name->c_str(),
variable.type().clone(symbolTableForStatement),
isBuiltinCode,
variable.storage());
- (*varMap)[&variable] = VariableReference::Make(offset, clonedVar.get());
+ (*varMap)[&variable] = VariableReference::Make(line, clonedVar.get());
auto result = VarDeclaration::Make(*fContext,
clonedVar.get(),
decl.baseType().clone(symbolTableForStatement),
@@ -599,7 +599,7 @@
SkASSERT(this->isSafeToInline(call->function().definition()));
ExpressionArray& arguments = call->arguments();
- const int offset = call->fOffset;
+ const int line = call->fLine;
const FunctionDefinition& function = *call->function().definition();
const Block& body = function.body()->as<Block>();
const ReturnComplexity returnComplexity = GetReturnComplexity(function);
@@ -626,7 +626,7 @@
symbolTable.get(),
/*initialValue=*/nullptr);
inlineStatements.push_back(std::move(var.fVarDecl));
- resultExpr = VariableReference::Make(/*offset=*/-1, var.fVarSymbol);
+ resultExpr = VariableReference::Make(/*line=*/-1, var.fVarSymbol);
}
// Create variables in the extra statements to hold the arguments, and assign the arguments to
@@ -654,11 +654,11 @@
symbolTable.get(),
std::move(arguments[i]));
inlineStatements.push_back(std::move(var.fVarDecl));
- varMap[param] = VariableReference::Make(/*offset=*/-1, var.fVarSymbol);
+ varMap[param] = VariableReference::Make(/*line=*/-1, var.fVarSymbol);
}
for (const std::unique_ptr<Statement>& stmt : body.children()) {
- inlineStatements.push_back(this->inlineStatement(offset, &varMap, symbolTable.get(),
+ inlineStatements.push_back(this->inlineStatement(line, &varMap, symbolTable.get(),
&resultExpr, returnComplexity, *stmt,
caller->isBuiltin()));
}
@@ -668,7 +668,7 @@
// Wrap all of the generated statements in a block. We need a real Block here, so we can't use
// MakeUnscoped. This is because we need to add another child statement to the Block later.
InlinedCall inlinedCall;
- inlinedCall.fInlinedBody = Block::Make(offset, std::move(inlineStatements),
+ inlinedCall.fInlinedBody = Block::Make(line, std::move(inlineStatements),
/*symbols=*/nullptr, /*isScope=*/false);
if (resultExpr) {
@@ -677,15 +677,15 @@
} else if (function.declaration().returnType().isVoid()) {
// It's a void function, so it doesn't actually result in anything, but we have to return
// something non-null as a standin.
- inlinedCall.fReplacementExpr = Literal::MakeBool(*fContext, offset, /*value=*/false);
+ inlinedCall.fReplacementExpr = Literal::MakeBool(*fContext, line, /*value=*/false);
} else {
// It's a non-void function, but it never created a result expression--that is, it never
// returned anything on any path! This should have been detected in the function finalizer.
// Still, discard our output and generate an error.
SkDEBUGFAIL("inliner found non-void function that fails to return a value on any path");
- fContext->fErrors->error(function.fOffset, "inliner found non-void function '" +
- function.declaration().name() +
- "' that fails to return a value on any path");
+ fContext->fErrors->error(function.fLine, "inliner found non-void function '" +
+ function.declaration().name() +
+ "' that fails to return a value on any path");
inlinedCall = {};
}
diff --git a/src/sksl/SkSLInliner.h b/src/sksl/SkSLInliner.h
index 9d68755..a38599e 100644
--- a/src/sksl/SkSLInliner.h
+++ b/src/sksl/SkSLInliner.h
@@ -61,11 +61,11 @@
std::shared_ptr<SymbolTable> symbols, ProgramUsage* usage,
InlineCandidateList* candidateList);
- std::unique_ptr<Expression> inlineExpression(int offset,
+ std::unique_ptr<Expression> inlineExpression(int line,
VariableRewriteMap* varMap,
SymbolTable* symbolTableForExpression,
const Expression& expression);
- std::unique_ptr<Statement> inlineStatement(int offset,
+ std::unique_ptr<Statement> inlineStatement(int line,
VariableRewriteMap* varMap,
SymbolTable* symbolTableForStatement,
std::unique_ptr<Expression>* resultExpr,
diff --git a/src/sksl/SkSLParser.cpp b/src/sksl/SkSLParser.cpp
index 09d65ae..c0ae141 100644
--- a/src/sksl/SkSLParser.cpp
+++ b/src/sksl/SkSLParser.cpp
@@ -119,7 +119,7 @@
std::unique_ptr<ASTFile> Parser::compilationUnit() {
fFile = std::make_unique<ASTFile>();
fFile->fNodes.reserve(fText.size() / 10); // a typical program is approx 10:1 for chars:nodes
- ASTNode::ID result = this->createNode(/*offset=*/1, ASTNode::Kind::kFile);
+ ASTNode::ID result = this->createNode(/*line=*/1, ASTNode::Kind::kFile);
fFile->fRoot = result;
for (;;) {
switch (this->peek().fKind) {
@@ -232,11 +232,11 @@
}
void Parser::error(Token token, String msg) {
- this->error(token.fOffset, msg);
+ this->error(token.fLine, msg);
}
-void Parser::error(int offset, String msg) {
- fErrors->error(offset, msg);
+void Parser::error(int line, String msg) {
+ fErrors->error(line, msg);
}
bool Parser::isType(skstd::string_view name) {
@@ -270,7 +270,7 @@
if (!this->expect(Token::Kind::TK_IDENTIFIER, "an identifier")) {
return ASTNode::ID::Invalid();
}
- return this->createNode(start.fOffset, ASTNode::Kind::kExtension, this->text(name));
+ return this->createNode(start.fLine, ASTNode::Kind::kExtension, this->text(name));
} else {
this->error(start, "unsupported directive '" + this->text(start) + "'");
return ASTNode::ID::Invalid();
@@ -283,7 +283,7 @@
Token lookahead = this->peek();
switch (lookahead.fKind) {
case Token::Kind::TK_SEMICOLON:
- this->error(lookahead.fOffset, "expected a declaration, but found ';'");
+ this->error(lookahead.fLine, "expected a declaration, but found ';'");
return ASTNode::ID::Invalid();
default:
break;
@@ -299,7 +299,7 @@
}
if (lookahead.fKind == Token::Kind::TK_SEMICOLON) {
this->nextToken();
- return this->createNode(lookahead.fOffset, ASTNode::Kind::kModifiers, modifiers);
+ return this->createNode(lookahead.fLine, ASTNode::Kind::kModifiers, modifiers);
}
ASTNode::ID type = this->type();
if (!type) {
@@ -320,7 +320,7 @@
ASTNode::ID Parser::functionDeclarationEnd(Modifiers modifiers,
ASTNode::ID type,
const Token& name) {
- ASTNode::ID result = this->createNode(name.fOffset, ASTNode::Kind::kFunction);
+ ASTNode::ID result = this->createNode(name.fLine, ASTNode::Kind::kFunction);
ASTNode::FunctionData fd(modifiers, this->text(name), 0);
getNode(result).addChild(type);
Token lookahead = this->peek();
@@ -431,7 +431,7 @@
if (modifiers.fFlags != Modifiers::kNo_Flag) {
String desc = modifiers.description();
desc.pop_back(); // remove trailing space
- this->error(declsNode.fOffset,
+ this->error(declsNode.fLine,
"modifier '" + desc + "' is not permitted on a struct field");
}
@@ -439,7 +439,7 @@
SkASSERT(symbol);
const Type* type = &symbol->as<Type>();
if (type->isOpaque()) {
- this->error(declsNode.fOffset,
+ this->error(declsNode.fLine,
"opaque type '" + type->name() + "' is not permitted in a struct");
}
@@ -452,11 +452,11 @@
if (vd.fIsArray) {
const ASTNode& size = *var.begin();
if (!size || size.fKind != ASTNode::Kind::kInt) {
- this->error(declsNode.fOffset, "array size in struct field must be a constant");
+ this->error(declsNode.fLine, "array size in struct field must be a constant");
return ASTNode::ID::Invalid();
}
if (size.getInt() <= 0 || size.getInt() > INT_MAX) {
- this->error(declsNode.fOffset, "array size is invalid");
+ this->error(declsNode.fLine, "array size is invalid");
return ASTNode::ID::Invalid();
}
// Add the array dimensions to our type.
@@ -466,7 +466,7 @@
fields.push_back(Type::Field(modifiers, vd.fName, fieldType));
if (vd.fIsArray ? var.begin()->fNext : var.fFirstChild) {
- this->error(declsNode.fOffset, "initializers are not permitted on struct fields");
+ this->error(declsNode.fLine, "initializers are not permitted on struct fields");
}
}
}
@@ -474,17 +474,17 @@
return ASTNode::ID::Invalid();
}
if (fields.empty()) {
- this->error(name.fOffset,
+ this->error(name.fLine,
"struct '" + this->text(name) + "' must contain at least one field");
return ASTNode::ID::Invalid();
}
- std::unique_ptr<Type> newType = Type::MakeStructType(name.fOffset, this->text(name), fields);
+ std::unique_ptr<Type> newType = Type::MakeStructType(name.fLine, this->text(name), fields);
if (newType->isTooDeeplyNested()) {
- this->error(name.fOffset, "struct '" + this->text(name) + "' is too deeply nested");
+ this->error(name.fLine, "struct '" + this->text(name) + "' is too deeply nested");
return ASTNode::ID::Invalid();
}
fSymbols.add(std::move(newType));
- return this->createNode(name.fOffset, ASTNode::Kind::kType, this->text(name));
+ return this->createNode(name.fLine, ASTNode::Kind::kType, this->text(name));
}
/* structDeclaration ((IDENTIFIER varDeclarationEnd) | SEMICOLON) */
@@ -504,9 +504,9 @@
/* (LBRACKET expression? RBRACKET)* (EQ assignmentExpression)? (COMMA IDENTIFER
(LBRACKET expression? RBRACKET)* (EQ assignmentExpression)?)* SEMICOLON */
ASTNode::ID Parser::varDeclarationEnd(Modifiers mods, ASTNode::ID type, skstd::string_view name) {
- int offset = this->peek().fOffset;
- ASTNode::ID result = this->createNode(offset, ASTNode::Kind::kVarDeclarations);
- this->addChild(result, this->createNode(offset, ASTNode::Kind::kModifiers, mods));
+ int line = this->peek().fLine;
+ ASTNode::ID result = this->createNode(line, ASTNode::Kind::kVarDeclarations);
+ this->addChild(result, this->createNode(line, ASTNode::Kind::kModifiers, mods));
getNode(result).addChild(type);
auto parseArrayDimensions = [&](ASTNode::ID currentVar, ASTNode::VarData* vd) -> bool {
@@ -543,7 +543,7 @@
return true;
};
- ASTNode::ID currentVar = this->createNode(offset, ASTNode::Kind::kVarDeclaration);
+ ASTNode::ID currentVar = this->createNode(line, ASTNode::Kind::kVarDeclaration);
ASTNode::VarData vd{name, /*isArray=*/false};
getNode(result).addChild(currentVar);
@@ -563,7 +563,7 @@
currentVar = ASTNode::ID(fFile->fNodes.size());
vd = ASTNode::VarData{this->text(identifierName), /*isArray=*/false};
- fFile->fNodes.emplace_back(&fFile->fNodes, offset, ASTNode::Kind::kVarDeclaration);
+ fFile->fNodes.emplace_back(&fFile->fNodes, line, ASTNode::Kind::kVarDeclaration);
getNode(result).addChild(currentVar);
if (!parseArrayDimensions(currentVar, &vd)) {
@@ -591,7 +591,7 @@
if (!this->expectIdentifier(&name)) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID result = this->createNode(name.fOffset, ASTNode::Kind::kParameter);
+ ASTNode::ID result = this->createNode(name.fLine, ASTNode::Kind::kParameter);
ASTNode::ParameterData pd(modifiers, this->text(name), 0);
getNode(result).addChild(type);
while (this->checkNext(Token::Kind::TK_LBRACKET)) {
@@ -609,7 +609,7 @@
this->error(sizeToken, "array size is too large: " + arraySizeFrag);
return ASTNode::ID::Invalid();
}
- this->addChild(result, this->createNode(sizeToken.fOffset, ASTNode::Kind::kInt, arraySize));
+ this->addChild(result, this->createNode(sizeToken.fLine, ASTNode::Kind::kInt, arraySize));
if (!this->expect(Token::Kind::TK_RBRACKET, "']'")) {
return ASTNode::ID::Invalid();
}
@@ -792,7 +792,7 @@
return this->block();
case Token::Kind::TK_SEMICOLON:
this->nextToken();
- return this->createNode(start.fOffset, ASTNode::Kind::kBlock);
+ return this->createNode(start.fLine, ASTNode::Kind::kBlock);
case Token::Kind::TK_HIGHP:
case Token::Kind::TK_MEDIUMP:
case Token::Kind::TK_LOWP:
@@ -814,7 +814,7 @@
this->error(type, ("no type named '" + this->text(type) + "'").c_str());
return ASTNode::ID::Invalid();
}
- ASTNode::ID result = this->createNode(type.fOffset, ASTNode::Kind::kType, this->text(type));
+ ASTNode::ID result = this->createNode(type.fLine, ASTNode::Kind::kType, this->text(type));
bool isArray = false;
while (this->checkNext(Token::Kind::TK_LBRACKET)) {
if (isArray) {
@@ -824,7 +824,7 @@
if (this->peek().fKind != Token::Kind::TK_RBRACKET) {
SKSL_INT i;
if (this->intLiteral(&i)) {
- this->addChild(result, this->createNode(this->peek().fOffset,
+ this->addChild(result, this->createNode(this->peek().fLine,
ASTNode::Kind::kInt, i));
} else {
return ASTNode::ID::Invalid();
@@ -853,7 +853,7 @@
this->error(name, "no type named '" + this->text(name) + "'");
return ASTNode::ID::Invalid();
}
- ASTNode::ID result = this->createNode(name.fOffset, ASTNode::Kind::kInterfaceBlock);
+ ASTNode::ID result = this->createNode(name.fLine, ASTNode::Kind::kInterfaceBlock);
ASTNode::InterfaceBlockData id(mods, this->text(name), 0, "", 0);
this->nextToken();
while (this->peek().fKind != Token::Kind::TK_RBRACE) {
@@ -906,7 +906,7 @@
if (!isStatic && !this->expect(Token::Kind::TK_IF, "'if'", &start)) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID result = this->createNode(start.fOffset, ASTNode::Kind::kIf, isStatic);
+ ASTNode::ID result = this->createNode(start.fLine, ASTNode::Kind::kIf, isStatic);
if (!this->expect(Token::Kind::TK_LPAREN, "'('")) {
return ASTNode::ID::Invalid();
}
@@ -940,7 +940,7 @@
if (!this->expect(Token::Kind::TK_DO, "'do'", &start)) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID result = this->createNode(start.fOffset, ASTNode::Kind::kDo);
+ ASTNode::ID result = this->createNode(start.fLine, ASTNode::Kind::kDo);
ASTNode::ID statement = this->statement();
if (!statement) {
return ASTNode::ID::Invalid();
@@ -975,7 +975,7 @@
if (!this->expect(Token::Kind::TK_LPAREN, "'('")) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID result = this->createNode(start.fOffset, ASTNode::Kind::kWhile);
+ ASTNode::ID result = this->createNode(start.fLine, ASTNode::Kind::kWhile);
ASTNode::ID test = this->expression();
if (!test) {
return ASTNode::ID::Invalid();
@@ -998,7 +998,7 @@
if (!this->expect(Token::Kind::TK_CASE, "'case'", &start)) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID result = this->createNode(start.fOffset, ASTNode::Kind::kSwitchCase);
+ ASTNode::ID result = this->createNode(start.fLine, ASTNode::Kind::kSwitchCase);
ASTNode::ID value = this->expression();
if (!value) {
return ASTNode::ID::Invalid();
@@ -1039,7 +1039,7 @@
if (!this->expect(Token::Kind::TK_LBRACE, "'{'")) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID result = this->createNode(start.fOffset, ASTNode::Kind::kSwitch, isStatic);
+ ASTNode::ID result = this->createNode(start.fLine, ASTNode::Kind::kSwitch, isStatic);
getNode(result).addChild(value);
while (this->peek().fKind == Token::Kind::TK_CASE) {
ASTNode::ID c = this->switchCase();
@@ -1057,7 +1057,7 @@
return ASTNode::ID::Invalid();
}
ASTNode::ID defaultCase = this->addChild(
- result, this->createNode(defaultStart.fOffset, ASTNode::Kind::kSwitchCase));
+ result, this->createNode(defaultStart.fLine, ASTNode::Kind::kSwitchCase));
this->createEmptyChild(defaultCase); // empty test to signify default case
while (this->peek().fKind != Token::Kind::TK_RBRACE) {
ASTNode::ID s = this->statement();
@@ -1083,7 +1083,7 @@
if (!this->expect(Token::Kind::TK_LPAREN, "'('")) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID result = this->createNode(start.fOffset, ASTNode::Kind::kFor);
+ ASTNode::ID result = this->createNode(start.fLine, ASTNode::Kind::kFor);
Token nextToken = this->peek();
if (nextToken.fKind == Token::Kind::TK_SEMICOLON) {
// An empty init-statement.
@@ -1137,7 +1137,7 @@
if (!this->expect(Token::Kind::TK_RETURN, "'return'", &start)) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID result = this->createNode(start.fOffset, ASTNode::Kind::kReturn);
+ ASTNode::ID result = this->createNode(start.fLine, ASTNode::Kind::kReturn);
if (this->peek().fKind != Token::Kind::TK_SEMICOLON) {
ASTNode::ID expression = this->expression();
if (!expression) {
@@ -1160,7 +1160,7 @@
if (!this->expect(Token::Kind::TK_SEMICOLON, "';'")) {
return ASTNode::ID::Invalid();
}
- return this->createNode(start.fOffset, ASTNode::Kind::kBreak);
+ return this->createNode(start.fLine, ASTNode::Kind::kBreak);
}
/* CONTINUE SEMICOLON */
@@ -1172,7 +1172,7 @@
if (!this->expect(Token::Kind::TK_SEMICOLON, "';'")) {
return ASTNode::ID::Invalid();
}
- return this->createNode(start.fOffset, ASTNode::Kind::kContinue);
+ return this->createNode(start.fLine, ASTNode::Kind::kContinue);
}
/* DISCARD SEMICOLON */
@@ -1184,7 +1184,7 @@
if (!this->expect(Token::Kind::TK_SEMICOLON, "';'")) {
return ASTNode::ID::Invalid();
}
- return this->createNode(start.fOffset, ASTNode::Kind::kDiscard);
+ return this->createNode(start.fLine, ASTNode::Kind::kDiscard);
}
/* LBRACE statement* RBRACE */
@@ -1197,7 +1197,7 @@
if (!depth.increase()) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID result = this->createNode(start.fOffset, ASTNode::Kind::kBlock);
+ ASTNode::ID result = this->createNode(start.fLine, ASTNode::Kind::kBlock);
for (;;) {
switch (this->peek().fKind) {
case Token::Kind::TK_RBRACE:
@@ -1245,7 +1245,7 @@
if (!right) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID newResult = this->createNode(t.fOffset, ASTNode::Kind::kBinary,
+ ASTNode::ID newResult = this->createNode(t.fLine, ASTNode::Kind::kBinary,
Operator(t.fKind));
getNode(newResult).addChild(result);
getNode(newResult).addChild(right);
@@ -1285,7 +1285,7 @@
if (!right) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID newResult = this->createNode(getNode(result).fOffset,
+ ASTNode::ID newResult = this->createNode(getNode(result).fLine,
ASTNode::Kind::kBinary, Operator(t.fKind));
getNode(newResult).addChild(result);
getNode(newResult).addChild(right);
@@ -1318,7 +1318,7 @@
if (!falseExpr) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID ternary = this->createNode(getNode(base).fOffset, ASTNode::Kind::kTernary);
+ ASTNode::ID ternary = this->createNode(getNode(base).fLine, ASTNode::Kind::kTernary);
getNode(ternary).addChild(base);
getNode(ternary).addChild(trueExpr);
getNode(ternary).addChild(falseExpr);
@@ -1345,7 +1345,7 @@
if (!right) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID newResult = this->createNode(getNode(result).fOffset, ASTNode::Kind::kBinary,
+ ASTNode::ID newResult = this->createNode(getNode(result).fLine, ASTNode::Kind::kBinary,
Operator(t.fKind));
getNode(newResult).addChild(result);
getNode(newResult).addChild(right);
@@ -1370,7 +1370,7 @@
if (!right) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID newResult = this->createNode(getNode(result).fOffset, ASTNode::Kind::kBinary,
+ ASTNode::ID newResult = this->createNode(getNode(result).fLine, ASTNode::Kind::kBinary,
Operator(t.fKind));
getNode(newResult).addChild(result);
getNode(newResult).addChild(right);
@@ -1395,7 +1395,7 @@
if (!right) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID newResult = this->createNode(getNode(result).fOffset, ASTNode::Kind::kBinary,
+ ASTNode::ID newResult = this->createNode(getNode(result).fLine, ASTNode::Kind::kBinary,
Operator(t.fKind));
getNode(newResult).addChild(result);
getNode(newResult).addChild(right);
@@ -1420,7 +1420,7 @@
if (!right) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID newResult = this->createNode(getNode(result).fOffset, ASTNode::Kind::kBinary,
+ ASTNode::ID newResult = this->createNode(getNode(result).fLine, ASTNode::Kind::kBinary,
Operator(t.fKind));
getNode(newResult).addChild(result);
getNode(newResult).addChild(right);
@@ -1445,7 +1445,7 @@
if (!right) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID newResult = this->createNode(getNode(result).fOffset, ASTNode::Kind::kBinary,
+ ASTNode::ID newResult = this->createNode(getNode(result).fLine, ASTNode::Kind::kBinary,
Operator(t.fKind));
getNode(newResult).addChild(result);
getNode(newResult).addChild(right);
@@ -1470,7 +1470,7 @@
if (!right) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID newResult = this->createNode(getNode(result).fOffset, ASTNode::Kind::kBinary,
+ ASTNode::ID newResult = this->createNode(getNode(result).fLine, ASTNode::Kind::kBinary,
Operator(t.fKind));
getNode(newResult).addChild(result);
getNode(newResult).addChild(right);
@@ -1498,7 +1498,7 @@
if (!right) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID newResult = this->createNode(getNode(result).fOffset,
+ ASTNode::ID newResult = this->createNode(getNode(result).fLine,
ASTNode::Kind::kBinary, Operator(t.fKind));
getNode(newResult).addChild(result);
getNode(newResult).addChild(right);
@@ -1532,7 +1532,7 @@
if (!right) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID newResult = this->createNode(getNode(result).fOffset,
+ ASTNode::ID newResult = this->createNode(getNode(result).fLine,
ASTNode::Kind::kBinary, Operator(t.fKind));
getNode(newResult).addChild(result);
getNode(newResult).addChild(right);
@@ -1564,7 +1564,7 @@
if (!right) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID newResult = this->createNode(getNode(result).fOffset,
+ ASTNode::ID newResult = this->createNode(getNode(result).fLine,
ASTNode::Kind::kBinary, Operator(t.fKind));
getNode(newResult).addChild(result);
getNode(newResult).addChild(right);
@@ -1596,7 +1596,7 @@
if (!right) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID newResult = this->createNode(getNode(result).fOffset,
+ ASTNode::ID newResult = this->createNode(getNode(result).fLine,
ASTNode::Kind::kBinary, Operator(t.fKind));
getNode(newResult).addChild(result);
getNode(newResult).addChild(right);
@@ -1629,7 +1629,7 @@
if (!right) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID newResult = this->createNode(getNode(result).fOffset,
+ ASTNode::ID newResult = this->createNode(getNode(result).fLine,
ASTNode::Kind::kBinary, Operator(t.fKind));
getNode(newResult).addChild(result);
getNode(newResult).addChild(right);
@@ -1660,7 +1660,7 @@
if (!expr) {
return ASTNode::ID::Invalid();
}
- ASTNode::ID result = this->createNode(t.fOffset, ASTNode::Kind::kPrefix,
+ ASTNode::ID result = this->createNode(t.fLine, ASTNode::Kind::kPrefix,
Operator(t.fKind));
getNode(result).addChild(expr);
return result;
@@ -1716,7 +1716,7 @@
switch (next.fKind) {
case Token::Kind::TK_LBRACKET: {
if (this->checkNext(Token::Kind::TK_RBRACKET)) {
- ASTNode::ID result = this->createNode(next.fOffset, ASTNode::Kind::kIndex);
+ ASTNode::ID result = this->createNode(next.fLine, ASTNode::Kind::kIndex);
getNode(result).addChild(base);
return result;
}
@@ -1725,16 +1725,16 @@
return ASTNode::ID::Invalid();
}
this->expect(Token::Kind::TK_RBRACKET, "']' to complete array access expression");
- ASTNode::ID result = this->createNode(next.fOffset, ASTNode::Kind::kIndex);
+ ASTNode::ID result = this->createNode(next.fLine, ASTNode::Kind::kIndex);
getNode(result).addChild(base);
getNode(result).addChild(e);
return result;
}
case Token::Kind::TK_DOT: {
- int offset = this->peek().fOffset;
+ int line = this->peek().fLine;
skstd::string_view text;
if (this->identifier(&text)) {
- ASTNode::ID result = this->createNode(offset, ASTNode::Kind::kField,
+ ASTNode::ID result = this->createNode(line, ASTNode::Kind::kField,
std::move(text));
getNode(result).addChild(base);
return result;
@@ -1761,12 +1761,12 @@
} else {
this->pushback(id);
}
- ASTNode::ID result = this->createNode(next.fOffset, ASTNode::Kind::kField, field);
+ ASTNode::ID result = this->createNode(next.fLine, ASTNode::Kind::kField, field);
getNode(result).addChild(base);
return result;
}
case Token::Kind::TK_LPAREN: {
- ASTNode::ID result = this->createNode(next.fOffset, ASTNode::Kind::kCall);
+ ASTNode::ID result = this->createNode(next.fLine, ASTNode::Kind::kCall);
getNode(result).addChild(base);
if (this->peek().fKind != Token::Kind::TK_RPAREN) {
for (;;) {
@@ -1785,7 +1785,7 @@
}
case Token::Kind::TK_PLUSPLUS: // fall through
case Token::Kind::TK_MINUSMINUS: {
- ASTNode::ID result = this->createNode(next.fOffset, ASTNode::Kind::kPostfix,
+ ASTNode::ID result = this->createNode(next.fLine, ASTNode::Kind::kPostfix,
Operator(next.fKind));
getNode(result).addChild(base);
return result;
@@ -1804,21 +1804,21 @@
case Token::Kind::TK_IDENTIFIER: {
skstd::string_view text;
if (this->identifier(&text)) {
- return this->createNode(t.fOffset, ASTNode::Kind::kIdentifier, std::move(text));
+ return this->createNode(t.fLine, ASTNode::Kind::kIdentifier, std::move(text));
}
break;
}
case Token::Kind::TK_INT_LITERAL: {
SKSL_INT i;
if (this->intLiteral(&i)) {
- return this->createNode(t.fOffset, ASTNode::Kind::kInt, i);
+ return this->createNode(t.fLine, ASTNode::Kind::kInt, i);
}
break;
}
case Token::Kind::TK_FLOAT_LITERAL: {
SKSL_FLOAT f;
if (this->floatLiteral(&f)) {
- return this->createNode(t.fOffset, ASTNode::Kind::kFloat, f);
+ return this->createNode(t.fLine, ASTNode::Kind::kFloat, f);
}
break;
}
@@ -1826,7 +1826,7 @@
case Token::Kind::TK_FALSE_LITERAL: {
bool b;
if (this->boolLiteral(&b)) {
- return this->createNode(t.fOffset, ASTNode::Kind::kBool, b);
+ return this->createNode(t.fLine, ASTNode::Kind::kBool, b);
}
break;
}
@@ -1845,7 +1845,7 @@
}
default:
this->nextToken();
- this->error(t.fOffset, "expected expression, but found '" + this->text(t) + "'");
+ this->error(t.fLine, "expected expression, but found '" + this->text(t) + "'");
}
return ASTNode::ID::Invalid();
}
diff --git a/src/sksl/SkSLParser.h b/src/sksl/SkSLParser.h
index 699984b..7fd43e1 100644
--- a/src/sksl/SkSLParser.h
+++ b/src/sksl/SkSLParser.h
@@ -104,7 +104,7 @@
bool expectIdentifier(Token* result);
void error(Token token, String msg);
- void error(int offset, String msg);
+ void error(int line, String msg);
/**
* Returns true if the 'name' identifier refers to a type name. For instance, isType("int") will
* always return true.
diff --git a/src/sksl/SkSLRehydrator.cpp b/src/sksl/SkSLRehydrator.cpp
index b9fab8b..c1225ea 100644
--- a/src/sksl/SkSLRehydrator.cpp
+++ b/src/sksl/SkSLRehydrator.cpp
@@ -162,7 +162,7 @@
const Type* returnType = this->type();
const FunctionDeclaration* result =
fSymbolTable->takeOwnershipOfSymbol(std::make_unique<FunctionDeclaration>(
- /*offset=*/-1,
+ /*line=*/-1,
this->modifiersPool().add(modifiers),
name,
std::move(parameters),
@@ -175,7 +175,7 @@
const Variable* owner = this->symbolRef<Variable>(Symbol::Kind::kVariable);
uint8_t index = this->readU8();
const Field* result = fSymbolTable->takeOwnershipOfSymbol(
- std::make_unique<Field>(/*offset=*/-1, owner, index));
+ std::make_unique<Field>(/*line=*/-1, owner, index));
return result;
}
case kStructType_Command: {
@@ -192,7 +192,7 @@
}
skstd::string_view nameChars(*fSymbolTable->takeOwnershipOfString(std::move(name)));
const Type* result = fSymbolTable->takeOwnershipOfSymbol(
- Type::MakeStructType(/*offset=*/-1, nameChars, std::move(fields)));
+ Type::MakeStructType(/*line=*/-1, nameChars, std::move(fields)));
this->addSymbol(id, result);
return result;
}
@@ -206,7 +206,7 @@
skstd::string_view name = this->readString();
const Symbol* origSymbol = this->symbol();
const SymbolAlias* symbolAlias = fSymbolTable->takeOwnershipOfSymbol(
- std::make_unique<SymbolAlias>(/*offset=*/-1, name, origSymbol));
+ std::make_unique<SymbolAlias>(/*line=*/-1, name, origSymbol));
this->addSymbol(id, symbolAlias);
return symbolAlias;
}
@@ -240,7 +240,7 @@
const Type* type = this->type();
Variable::Storage storage = (Variable::Storage) this->readU8();
const Variable* result = fSymbolTable->takeOwnershipOfSymbol(std::make_unique<Variable>(
- /*offset=*/-1, m, name, type, /*builtin=*/true, storage));
+ /*line=*/-1, m, name, type, /*builtin=*/true, storage));
this->addSymbol(id, result);
return result;
}
@@ -274,7 +274,7 @@
const FunctionDeclaration* decl = this->symbolRef<FunctionDeclaration>(
Symbol::Kind::kFunctionDeclaration);
std::unique_ptr<Statement> body = this->statement();
- auto result = FunctionDefinition::Convert(fContext, /*offset=*/-1, *decl,
+ auto result = FunctionDefinition::Convert(fContext, /*line=*/-1, *decl,
std::move(body), /*builtin=*/true);
decl->setDefinition(result.get());
return std::move(result);
@@ -285,7 +285,7 @@
skstd::string_view typeName = this->readString();
skstd::string_view instanceName = this->readString();
int arraySize = this->readS8();
- return std::make_unique<InterfaceBlock>(/*offset=*/-1, var->as<Variable>(), typeName,
+ return std::make_unique<InterfaceBlock>(/*line=*/-1, var->as<Variable>(), typeName,
instanceName, arraySize, nullptr);
}
case Rehydrator::kVarDeclarations_Command: {
@@ -295,7 +295,7 @@
case Rehydrator::kStructDefinition_Command: {
const Symbol* type = this->symbol();
SkASSERT(type && type->is<Type>());
- return std::make_unique<StructDefinition>(/*offset=*/-1, type->as<Type>());
+ return std::make_unique<StructDefinition>(/*line=*/-1, type->as<Type>());
}
case Rehydrator::kElementsComplete_Command:
return nullptr;
@@ -317,14 +317,14 @@
statements.push_back(this->statement());
}
bool isScope = this->readU8();
- return Block::Make(/*offset=*/-1, std::move(statements), fSymbolTable, isScope);
+ return Block::Make(/*line=*/-1, std::move(statements), fSymbolTable, isScope);
}
case Rehydrator::kBreak_Command:
- return BreakStatement::Make(/*offset=*/-1);
+ return BreakStatement::Make(/*line=*/-1);
case Rehydrator::kContinue_Command:
- return ContinueStatement::Make(/*offset=*/-1);
+ return ContinueStatement::Make(/*line=*/-1);
case Rehydrator::kDiscard_Command:
- return DiscardStatement::Make(/*offset=*/-1);
+ return DiscardStatement::Make(/*line=*/-1);
case Rehydrator::kDo_Command: {
std::unique_ptr<Statement> stmt = this->statement();
std::unique_ptr<Expression> expr = this->expression();
@@ -340,7 +340,7 @@
std::unique_ptr<Expression> next = this->expression();
std::unique_ptr<Statement> body = this->statement();
std::shared_ptr<SymbolTable> symbols = this->symbolTable();
- return ForStatement::Make(fContext, /*offset=*/-1, std::move(initializer),
+ return ForStatement::Make(fContext, /*line=*/-1, std::move(initializer),
std::move(test), std::move(next), std::move(body),
/*unrollInfo=*/nullptr, std::move(symbols));
}
@@ -349,7 +349,7 @@
std::unique_ptr<Expression> test = this->expression();
std::unique_ptr<Statement> ifTrue = this->statement();
std::unique_ptr<Statement> ifFalse = this->statement();
- return IfStatement::Make(fContext, /*offset=*/-1, isStatic, std::move(test),
+ return IfStatement::Make(fContext, /*line=*/-1, isStatic, std::move(test),
std::move(ifTrue), std::move(ifFalse));
}
case Rehydrator::kInlineMarker_Command: {
@@ -359,7 +359,7 @@
}
case Rehydrator::kReturn_Command: {
std::unique_ptr<Expression> expr = this->expression();
- return ReturnStatement::Make(/*offset=*/-1, std::move(expr));
+ return ReturnStatement::Make(/*line=*/-1, std::move(expr));
}
case Rehydrator::kSwitch_Command: {
bool isStatic = this->readU8();
@@ -371,10 +371,10 @@
for (int i = 0; i < caseCount; ++i) {
std::unique_ptr<Expression> value = this->expression();
std::unique_ptr<Statement> statement = this->statement();
- cases.push_back(std::make_unique<SwitchCase>(/*offset=*/-1, std::move(value),
+ cases.push_back(std::make_unique<SwitchCase>(/*line=*/-1, std::move(value),
std::move(statement)));
}
- return SwitchStatement::Make(fContext, /*offset=*/-1, isStatic, std::move(expr),
+ return SwitchStatement::Make(fContext, /*line=*/-1, isStatic, std::move(expr),
std::move(cases), fSymbolTable);
}
case Rehydrator::kVarDeclaration_Command: {
@@ -414,52 +414,52 @@
}
case Rehydrator::kBoolLiteral_Command: {
bool value = this->readU8();
- return Literal::MakeBool(fContext, /*offset=*/-1, value);
+ return Literal::MakeBool(fContext, /*line=*/-1, value);
}
case Rehydrator::kConstructorArray_Command: {
const Type* type = this->type();
- return ConstructorArray::Make(fContext, /*offset=*/-1, *type, this->expressionArray());
+ return ConstructorArray::Make(fContext, /*line=*/-1, *type, this->expressionArray());
}
case Rehydrator::kConstructorCompound_Command: {
const Type* type = this->type();
- return ConstructorCompound::Make(fContext, /*offset=*/-1, *type,
+ return ConstructorCompound::Make(fContext, /*line=*/-1, *type,
this->expressionArray());
}
case Rehydrator::kConstructorDiagonalMatrix_Command: {
const Type* type = this->type();
ExpressionArray args = this->expressionArray();
SkASSERT(args.size() == 1);
- return ConstructorDiagonalMatrix::Make(fContext, /*offset=*/-1, *type,
+ return ConstructorDiagonalMatrix::Make(fContext, /*line=*/-1, *type,
std::move(args[0]));
}
case Rehydrator::kConstructorMatrixResize_Command: {
const Type* type = this->type();
ExpressionArray args = this->expressionArray();
SkASSERT(args.size() == 1);
- return ConstructorMatrixResize::Make(fContext, /*offset=*/-1, *type,
+ return ConstructorMatrixResize::Make(fContext, /*line=*/-1, *type,
std::move(args[0]));
}
case Rehydrator::kConstructorScalarCast_Command: {
const Type* type = this->type();
ExpressionArray args = this->expressionArray();
SkASSERT(args.size() == 1);
- return ConstructorScalarCast::Make(fContext, /*offset=*/-1, *type, std::move(args[0]));
+ return ConstructorScalarCast::Make(fContext, /*line=*/-1, *type, std::move(args[0]));
}
case Rehydrator::kConstructorSplat_Command: {
const Type* type = this->type();
ExpressionArray args = this->expressionArray();
SkASSERT(args.size() == 1);
- return ConstructorSplat::Make(fContext, /*offset=*/-1, *type, std::move(args[0]));
+ return ConstructorSplat::Make(fContext, /*line=*/-1, *type, std::move(args[0]));
}
case Rehydrator::kConstructorStruct_Command: {
const Type* type = this->type();
- return ConstructorStruct::Make(fContext, /*offset=*/-1, *type, this->expressionArray());
+ return ConstructorStruct::Make(fContext, /*line=*/-1, *type, this->expressionArray());
}
case Rehydrator::kConstructorCompoundCast_Command: {
const Type* type = this->type();
ExpressionArray args = this->expressionArray();
SkASSERT(args.size() == 1);
- return ConstructorCompoundCast::Make(fContext,/*offset=*/-1, *type, std::move(args[0]));
+ return ConstructorCompoundCast::Make(fContext,/*line=*/-1, *type, std::move(args[0]));
}
case Rehydrator::kFieldAccess_Command: {
std::unique_ptr<Expression> base = this->expression();
@@ -472,14 +472,14 @@
int32_t floatBits = this->readS32();
float value;
memcpy(&value, &floatBits, sizeof(value));
- return Literal::MakeFloat(/*offset=*/-1, value, type);
+ return Literal::MakeFloat(/*line=*/-1, value, type);
}
case Rehydrator::kFunctionCall_Command: {
const Type* type = this->type();
const FunctionDeclaration* f = this->symbolRef<FunctionDeclaration>(
Symbol::Kind::kFunctionDeclaration);
ExpressionArray args = this->expressionArray();
- return FunctionCall::Make(fContext, /*offset=*/-1, type, *f, std::move(args));
+ return FunctionCall::Make(fContext, /*line=*/-1, type, *f, std::move(args));
}
case Rehydrator::kIndex_Command: {
std::unique_ptr<Expression> base = this->expression();
@@ -489,7 +489,7 @@
case Rehydrator::kIntLiteral_Command: {
const Type* type = this->type();
int value = this->readS32();
- return Literal::MakeInt(/*offset=*/-1, value, type);
+ return Literal::MakeInt(/*line=*/-1, value, type);
}
case Rehydrator::kPostfix_Command: {
Token::Kind op = (Token::Kind) this->readU8();
@@ -503,7 +503,7 @@
}
case Rehydrator::kSetting_Command: {
String name(this->readString());
- return Setting::Convert(fContext, /*offset=*/-1, name);
+ return Setting::Convert(fContext, /*line=*/-1, name);
}
case Rehydrator::kSwizzle_Command: {
std::unique_ptr<Expression> base = this->expression();
@@ -524,7 +524,7 @@
case Rehydrator::kVariableReference_Command: {
const Variable* var = this->symbolRef<Variable>(Symbol::Kind::kVariable);
VariableReference::RefKind refKind = (VariableReference::RefKind) this->readU8();
- return VariableReference::Make(/*offset=*/-1, var, refKind);
+ return VariableReference::Make(/*line=*/-1, var, refKind);
}
case Rehydrator::kVoid_Command:
return nullptr;
diff --git a/src/sksl/codegen/SkSLGLSLCodeGenerator.cpp b/src/sksl/codegen/SkSLGLSLCodeGenerator.cpp
index dc25460..53aa8a0 100644
--- a/src/sksl/codegen/SkSLGLSLCodeGenerator.cpp
+++ b/src/sksl/codegen/SkSLGLSLCodeGenerator.cpp
@@ -780,7 +780,7 @@
if (this->caps().fbFetchSupport()) {
this->write(this->caps().fbFetchColorName());
} else {
- fContext.fErrors->error(ref.fOffset,
+ fContext.fErrors->error(ref.fLine,
"sk_LastFragColor requires framebuffer fetch support");
}
break;
@@ -909,12 +909,12 @@
if (b.getOperator().kind() == Token::Kind::TK_LOGICALAND) {
this->writeExpression(*b.right(), Precedence::kTernary);
} else {
- Literal boolTrue(/*offset=*/-1, /*value=*/1, fContext.fTypes.fBool.get());
+ Literal boolTrue(/*line=*/-1, /*value=*/1, fContext.fTypes.fBool.get());
this->writeLiteral(boolTrue);
}
this->write(" : ");
if (b.getOperator().kind() == Token::Kind::TK_LOGICALAND) {
- Literal boolFalse(/*offset=*/-1, /*value=*/0, fContext.fTypes.fBool.get());
+ Literal boolFalse(/*line=*/-1, /*value=*/0, fContext.fTypes.fBool.get());
this->writeLiteral(boolFalse);
} else {
this->writeExpression(*b.right(), Precedence::kTernary);
@@ -1284,8 +1284,8 @@
if (f.test()) {
if (this->caps().addAndTrueToLoopCondition()) {
std::unique_ptr<Expression> and_true(new BinaryExpression(
- /*offset=*/-1, f.test()->clone(), Token::Kind::TK_LOGICALAND,
- Literal::MakeBool(fContext, /*offset=*/-1, /*value=*/true),
+ /*line=*/-1, f.test()->clone(), Token::Kind::TK_LOGICALAND,
+ Literal::MakeBool(fContext, /*line=*/-1, /*value=*/true),
fContext.fTypes.fBool.get()));
this->writeExpression(*and_true, Precedence::kTopLevel);
} else {
diff --git a/src/sksl/codegen/SkSLMetalCodeGenerator.cpp b/src/sksl/codegen/SkSLMetalCodeGenerator.cpp
index c0cd482..9b6b7d2 100644
--- a/src/sksl/codegen/SkSLMetalCodeGenerator.cpp
+++ b/src/sksl/codegen/SkSLMetalCodeGenerator.cpp
@@ -110,7 +110,7 @@
const Type& type = s.type();
this->writeLine("struct " + type.name() + " {");
fIndentation++;
- this->writeFields(type.fields(), type.fOffset);
+ this->writeFields(type.fields(), type.fLine);
fIndentation--;
this->writeLine("};");
}
@@ -1131,7 +1131,7 @@
} else if (c.type().isMatrix()) {
this->writeConstructorCompoundMatrix(c, parentPrecedence);
} else {
- fContext.fErrors->error(c.fOffset, "unsupported compound constructor");
+ fContext.fErrors->error(c.fLine, "unsupported compound constructor");
}
}
@@ -1798,13 +1798,13 @@
const VarDeclaration& var = decls.declaration()->as<VarDeclaration>();
if (var.var().type().typeKind() == Type::TypeKind::kSampler) {
if (var.var().modifiers().fLayout.fBinding < 0) {
- fContext.fErrors->error(decls.fOffset,
+ fContext.fErrors->error(decls.fLine,
"Metal samplers must have 'layout(binding=...)'");
return false;
}
if (var.var().type().dimensions() != SpvDim2D) {
// Not yet implemented--Skia currently only uses 2D textures.
- fContext.fErrors->error(decls.fOffset, "Unsupported texture dimensions");
+ fContext.fErrors->error(decls.fLine, "Unsupported texture dimensions");
return false;
}
this->write(", texture2d<float> ");
@@ -1960,7 +1960,7 @@
structType = &structType->componentType();
}
fIndentation++;
- this->writeFields(structType->fields(), structType->fOffset, &intf);
+ this->writeFields(structType->fields(), structType->fLine, &intf);
if (fProgram.fInputs.fUseFlipRTUniform) {
this->writeLine("float2 " SKSL_RTFLIP_NAME ";");
}
@@ -1982,7 +1982,7 @@
this->writeLine(";");
}
-void MetalCodeGenerator::writeFields(const std::vector<Type::Field>& fields, int parentOffset,
+void MetalCodeGenerator::writeFields(const std::vector<Type::Field>& fields, int parentLine,
const InterfaceBlock* parentIntf) {
MemoryLayout memoryLayout(MemoryLayout::kMetal_Standard);
int currentOffset = 0;
@@ -1990,13 +1990,13 @@
int fieldOffset = field.fModifiers.fLayout.fOffset;
const Type* fieldType = field.fType;
if (!MemoryLayout::LayoutIsSupported(*fieldType)) {
- fContext.fErrors->error(parentOffset, "type '" + fieldType->name() +
- "' is not permitted here");
+ fContext.fErrors->error(parentLine, "type '" + fieldType->name() +
+ "' is not permitted here");
return;
}
if (fieldOffset != -1) {
if (currentOffset > fieldOffset) {
- fContext.fErrors->error(parentOffset,
+ fContext.fErrors->error(parentLine,
"offset of field '" + field.fName + "' must be at least " +
to_string((int) currentOffset));
return;
@@ -2010,7 +2010,7 @@
}
int alignment = memoryLayout.alignment(*fieldType);
if (fieldOffset % alignment) {
- fContext.fErrors->error(parentOffset,
+ fContext.fErrors->error(parentLine,
"offset of field '" + field.fName + "' must be a multiple of " +
to_string((int) alignment));
return;
@@ -2018,7 +2018,7 @@
}
size_t fieldSize = memoryLayout.size(*fieldType);
if (fieldSize > static_cast<size_t>(std::numeric_limits<int>::max() - currentOffset)) {
- fContext.fErrors->error(parentOffset, "field offset overflow");
+ fContext.fErrors->error(parentLine, "field offset overflow");
return;
}
currentOffset += fieldSize;
@@ -2213,7 +2213,7 @@
this->writeExpression(*r.expression(), Precedence::kTopLevel);
this->writeLine(";");
} else {
- fContext.fErrors->error(r.fOffset,
+ fContext.fErrors->error(r.fLine,
"Metal does not support returning '" +
r.expression()->type().description() + "' from main()");
}
@@ -2249,7 +2249,7 @@
this->write("struct Uniforms {\n");
fUniformBuffer = uniformSet;
} else if (uniformSet != fUniformBuffer) {
- fContext.fErrors->error(decls.fOffset,
+ fContext.fErrors->error(decls.fLine,
"Metal backend requires all uniforms to have the same "
"'layout(set=...)'");
}
@@ -2314,7 +2314,7 @@
int location = var.modifiers().fLayout.fLocation;
if (location < 0) {
- fContext.fErrors->error(var.fOffset,
+ fContext.fErrors->error(var.fLine,
"Metal out variables must have 'layout(location=...)'");
} else if (fProgram.fConfig->fKind == ProgramKind::kVertex) {
this->write(" [[user(locn" + to_string(location) + ")]]");
diff --git a/src/sksl/codegen/SkSLMetalCodeGenerator.h b/src/sksl/codegen/SkSLMetalCodeGenerator.h
index e799dfb..1668e69 100644
--- a/src/sksl/codegen/SkSLMetalCodeGenerator.h
+++ b/src/sksl/codegen/SkSLMetalCodeGenerator.h
@@ -97,7 +97,7 @@
void writeStructDefinitions();
- void writeFields(const std::vector<Type::Field>& fields, int parentOffset,
+ void writeFields(const std::vector<Type::Field>& fields, int parentLine,
const InterfaceBlock* parentIntf = nullptr);
int size(const Type* type, bool isPacked) const;
diff --git a/src/sksl/codegen/SkSLSPIRVCodeGenerator.cpp b/src/sksl/codegen/SkSLSPIRVCodeGenerator.cpp
index 47e80a0..aeae383 100644
--- a/src/sksl/codegen/SkSLSPIRVCodeGenerator.cpp
+++ b/src/sksl/codegen/SkSLSPIRVCodeGenerator.cpp
@@ -447,7 +447,7 @@
for (int32_t i = 0; i < (int32_t) type.fields().size(); i++) {
const Type::Field& field = type.fields()[i];
if (!MemoryLayout::LayoutIsSupported(*field.fType)) {
- fContext.fErrors->error(type.fOffset, "type '" + field.fType->name() +
+ fContext.fErrors->error(type.fLine, "type '" + field.fType->name() +
"' is not permitted here");
return;
}
@@ -456,12 +456,12 @@
const Layout& fieldLayout = field.fModifiers.fLayout;
if (fieldLayout.fOffset >= 0) {
if (fieldLayout.fOffset < (int) offset) {
- fContext.fErrors->error(type.fOffset,
+ fContext.fErrors->error(type.fLine,
"offset of field '" + field.fName + "' must be at "
"least " + to_string((int) offset));
}
if (fieldLayout.fOffset % alignment) {
- fContext.fErrors->error(type.fOffset,
+ fContext.fErrors->error(type.fLine,
"offset of field '" + field.fName + "' must be a multiple"
" of " + to_string((int) alignment));
}
@@ -590,13 +590,13 @@
break;
case Type::TypeKind::kArray: {
if (!MemoryLayout::LayoutIsSupported(*type)) {
- fContext.fErrors->error(type->fOffset,
+ fContext.fErrors->error(type->fLine,
"type '" + type->name() + "' is not permitted here");
return this->nextId(nullptr);
}
if (type->columns() > 0) {
SpvId typeId = this->getType(type->componentType(), layout);
- Literal countLiteral(/*offset=*/-1, type->columns(),
+ Literal countLiteral(/*line=*/-1, type->columns(),
fContext.fTypes.fInt.get());
SpvId countId = this->writeLiteral(countLiteral);
this->writeInstruction(SpvOpTypeArray, result, typeId, countId,
@@ -606,7 +606,7 @@
fDecorationBuffer);
} else {
// We shouldn't have any runtime-sized arrays right now
- fContext.fErrors->error(type->fOffset,
+ fContext.fErrors->error(type->fLine,
"runtime-sized arrays are not supported in SPIR-V");
this->writeInstruction(SpvOpTypeRuntimeArray, result,
this->getType(type->componentType(), layout),
@@ -789,8 +789,7 @@
const FunctionDeclaration& function = c.function();
auto intrinsic = fIntrinsicMap.find(function.intrinsicKind());
if (intrinsic == fIntrinsicMap.end()) {
- fContext.fErrors->error(c.fOffset, "unsupported intrinsic '" + function.description() +
- "'");
+ fContext.fErrors->error(c.fLine, "unsupported intrinsic '" + function.description() + "'");
return -1;
}
int32_t intrinsicId;
@@ -876,8 +875,8 @@
case kSpecial_IntrinsicOpcodeKind:
return this->writeSpecialIntrinsic(c, (SpecialIntrinsic) intrinsicId, out);
default:
- fContext.fErrors->error(c.fOffset, "unsupported intrinsic '" + function.description() +
- "'");
+ fContext.fErrors->error(c.fLine, "unsupported intrinsic '" + function.description() +
+ "'");
return -1;
}
}
@@ -984,9 +983,9 @@
SpvId img = this->writeExpression(*arguments[0], out);
ExpressionArray args;
args.reserve_back(2);
- args.push_back(Literal::MakeInt(fContext, /*offset=*/-1, /*value=*/0));
- args.push_back(Literal::MakeInt(fContext, /*offset=*/-1, /*value=*/0));
- ConstructorCompound ctor(/*offset=*/-1, *fContext.fTypes.fInt2, std::move(args));
+ args.push_back(Literal::MakeInt(fContext, /*line=*/-1, /*value=*/0));
+ args.push_back(Literal::MakeInt(fContext, /*line=*/-1, /*value=*/0));
+ ConstructorCompound ctor(/*line=*/-1, *fContext.fTypes.fInt2, std::move(args));
SpvId coords = this->writeConstantVector(ctor);
if (arguments.size() == 1) {
this->writeInstruction(SpvOpImageRead,
@@ -1051,7 +1050,7 @@
} else {
SkASSERT(arguments.size() == 2);
if (fProgram.fConfig->fSettings.fSharpenTextures) {
- Literal lodBias(/*offset=*/-1, /*value=*/-0.5, fContext.fTypes.fFloat.get());
+ Literal lodBias(/*line=*/-1, /*value=*/-0.5, fContext.fTypes.fFloat.get());
this->writeInstruction(op, type, result, sampler, uv,
SpvImageOperandsBiasMask,
this->writeLiteral(lodBias),
@@ -1091,9 +1090,9 @@
this->writeWord(this->getType(callType), out);
this->writeWord(result, out);
this->writeWord(fn, out);
- this->addRTFlipUniform(c.fOffset);
+ this->addRTFlipUniform(c.fLine);
using namespace dsl;
- DSLExpression rtFlip(DSLWriter::IRGenerator().convertIdentifier(/*offset=*/-1,
+ DSLExpression rtFlip(DSLWriter::IRGenerator().convertIdentifier(/*line=*/-1,
SKSL_RTFLIP_NAME));
SpvId rtFlipY = this->vectorize(*rtFlip.y().release(), callType.columns(), out);
SpvId flipped = this->nextId(&callType);
@@ -1144,8 +1143,8 @@
ExpressionArray finalArgs;
finalArgs.reserve_back(3);
finalArgs.push_back(arguments[0]->clone());
- finalArgs.push_back(Literal::MakeFloat(fContext, /*offset=*/-1, /*value=*/0));
- finalArgs.push_back(Literal::MakeFloat(fContext, /*offset=*/-1, /*value=*/1));
+ finalArgs.push_back(Literal::MakeFloat(fContext, /*line=*/-1, /*value=*/0));
+ finalArgs.push_back(Literal::MakeFloat(fContext, /*line=*/-1, /*value=*/1));
std::vector<SpvId> spvArgs = this->vectorize(finalArgs, out);
this->writeGLSLExtendedInstruction(callType, result, GLSLstd450FClamp, GLSLstd450SClamp,
GLSLstd450UClamp, spvArgs, out);
@@ -1232,8 +1231,8 @@
const ExpressionArray& arguments = c.arguments();
const auto& entry = fFunctionMap.find(&function);
if (entry == fFunctionMap.end()) {
- fContext.fErrors->error(c.fOffset, "function '" + function.description() +
- "' is not defined");
+ fContext.fErrors->error(c.fLine, "function '" + function.description() +
+ "' is not defined");
return -1;
}
// Temp variables are used to write back out-parameters after the function call is complete.
@@ -1333,9 +1332,9 @@
SpvId result = this->nextId(&outputType);
if (inputType.isBoolean()) {
// Use OpSelect to convert the boolean argument to a literal 1.0 or 0.0.
- Literal one(/*offset=*/-1, /*value=*/1, fContext.fTypes.fFloat.get());
+ Literal one(/*line=*/-1, /*value=*/1, fContext.fTypes.fFloat.get());
const SpvId oneID = this->writeLiteral(one);
- Literal zero(/*offset=*/-1, /*value=*/0, fContext.fTypes.fFloat.get());
+ Literal zero(/*line=*/-1, /*value=*/0, fContext.fTypes.fFloat.get());
const SpvId zeroID = this->writeLiteral(zero);
this->writeInstruction(SpvOpSelect, this->getType(outputType), result,
inputId, oneID, zeroID, out);
@@ -1369,9 +1368,9 @@
SpvId result = this->nextId(&outputType);
if (inputType.isBoolean()) {
// Use OpSelect to convert the boolean argument to a literal 1 or 0.
- Literal one(/*offset=*/-1, /*value=*/1, fContext.fTypes.fInt.get());
+ Literal one(/*line=*/-1, /*value=*/1, fContext.fTypes.fInt.get());
const SpvId oneID = this->writeLiteral(one);
- Literal zero(/*offset=*/-1, /*value=*/0, fContext.fTypes.fInt.get());
+ Literal zero(/*line=*/-1, /*value=*/0, fContext.fTypes.fInt.get());
const SpvId zeroID = this->writeLiteral(zero);
this->writeInstruction(SpvOpSelect, this->getType(outputType), result,
inputId, oneID, zeroID, out);
@@ -1406,9 +1405,9 @@
SpvId result = this->nextId(&outputType);
if (inputType.isBoolean()) {
// Use OpSelect to convert the boolean argument to a literal 1u or 0u.
- Literal one(/*offset=*/-1, /*value=*/1, fContext.fTypes.fUInt.get());
+ Literal one(/*line=*/-1, /*value=*/1, fContext.fTypes.fUInt.get());
const SpvId oneID = this->writeLiteral(one);
- Literal zero(/*offset=*/-1, /*value=*/0, fContext.fTypes.fUInt.get());
+ Literal zero(/*line=*/-1, /*value=*/0, fContext.fTypes.fUInt.get());
const SpvId zeroID = this->writeLiteral(zero);
this->writeInstruction(SpvOpSelect, this->getType(outputType), result,
inputId, oneID, zeroID, out);
@@ -1443,19 +1442,19 @@
SpvId result = this->nextId(nullptr);
if (inputType.isSigned()) {
// Synthesize a boolean result by comparing the input against a signed zero literal.
- Literal zero(/*offset=*/-1, /*value=*/0, fContext.fTypes.fInt.get());
+ Literal zero(/*line=*/-1, /*value=*/0, fContext.fTypes.fInt.get());
const SpvId zeroID = this->writeLiteral(zero);
this->writeInstruction(SpvOpINotEqual, this->getType(outputType), result,
inputId, zeroID, out);
} else if (inputType.isUnsigned()) {
// Synthesize a boolean result by comparing the input against an unsigned zero literal.
- Literal zero(/*offset=*/-1, /*value=*/0, fContext.fTypes.fUInt.get());
+ Literal zero(/*line=*/-1, /*value=*/0, fContext.fTypes.fUInt.get());
const SpvId zeroID = this->writeLiteral(zero);
this->writeInstruction(SpvOpINotEqual, this->getType(outputType), result,
inputId, zeroID, out);
} else if (inputType.isFloat()) {
// Synthesize a boolean result by comparing the input against a floating-point zero literal.
- Literal zero(/*offset=*/-1, /*value=*/0, fContext.fTypes.fFloat.get());
+ Literal zero(/*line=*/-1, /*value=*/0, fContext.fTypes.fFloat.get());
const SpvId zeroID = this->writeLiteral(zero);
this->writeInstruction(SpvOpFUnordNotEqual, this->getType(outputType), result,
inputId, zeroID, out);
@@ -1468,7 +1467,7 @@
void SPIRVCodeGenerator::writeUniformScaleMatrix(SpvId id, SpvId diagonal, const Type& type,
OutputStream& out) {
- Literal zero(/*offset=*/-1, /*value=*/0, fContext.fTypes.fFloat.get());
+ Literal zero(/*line=*/-1, /*value=*/0, fContext.fTypes.fFloat.get());
SpvId zeroId = this->writeLiteral(zero);
std::vector<SpvId> columnIds;
columnIds.reserve(type.columns());
@@ -1507,9 +1506,9 @@
dstType.rows(),
1));
SkASSERT(dstType.componentType().isFloat());
- Literal zero(/*offset=*/-1, /*value=*/0.0, &dstType.componentType());
+ Literal zero(/*line=*/-1, /*value=*/0.0, &dstType.componentType());
const SpvId zeroId = this->writeLiteral(zero);
- Literal one(/*offset=*/-1, /*value=*/1.0, &dstType.componentType());
+ Literal one(/*line=*/-1, /*value=*/1.0, &dstType.componentType());
const SpvId oneId = this->writeLiteral(one);
SpvId columns[4];
@@ -1864,7 +1863,7 @@
case Expression::Kind::kFieldAccess: {
const FieldAccess& fieldExpr = expr.as<FieldAccess>();
chain = this->getAccessChain(*fieldExpr.base(), out);
- Literal index(/*offset=*/-1, fieldExpr.fieldIndex(), fContext.fTypes.fInt.get());
+ Literal index(/*line=*/-1, fieldExpr.fieldIndex(), fContext.fTypes.fInt.get());
chain.push_back(this->writeLiteral(index));
break;
}
@@ -2013,7 +2012,7 @@
const Variable& var = *expr.as<VariableReference>().variable();
int uniformIdx = this->findUniformFieldIndex(var);
if (uniformIdx >= 0) {
- Literal uniformIdxLiteral{/*offset=*/-1, (double)uniformIdx,
+ Literal uniformIdxLiteral{/*line=*/-1, (double)uniformIdx,
fContext.fTypes.fInt.get()};
SpvId memberId = this->nextId(nullptr);
SpvId typeId = this->getPointerType(type, SpvStorageClassUniform);
@@ -2052,12 +2051,12 @@
}
SpvId base = lvalue->getPointer();
if (base == (SpvId) -1) {
- fContext.fErrors->error(swizzle.fOffset, "unable to retrieve lvalue from swizzle");
+ fContext.fErrors->error(swizzle.fLine, "unable to retrieve lvalue from swizzle");
}
if (swizzle.components().size() == 1) {
SpvId member = this->nextId(nullptr);
SpvId typeId = this->getPointerType(type, get_storage_class(*swizzle.base()));
- Literal index(/*offset=*/-1, swizzle.components()[0], fContext.fTypes.fInt.get());
+ Literal index(/*line=*/-1, swizzle.components()[0], fContext.fTypes.fInt.get());
SpvId indexId = this->writeLiteral(index);
this->writeInstruction(SpvOpAccessChain, typeId, member, base, indexId, out);
return std::make_unique<PointerLValue>(*this,
@@ -2105,7 +2104,7 @@
// Handle inserting use of uniform to flip y when referencing sk_FragCoord.
if (variable->modifiers().fLayout.fBuiltin == SK_FRAGCOORD_BUILTIN) {
- this->addRTFlipUniform(ref.fOffset);
+ this->addRTFlipUniform(ref.fLine);
// Use sk_RTAdjust to compute the flipped coordinate
using namespace dsl;
const char* DEVICE_COORDS_NAME = "__device_FragCoords";
@@ -2113,13 +2112,13 @@
// Use a uniform to flip the Y coordinate. The new expression will be written in
// terms of __device_FragCoords, which is a fake variable that means "access the
// underlying fragcoords directly without flipping it".
- DSLExpression rtFlip(DSLWriter::IRGenerator().convertIdentifier(/*offset=*/-1,
+ DSLExpression rtFlip(DSLWriter::IRGenerator().convertIdentifier(/*line=*/-1,
SKSL_RTFLIP_NAME));
if (!symbols[DEVICE_COORDS_NAME]) {
AutoAttachPoolToThread attach(fProgram.fPool.get());
Modifiers modifiers;
modifiers.fLayout.fBuiltin = DEVICE_FRAGCOORDS_BUILTIN;
- auto coordsVar = std::make_unique<Variable>(/*offset=*/-1,
+ auto coordsVar = std::make_unique<Variable>(/*line=*/-1,
fContext.fModifiersPool->add(modifiers),
DEVICE_COORDS_NAME,
fContext.fTypes.fFloat4.get(),
@@ -2141,20 +2140,20 @@
// Handle flipping sk_Clockwise.
if (variable->modifiers().fLayout.fBuiltin == SK_CLOCKWISE_BUILTIN) {
- this->addRTFlipUniform(ref.fOffset);
+ this->addRTFlipUniform(ref.fLine);
using namespace dsl;
const char* DEVICE_CLOCKWISE_NAME = "__device_Clockwise";
SymbolTable& symbols = *dsl::DSLWriter::SymbolTable();
// Use a uniform to flip the Y coordinate. The new expression will be written in
// terms of __device_Clockwise, which is a fake variable that means "access the
// underlying FrontFacing directly".
- DSLExpression rtFlip(DSLWriter::IRGenerator().convertIdentifier(/*offset=*/-1,
+ DSLExpression rtFlip(DSLWriter::IRGenerator().convertIdentifier(/*line=*/-1,
SKSL_RTFLIP_NAME));
if (!symbols[DEVICE_CLOCKWISE_NAME]) {
AutoAttachPoolToThread attach(fProgram.fPool.get());
Modifiers modifiers;
modifiers.fLayout.fBuiltin = DEVICE_CLOCKWISE_BUILTIN;
- auto clockwiseVar = std::make_unique<Variable>(/*offset=*/-1,
+ auto clockwiseVar = std::make_unique<Variable>(/*line=*/-1,
fContext.fModifiersPool->add(modifiers),
DEVICE_CLOCKWISE_NAME,
fContext.fTypes.fBool.get(),
@@ -2225,7 +2224,7 @@
} else if (is_bool(fContext, operandType)) {
this->writeInstruction(ifBool, this->getType(resultType), result, lhs, rhs, out);
} else {
- fContext.fErrors->error(operandType.fOffset,
+ fContext.fErrors->error(operandType.fLine,
"unsupported operand for binary expression: " + operandType.description());
}
return result;
@@ -2297,12 +2296,12 @@
static std::unique_ptr<Expression> create_literal_1(const Context& context, const Type& type) {
SkASSERT(type.isInteger() || type.isFloat());
- return Literal::Make(/*offset=*/-1, /*value=*/1.0, &type);
+ return Literal::Make(/*line=*/-1, /*value=*/1.0, &type);
}
SpvId SPIRVCodeGenerator::writeReciprocal(const Type& type, SpvId value, OutputStream& out) {
SkASSERT(type.isFloat());
- SpvId one = this->writeLiteral({/*offset=*/-1, /*value=*/1, &type});
+ SpvId one = this->writeLiteral({/*line=*/-1, /*value=*/1, &type});
SpvId reciprocal = this->nextId(&type);
this->writeInstruction(SpvOpFDiv, this->getType(type), reciprocal, one, value, out);
return reciprocal;
@@ -2436,7 +2435,7 @@
resultType, out);
}
} else {
- fContext.fErrors->error(leftType.fOffset, "unsupported mixed-type expression");
+ fContext.fErrors->error(leftType.fLine, "unsupported mixed-type expression");
return -1;
}
} else {
@@ -2707,7 +2706,7 @@
// This converts `expr / 2` into `expr * 0.5`
// This improves codegen, especially for certain types of divides (e.g. vector/scalar).
op = Operator(Token::Kind::TK_STAR);
- Literal reciprocal{right->fOffset, 1.0f / rhsValue, &right->type()};
+ Literal reciprocal{right->fLine, 1.0f / rhsValue, &right->type()};
rhs = this->writeExpression(reciprocal, out);
} else {
// Write the right-hand side expression normally.
@@ -2724,7 +2723,7 @@
SpvId SPIRVCodeGenerator::writeLogicalAnd(const Expression& left, const Expression& right,
OutputStream& out) {
- Literal falseLiteral(/*offset=*/-1, /*value=*/false, fContext.fTypes.fBool.get());
+ Literal falseLiteral(/*line=*/-1, /*value=*/false, fContext.fTypes.fBool.get());
SpvId falseConstant = this->writeLiteral(falseLiteral);
SpvId lhs = this->writeExpression(left, out);
SpvId rhsLabel = this->nextId(nullptr);
@@ -2745,7 +2744,7 @@
SpvId SPIRVCodeGenerator::writeLogicalOr(const Expression& left, const Expression& right,
OutputStream& out) {
- Literal trueLiteral(/*offset=*/-1, /*value=*/true, fContext.fTypes.fBool.get());
+ Literal trueLiteral(/*line=*/-1, /*value=*/true, fContext.fTypes.fBool.get());
SpvId trueConstant = this->writeLiteral(trueLiteral);
SpvId lhs = this->writeExpression(left, out);
SpvId rhsLabel = this->nextId(nullptr);
@@ -3018,7 +3017,7 @@
const Variable& intfVar = intf.variable();
const Type& type = intfVar.type();
if (!MemoryLayout::LayoutIsSupported(type)) {
- fContext.fErrors->error(type.fOffset, "type '" + type.name() + "' is not permitted here");
+ fContext.fErrors->error(type.fLine, "type '" + type.name() + "' is not permitted here");
return this->nextId(nullptr);
}
SpvStorageClass_ storageClass = get_storage_class(intf.variable(), SpvStorageClassFunction);
@@ -3042,16 +3041,16 @@
{
AutoAttachPoolToThread attach(fProgram.fPool.get());
const Type* rtFlipStructType = fProgram.fSymbols->takeOwnershipOfSymbol(
- Type::MakeStructType(type.fOffset, type.name(), std::move(fields)));
+ Type::MakeStructType(type.fLine, type.name(), std::move(fields)));
const Variable* modifiedVar = fProgram.fSymbols->takeOwnershipOfSymbol(
- std::make_unique<Variable>(intfVar.fOffset,
+ std::make_unique<Variable>(intfVar.fLine,
&intfVar.modifiers(),
intfVar.name(),
rtFlipStructType,
intfVar.isBuiltin(),
intfVar.storage()));
fSPIRVBonusVariables.insert(modifiedVar);
- InterfaceBlock modifiedCopy(intf.fOffset,
+ InterfaceBlock modifiedCopy(intf.fLine,
*modifiedVar,
intf.typeName(),
intf.instanceName(),
@@ -3059,7 +3058,7 @@
intf.typeOwner());
result = this->writeInterfaceBlock(modifiedCopy, false);
fProgram.fSymbols->add(std::make_unique<Field>(
- /*offset=*/-1, modifiedVar, rtFlipStructType->fields().size() - 1));
+ /*line=*/-1, modifiedVar, rtFlipStructType->fields().size() - 1));
}
fVariableMap[&intfVar] = result;
fWroteRTFlip = true;
@@ -3374,30 +3373,30 @@
const Symbol* skFragColorSymbol = (*symbolTable)["sk_FragColor"];
SkASSERT(skFragColorSymbol);
const Variable& skFragColorVar = skFragColorSymbol->as<Variable>();
- auto skFragColorRef = std::make_unique<VariableReference>(/*offset=*/-1, &skFragColorVar,
+ auto skFragColorRef = std::make_unique<VariableReference>(/*line=*/-1, &skFragColorVar,
VariableReference::RefKind::kWrite);
// Synthesize a call to the `main()` function.
if (main.returnType() != skFragColorRef->type()) {
- fContext.fErrors->error(main.fOffset, "SPIR-V does not support returning '" +
- main.returnType().description() + "' from main()");
+ fContext.fErrors->error(main.fLine, "SPIR-V does not support returning '" +
+ main.returnType().description() + "' from main()");
return {};
}
ExpressionArray args;
if (main.parameters().size() == 1) {
if (main.parameters()[0]->type() != *fContext.fTypes.fFloat2) {
- fContext.fErrors->error(main.fOffset,
+ fContext.fErrors->error(main.fLine,
"SPIR-V does not support parameter of type '" +
main.parameters()[0]->type().description() + "' to main()");
return {};
}
args.push_back(dsl::Float2(0).release());
}
- auto callMainFn = std::make_unique<FunctionCall>(/*offset=*/-1, &main.returnType(), &main,
+ auto callMainFn = std::make_unique<FunctionCall>(/*line=*/-1, &main.returnType(), &main,
std::move(args));
// Synthesize `skFragColor = main()` as a BinaryExpression.
auto assignmentStmt = std::make_unique<ExpressionStatement>(std::make_unique<BinaryExpression>(
- /*offset=*/-1,
+ /*line=*/-1,
std::move(skFragColorRef),
Token::Kind::TK_EQ,
std::move(callMainFn),
@@ -3406,14 +3405,14 @@
// Function bodies are always wrapped in a Block.
StatementArray entrypointStmts;
entrypointStmts.push_back(std::move(assignmentStmt));
- auto entrypointBlock = Block::Make(/*offset=*/-1, std::move(entrypointStmts),
+ auto entrypointBlock = Block::Make(/*line=*/-1, std::move(entrypointStmts),
symbolTable, /*isScope=*/true);
// Declare an entrypoint function.
EntrypointAdapter adapter;
adapter.fLayout = {};
adapter.fModifiers = Modifiers{adapter.fLayout, Modifiers::kHasSideEffects_Flag};
adapter.entrypointDecl =
- std::make_unique<FunctionDeclaration>(/*offset=*/-1,
+ std::make_unique<FunctionDeclaration>(/*line=*/-1,
&adapter.fModifiers,
"_entrypoint",
/*parameters=*/std::vector<const Variable*>{},
@@ -3421,7 +3420,7 @@
/*builtin=*/false);
// Define it.
adapter.entrypointDef = FunctionDefinition::Convert(fContext,
- /*offset=*/-1,
+ /*line=*/-1,
*adapter.entrypointDecl,
std::move(entrypointBlock),
/*builtin=*/false);
@@ -3444,7 +3443,7 @@
fTopLevelUniformMap[var] = (int)fields.size();
fields.emplace_back(var->modifiers(), var->name(), &var->type());
}
- fUniformBuffer.fStruct = Type::MakeStructType(/*offset=*/-1, kUniformBufferName,
+ fUniformBuffer.fStruct = Type::MakeStructType(/*line=*/-1, kUniformBufferName,
std::move(fields));
// Create a global variable to contain this struct.
@@ -3454,7 +3453,7 @@
Modifiers modifiers{layout, Modifiers::kUniform_Flag};
fUniformBuffer.fInnerVariable = std::make_unique<Variable>(
- /*offset=*/-1, fProgram.fModifiers->add(modifiers), kUniformBufferName,
+ /*line=*/-1, fProgram.fModifiers->add(modifiers), kUniformBufferName,
fUniformBuffer.fStruct.get(), /*builtin=*/false, Variable::Storage::kGlobal);
// Create an interface block object for this global variable.
@@ -3466,7 +3465,7 @@
fUniformBufferId = this->writeInterfaceBlock(*fUniformBuffer.fInterfaceBlock);
}
-void SPIRVCodeGenerator::addRTFlipUniform(int offset) {
+void SPIRVCodeGenerator::addRTFlipUniform(int line) {
if (fWroteRTFlip) {
return;
}
@@ -3475,7 +3474,7 @@
fWroteRTFlip = true;
std::vector<Type::Field> fields;
if (fProgram.fConfig->fSettings.fRTFlipOffset < 0) {
- fContext.fErrors->error(offset, "RTFlipOffset is negative");
+ fContext.fErrors->error(line, "RTFlipOffset is negative");
}
fields.emplace_back(Modifiers(Layout(/*flags=*/0,
/*location=*/-1,
@@ -3490,14 +3489,14 @@
fContext.fTypes.fFloat2.get());
skstd::string_view name = "sksl_synthetic_uniforms";
const Type* intfStruct =
- fSynthetics.takeOwnershipOfSymbol(Type::MakeStructType(/*offset=*/-1, name, fields));
+ fSynthetics.takeOwnershipOfSymbol(Type::MakeStructType(/*line=*/-1, name, fields));
int binding = fProgram.fConfig->fSettings.fRTFlipBinding;
if (binding == -1) {
- fContext.fErrors->error(offset, "layout(binding=...) is required in SPIR-V");
+ fContext.fErrors->error(line, "layout(binding=...) is required in SPIR-V");
}
int set = fProgram.fConfig->fSettings.fRTFlipSet;
if (set == -1) {
- fContext.fErrors->error(offset, "layout(set=...) is required in SPIR-V");
+ fContext.fErrors->error(line, "layout(set=...) is required in SPIR-V");
}
bool usePushConstants = fProgram.fConfig->fSettings.fUsePushConstants;
int flags = usePushConstants ? Layout::Flag::kPushConstant_Flag : 0;
@@ -3516,7 +3515,7 @@
modsPtr = fProgram.fModifiers->add(modifiers);
}
const Variable* intfVar = fSynthetics.takeOwnershipOfSymbol(
- std::make_unique<Variable>(/*offset=*/-1,
+ std::make_unique<Variable>(/*line=*/-1,
modsPtr,
name,
intfStruct,
@@ -3525,9 +3524,9 @@
fSPIRVBonusVariables.insert(intfVar);
{
AutoAttachPoolToThread attach(fProgram.fPool.get());
- fProgram.fSymbols->add(std::make_unique<Field>(/*offset=*/-1, intfVar, /*field=*/0));
+ fProgram.fSymbols->add(std::make_unique<Field>(/*line=*/-1, intfVar, /*field=*/0));
}
- InterfaceBlock intf(/*offset=*/-1,
+ InterfaceBlock intf(/*line=*/-1,
*intfVar,
name,
/*instanceName=*/"",
@@ -3554,7 +3553,7 @@
}
// Make sure we have a main() function.
if (!main) {
- fContext.fErrors->error(/*offset=*/-1, "program does not contain a main() function");
+ fContext.fErrors->error(/*line=*/-1, "program does not contain a main() function");
return;
}
// Emit interface blocks.
diff --git a/src/sksl/codegen/SkSLSPIRVCodeGenerator.h b/src/sksl/codegen/SkSLSPIRVCodeGenerator.h
index 0e7b728..abab85b 100644
--- a/src/sksl/codegen/SkSLSPIRVCodeGenerator.h
+++ b/src/sksl/codegen/SkSLSPIRVCodeGenerator.h
@@ -466,7 +466,7 @@
void writeUniformBuffer(std::shared_ptr<SymbolTable> topLevelSymbolTable);
- void addRTFlipUniform(int offset);
+ void addRTFlipUniform(int line);
const MemoryLayout fDefaultLayout;
diff --git a/src/sksl/dsl/DSLBlock.cpp b/src/sksl/dsl/DSLBlock.cpp
index aff5608..24f2335 100644
--- a/src/sksl/dsl/DSLBlock.cpp
+++ b/src/sksl/dsl/DSLBlock.cpp
@@ -36,7 +36,7 @@
}
std::unique_ptr<SkSL::Block> DSLBlock::release() {
- return std::make_unique<SkSL::Block>(/*offset=*/-1, std::move(fStatements),
+ return std::make_unique<SkSL::Block>(/*line=*/-1, std::move(fStatements),
std::move(fSymbols));
}
diff --git a/src/sksl/dsl/DSLCore.cpp b/src/sksl/dsl/DSLCore.cpp
index 6885a7b..3edd4c6 100644
--- a/src/sksl/dsl/DSLCore.cpp
+++ b/src/sksl/dsl/DSLCore.cpp
@@ -120,15 +120,15 @@
int unused[] = {0, (static_cast<void>(argArray.push_back(args.release())), 0)...};
static_cast<void>(unused);
- return ir.call(/*offset=*/-1, ir.convertIdentifier(-1, name), std::move(argArray));
+ return ir.call(/*line=*/-1, ir.convertIdentifier(-1, name), std::move(argArray));
}
static DSLStatement Break(PositionInfo pos) {
- return SkSL::BreakStatement::Make(pos.offset());
+ return SkSL::BreakStatement::Make(pos.line());
}
static DSLStatement Continue(PositionInfo pos) {
- return SkSL::ContinueStatement::Make(pos.offset());
+ return SkSL::ContinueStatement::Make(pos.line());
}
static void Declare(const DSLModifiers& modifiers) {
@@ -182,7 +182,7 @@
}
static DSLStatement Discard(PositionInfo pos) {
- return SkSL::DiscardStatement::Make(pos.offset());
+ return SkSL::DiscardStatement::Make(pos.line());
}
static DSLPossibleStatement Do(DSLStatement stmt, DSLExpression test) {
@@ -199,7 +199,7 @@
static DSLPossibleStatement If(DSLExpression test, DSLStatement ifTrue, DSLStatement ifFalse,
bool isStatic) {
- return IfStatement::Convert(DSLWriter::Context(), /*offset=*/-1, isStatic, test.release(),
+ return IfStatement::Convert(DSLWriter::Context(), /*line=*/-1, isStatic, test.release(),
ifTrue.release(), ifFalse.releaseIfPossible());
}
@@ -257,7 +257,7 @@
// 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
// added to a function. (This is done in FunctionDefinition::Convert.)
- return SkSL::ReturnStatement::Make(pos.offset(), value.releaseIfPossible());
+ return SkSL::ReturnStatement::Make(pos.line(), value.releaseIfPossible());
}
static DSLExpression Swizzle(DSLExpression base, SkSL::SwizzleComponent::Type a,
@@ -318,7 +318,7 @@
}
static DSLPossibleStatement While(DSLExpression test, DSLStatement stmt) {
- return ForStatement::ConvertWhile(DSLWriter::Context(), /*offset=*/-1, test.release(),
+ return ForStatement::ConvertWhile(DSLWriter::Context(), /*line=*/-1, test.release(),
stmt.release(), DSLWriter::SymbolTable());
}
};
@@ -340,7 +340,7 @@
}
void AddExtension(skstd::string_view name, PositionInfo pos) {
- DSLWriter::ProgramElements().push_back(std::make_unique<SkSL::Extension>(pos.offset(), name));
+ DSLWriter::ProgramElements().push_back(std::make_unique<SkSL::Extension>(pos.line(), name));
DSLWriter::ReportErrors(pos);
}
diff --git a/src/sksl/dsl/DSLExpression.cpp b/src/sksl/dsl/DSLExpression.cpp
index f9b8ec7..8627bcf 100644
--- a/src/sksl/dsl/DSLExpression.cpp
+++ b/src/sksl/dsl/DSLExpression.cpp
@@ -38,7 +38,7 @@
DSLExpression::DSLExpression(float value, PositionInfo pos)
: fExpression(SkSL::Literal::MakeFloat(DSLWriter::Context(),
- pos.offset(),
+ pos.line(),
value)) {
if (!isfinite(value)) {
if (isinf(value)) {
@@ -51,26 +51,26 @@
DSLExpression::DSLExpression(int value, PositionInfo pos)
: fExpression(SkSL::Literal::MakeInt(DSLWriter::Context(),
- pos.offset(),
+ pos.line(),
value)) {}
DSLExpression::DSLExpression(int64_t value, PositionInfo pos)
: fExpression(SkSL::Literal::MakeInt(DSLWriter::Context(),
- pos.offset(),
+ pos.line(),
value)) {}
DSLExpression::DSLExpression(unsigned int value, PositionInfo pos)
: fExpression(SkSL::Literal::MakeInt(DSLWriter::Context(),
- pos.offset(),
+ pos.line(),
value)) {}
DSLExpression::DSLExpression(bool value, PositionInfo pos)
: fExpression(SkSL::Literal::MakeBool(DSLWriter::Context(),
- pos.offset(),
+ pos.line(),
value)) {}
DSLExpression::DSLExpression(DSLVarBase& var, PositionInfo pos) {
- fExpression = std::make_unique<SkSL::VariableReference>(pos.offset(), DSLWriter::Var(var),
+ fExpression = std::make_unique<SkSL::VariableReference>(pos.line(), DSLWriter::Var(var),
SkSL::VariableReference::RefKind::kRead);
}
@@ -82,12 +82,12 @@
if (expr.valid()) {
fExpression = std::move(expr.fExpression);
} else {
- fExpression = SkSL::Poison::Make(pos.offset(), DSLWriter::Context());
+ fExpression = SkSL::Poison::Make(pos.line(), DSLWriter::Context());
}
}
DSLExpression DSLExpression::Poison(PositionInfo pos) {
- return DSLExpression(SkSL::Poison::Make(pos.offset(), DSLWriter::Context()));
+ return DSLExpression(SkSL::Poison::Make(pos.line(), DSLWriter::Context()));
}
DSLExpression::~DSLExpression() {
diff --git a/src/sksl/dsl/DSLFunction.cpp b/src/sksl/dsl/DSLFunction.cpp
index baf230f..80dc60f 100644
--- a/src/sksl/dsl/DSLFunction.cpp
+++ b/src/sksl/dsl/DSLFunction.cpp
@@ -52,7 +52,7 @@
SkASSERT(paramVars.size() == params.size());
fDecl = SkSL::FunctionDeclaration::Convert(DSLWriter::Context(),
*DSLWriter::SymbolTable(),
- pos.offset(),
+ pos.line(),
DSLWriter::Modifiers(modifiers.fModifiers),
name == "main" ? name : DSLWriter::Name(name),
std::move(paramVars), &returnType.skslType(),
@@ -67,7 +67,7 @@
// case the definition is delayed. If we end up defining the function immediately, we'll
// remove the prototype in define().
DSLWriter::ProgramElements().push_back(std::make_unique<SkSL::FunctionPrototype>(
- pos.offset(), fDecl, DSLWriter::IsModule()));
+ pos.line(), fDecl, DSLWriter::IsModule()));
}
}
@@ -98,7 +98,7 @@
// Append sk_Position fixup to the bottom of main() if this is a vertex program.
DSLWriter::IRGenerator().appendRTAdjustFixupToVertexMain(*fDecl, body.get());
std::unique_ptr<FunctionDefinition> function = FunctionDefinition::Convert(DSLWriter::Context(),
- pos.offset(),
+ pos.line(),
*fDecl,
std::move(body),
/*builtin=*/false);
diff --git a/src/sksl/dsl/DSLStatement.cpp b/src/sksl/dsl/DSLStatement.cpp
index 080491f..1d2cd02 100644
--- a/src/sksl/dsl/DSLStatement.cpp
+++ b/src/sksl/dsl/DSLStatement.cpp
@@ -55,8 +55,8 @@
} else {
fStatement = SkSL::Nop::Make();
}
- if (pos.offset() != -1) {
- fStatement->fOffset = pos.offset();
+ if (pos.line() != -1) {
+ fStatement->fLine = pos.line();
}
}
@@ -83,7 +83,7 @@
}
DSLStatement operator,(DSLStatement left, DSLStatement right) {
- int line = left.fStatement->fOffset;
+ int line = left.fStatement->fLine;
StatementArray stmts;
stmts.reserve_back(2);
stmts.push_back(left.release());
diff --git a/src/sksl/dsl/DSLSymbols.cpp b/src/sksl/dsl/DSLSymbols.cpp
index 4103898..2801c10 100644
--- a/src/sksl/dsl/DSLSymbols.cpp
+++ b/src/sksl/dsl/DSLSymbols.cpp
@@ -27,7 +27,7 @@
}
DSLPossibleExpression Symbol(skstd::string_view name, PositionInfo pos) {
- return DSLWriter::IRGenerator().convertIdentifier(pos.offset(), name);
+ return DSLWriter::IRGenerator().convertIdentifier(pos.line(), name);
}
bool IsType(skstd::string_view name) {
diff --git a/src/sksl/dsl/DSLType.cpp b/src/sksl/dsl/DSLType.cpp
index 03258f9..4b529bf 100644
--- a/src/sksl/dsl/DSLType.cpp
+++ b/src/sksl/dsl/DSLType.cpp
@@ -48,7 +48,7 @@
return nullptr;
}
const Type* result = type->applyPrecisionQualifiers(DSLWriter::Context(), modifiers,
- DSLWriter::SymbolTable().get(), /*offset=*/-1);
+ DSLWriter::SymbolTable().get(), /*line=*/-1);
DSLWriter::ReportErrors(pos);
return result;
}
@@ -248,13 +248,13 @@
}
skslFields.emplace_back(field.fModifiers.fModifiers, field.fName, &type);
}
- const SkSL::Type* result = DSLWriter::SymbolTable()->add(Type::MakeStructType(pos.offset(),
+ const SkSL::Type* result = DSLWriter::SymbolTable()->add(Type::MakeStructType(pos.line(),
name,
skslFields));
if (result->isTooDeeplyNested()) {
DSLWriter::ReportError("struct '" + String(name) + "' is too deeply nested", pos);
}
- DSLWriter::ProgramElements().push_back(std::make_unique<SkSL::StructDefinition>(/*offset=*/-1,
+ DSLWriter::ProgramElements().push_back(std::make_unique<SkSL::StructDefinition>(/*line=*/-1,
*result));
return result;
}
diff --git a/src/sksl/dsl/DSLVar.cpp b/src/sksl/dsl/DSLVar.cpp
index 37de479..7c687ce 100644
--- a/src/sksl/dsl/DSLVar.cpp
+++ b/src/sksl/dsl/DSLVar.cpp
@@ -124,7 +124,7 @@
SkSL::Modifiers::kNo_Flag));
fVar = DSLWriter::SymbolTable()->takeOwnershipOfIRNode(std::make_unique<SkSL::Variable>(
- /*offset=*/-1,
+ /*line=*/-1,
modifiers,
fName,
DSLWriter::Context().fTypes.fFloat2.get(),
diff --git a/src/sksl/dsl/priv/DSLWriter.cpp b/src/sksl/dsl/priv/DSLWriter.cpp
index 5fc10ab..73b7f3c 100644
--- a/src/sksl/dsl/priv/DSLWriter.cpp
+++ b/src/sksl/dsl/priv/DSLWriter.cpp
@@ -143,7 +143,7 @@
stmts.reserve_back(2);
stmts.push_back(std::move(existing.fStatement));
stmts.push_back(Declare(additional).release());
- existing.fStatement = SkSL::Block::MakeUnscoped(/*offset=*/-1, std::move(stmts));
+ existing.fStatement = SkSL::Block::MakeUnscoped(/*line=*/-1, std::move(stmts));
} else if (existing.fStatement->isEmpty()) {
// If the variable declaration generated an error, we can end up with a Nop statement here.
existing.fStatement = Declare(additional).release();
@@ -155,7 +155,7 @@
PositionInfo pos) {
// We can't call FunctionCall::Convert directly here, because intrinsic management is handled in
// IRGenerator::call.
- return IRGenerator().call(pos.offset(), function, std::move(arguments));
+ return IRGenerator().call(pos.line(), function, std::move(arguments));
}
std::unique_ptr<SkSL::Expression> DSLWriter::Call(std::unique_ptr<SkSL::Expression> expr,
@@ -163,7 +163,7 @@
PositionInfo pos) {
// We can't call FunctionCall::Convert directly here, because intrinsic management is handled in
// IRGenerator::call.
- return IRGenerator().call(pos.offset(), std::move(expr), std::move(arguments));
+ return IRGenerator().call(pos.line(), std::move(expr), std::move(arguments));
}
DSLPossibleExpression DSLWriter::Coerce(std::unique_ptr<Expression> expr, const SkSL::Type& type) {
@@ -180,7 +180,7 @@
}
args.push_back(arg.release());
}
- return SkSL::Constructor::Convert(Context(), /*offset=*/-1, type, std::move(args));
+ return SkSL::Constructor::Convert(Context(), /*line=*/-1, type, std::move(args));
}
std::unique_ptr<SkSL::Expression> DSLWriter::ConvertBinary(std::unique_ptr<Expression> left,
@@ -216,13 +216,13 @@
StatementArray caseBlocks;
caseBlocks.resize(caseStatements.count());
for (int index = 0; index < caseStatements.count(); ++index) {
- caseBlocks[index] = std::make_unique<SkSL::Block>(/*offset=*/-1,
+ caseBlocks[index] = std::make_unique<SkSL::Block>(/*line=*/-1,
std::move(caseStatements[index]),
/*symbols=*/nullptr,
/*isScope=*/false);
}
- return SwitchStatement::Convert(Context(), /*offset=*/-1, isStatic, std::move(value),
+ return SwitchStatement::Convert(Context(), /*line=*/-1, isStatic, std::move(value),
std::move(caseValues), std::move(caseBlocks),
IRGenerator().fSymbolTable);
}
@@ -260,13 +260,13 @@
if (baseType->isArray()) {
baseType = &baseType->componentType();
}
- DSLWriter::IRGenerator().checkVarDeclaration(var.fPosition.offset(),
+ DSLWriter::IRGenerator().checkVarDeclaration(var.fPosition.line(),
var.fModifiers.fModifiers,
baseType,
var.storage());
}
std::unique_ptr<SkSL::Variable> skslvar = DSLWriter::IRGenerator().convertVar(
- var.fPosition.offset(),
+ var.fPosition.line(),
var.fModifiers.fModifiers,
&var.fType.skslType(),
var.fName,
@@ -299,7 +299,7 @@
// This should only be called on undeclared parameter variables, but we allow the creation to go
// ahead regardless so we don't have to worry about null pointers potentially sneaking in and
// breaking things. DSLFunction is responsible for reporting errors for invalid parameters.
- return DSLWriter::IRGenerator().convertVar(var.fPosition.offset(), var.fModifiers.fModifiers,
+ return DSLWriter::IRGenerator().convertVar(var.fPosition.line(), var.fModifiers.fModifiers,
&var.fType.skslType(), var.fName, /*isArray=*/false,
/*arraySize=*/nullptr, var.storage());
}
diff --git a/src/sksl/ir/SkSLBinaryExpression.cpp b/src/sksl/ir/SkSLBinaryExpression.cpp
index 8a22052..e79287f 100644
--- a/src/sksl/ir/SkSLBinaryExpression.cpp
+++ b/src/sksl/ir/SkSLBinaryExpression.cpp
@@ -40,7 +40,7 @@
for (int n = 0; n < left.type().rows(); ++n) {
// Get mat[N] with an index expression.
std::unique_ptr<Expression> matN = IndexExpression::Make(
- context, left.clone(), Literal::MakeInt(context, left.fOffset, n));
+ context, left.clone(), Literal::MakeInt(context, left.fLine, n));
// Get vec[N] with a swizzle expression.
std::unique_ptr<Expression> vecN = Swizzle::Make(
context, right.clone(), ComponentArray{(SkSL::SwizzleComponent::Type)n});
@@ -70,7 +70,7 @@
if (!left || !right) {
return nullptr;
}
- const int offset = left->fOffset;
+ const int line = left->fLine;
const Type* rawLeftType = (left->isIntLiteral() && right->type().isInteger())
? &right->type()
@@ -94,29 +94,29 @@
const Type* resultType;
if (!op.determineBinaryType(context, *rawLeftType, *rawRightType,
&leftType, &rightType, &resultType)) {
- context.fErrors->error(offset, String("type mismatch: '") + op.operatorName() +
- "' cannot operate on '" + left->type().displayName() +
- "', '" + right->type().displayName() + "'");
+ context.fErrors->error(line, String("type mismatch: '") + op.operatorName() +
+ "' cannot operate on '" + left->type().displayName() +
+ "', '" + right->type().displayName() + "'");
return nullptr;
}
if (isAssignment && leftType->componentType().isOpaque()) {
- context.fErrors->error(offset, "assignments to opaque type '" + left->type().displayName() +
- "' are not permitted");
+ context.fErrors->error(line, "assignments to opaque type '" + left->type().displayName() +
+ "' are not permitted");
return nullptr;
}
if (context.fConfig->strictES2Mode()) {
if (!op.isAllowedInStrictES2Mode()) {
- context.fErrors->error(offset, String("operator '") + op.operatorName() +
- "' is not allowed");
+ context.fErrors->error(line, String("operator '") + op.operatorName() +
+ "' is not allowed");
return nullptr;
}
if (leftType->isOrContainsArray()) {
// Most operators are already rejected on arrays, but GLSL ES 1.0 is very explicit that
// the *only* operator allowed on arrays is subscripting (and the rules against
// assignment, comparison, and even sequence apply to structs containing arrays as well)
- context.fErrors->error(offset, String("operator '") + op.operatorName() + "' can not "
- "operate on arrays (or structs containing arrays)");
+ context.fErrors->error(line, String("operator '") + op.operatorName() + "' can not "
+ "operate on arrays (or structs containing arrays)");
return nullptr;
}
}
@@ -163,8 +163,8 @@
}
// Perform constant-folding on the expression.
- const int offset = left->fOffset;
- if (std::unique_ptr<Expression> result = ConstantFolder::Simplify(context, offset, *left,
+ const int line = left->fLine;
+ if (std::unique_ptr<Expression> result = ConstantFolder::Simplify(context, line, *left,
op, *right, *resultType)) {
return result;
}
@@ -176,7 +176,7 @@
// : mat * vec)
if (is_low_precision_matrix_vector_multiply(*left, op, *right, *resultType)) {
// Look up `sk_Caps.rewriteMatrixVectorMultiply`.
- auto caps = Setting::Convert(context, offset, "rewriteMatrixVectorMultiply");
+ auto caps = Setting::Convert(context, line, "rewriteMatrixVectorMultiply");
bool capsBitIsTrue = caps->isBoolLiteral() && caps->as<Literal>().boolValue();
if (capsBitIsTrue || !caps->isBoolLiteral()) {
@@ -195,13 +195,13 @@
context,
std::move(caps),
std::move(rewrite),
- std::make_unique<BinaryExpression>(offset, std::move(left), op,
+ std::make_unique<BinaryExpression>(line, std::move(left), op,
std::move(right), resultType));
}
}
}
- return std::make_unique<BinaryExpression>(offset, std::move(left), op,
+ return std::make_unique<BinaryExpression>(line, std::move(left), op,
std::move(right), resultType);
}
@@ -231,7 +231,7 @@
}
std::unique_ptr<Expression> BinaryExpression::clone() const {
- return std::make_unique<BinaryExpression>(fOffset,
+ return std::make_unique<BinaryExpression>(fLine,
this->left()->clone(),
this->getOperator(),
this->right()->clone(),
diff --git a/src/sksl/ir/SkSLBinaryExpression.h b/src/sksl/ir/SkSLBinaryExpression.h
index 6a283e8..b79798a 100644
--- a/src/sksl/ir/SkSLBinaryExpression.h
+++ b/src/sksl/ir/SkSLBinaryExpression.h
@@ -28,9 +28,9 @@
public:
static constexpr Kind kExpressionKind = Kind::kBinary;
- BinaryExpression(int offset, std::unique_ptr<Expression> left, Operator op,
+ BinaryExpression(int line, std::unique_ptr<Expression> left, Operator op,
std::unique_ptr<Expression> right, const Type* type)
- : INHERITED(offset, kExpressionKind, type)
+ : INHERITED(line, kExpressionKind, type)
, fLeft(std::move(left))
, fOperator(op)
, fRight(std::move(right)) {
diff --git a/src/sksl/ir/SkSLBlock.cpp b/src/sksl/ir/SkSLBlock.cpp
index bd8dd65..c1cf065 100644
--- a/src/sksl/ir/SkSLBlock.cpp
+++ b/src/sksl/ir/SkSLBlock.cpp
@@ -12,7 +12,7 @@
namespace SkSL {
-std::unique_ptr<Statement> Block::MakeUnscoped(int offset, StatementArray statements) {
+std::unique_ptr<Statement> Block::MakeUnscoped(int line, StatementArray statements) {
// If the Block is completely empty, synthesize a Nop.
if (statements.empty()) {
return Nop::Make();
@@ -31,7 +31,7 @@
continue;
}
// We found more than one non-empty statement. We actually do need a Block.
- return std::make_unique<Block>(offset, std::move(statements),
+ return std::make_unique<Block>(line, std::move(statements),
/*symbols=*/nullptr, /*isScope=*/false);
}
}
@@ -49,13 +49,13 @@
return std::move(statements.front());
}
-std::unique_ptr<Block> Block::Make(int offset,
+std::unique_ptr<Block> Block::Make(int line,
StatementArray statements,
std::shared_ptr<SymbolTable> symbols,
bool isScope) {
// Nothing to optimize here--eliminating empty statements doesn't actually improve the generated
// code, and we promise to return a Block.
- return std::make_unique<Block>(offset, std::move(statements), std::move(symbols), isScope);
+ return std::make_unique<Block>(line, std::move(statements), std::move(symbols), isScope);
}
std::unique_ptr<Statement> Block::clone() const {
@@ -64,7 +64,7 @@
for (const std::unique_ptr<Statement>& stmt : this->children()) {
cloned.push_back(stmt->clone());
}
- return std::make_unique<Block>(fOffset,
+ return std::make_unique<Block>(fLine,
std::move(cloned),
SymbolTable::WrapIfBuiltin(this->symbolTable()),
this->isScope());
diff --git a/src/sksl/ir/SkSLBlock.h b/src/sksl/ir/SkSLBlock.h
index fba414f..45922f6 100644
--- a/src/sksl/ir/SkSLBlock.h
+++ b/src/sksl/ir/SkSLBlock.h
@@ -20,23 +20,23 @@
public:
static constexpr Kind kStatementKind = Kind::kBlock;
- Block(int offset, StatementArray statements,
+ Block(int line, StatementArray statements,
const std::shared_ptr<SymbolTable> symbols = nullptr, bool isScope = true)
- : INHERITED(offset, kStatementKind)
+ : INHERITED(line, kStatementKind)
, fChildren(std::move(statements))
, fSymbolTable(std::move(symbols))
, fIsScope(isScope) {}
// Make always makes a real Block object. This is important because many callers rely on Blocks
// specifically; e.g. a function body must be a scoped Block, nothing else will do.
- static std::unique_ptr<Block> Make(int offset,
+ static std::unique_ptr<Block> Make(int line,
StatementArray statements,
std::shared_ptr<SymbolTable> symbols = nullptr,
bool isScope = true);
// An unscoped Block is just a collection of Statements. For a single-statement Block,
// MakeUnscoped will return the Statement as-is. For an empty Block, MakeUnscoped returns Nop.
- static std::unique_ptr<Statement> MakeUnscoped(int offset, StatementArray statements);
+ static std::unique_ptr<Statement> MakeUnscoped(int line, StatementArray statements);
const StatementArray& children() const {
return fChildren;
diff --git a/src/sksl/ir/SkSLBreakStatement.h b/src/sksl/ir/SkSLBreakStatement.h
index 34b03fd..457d514 100644
--- a/src/sksl/ir/SkSLBreakStatement.h
+++ b/src/sksl/ir/SkSLBreakStatement.h
@@ -20,15 +20,15 @@
public:
static constexpr Kind kStatementKind = Kind::kBreak;
- BreakStatement(int offset)
- : INHERITED(offset, kStatementKind) {}
+ BreakStatement(int line)
+ : INHERITED(line, kStatementKind) {}
- static std::unique_ptr<Statement> Make(int offset) {
- return std::make_unique<BreakStatement>(offset);
+ static std::unique_ptr<Statement> Make(int line) {
+ return std::make_unique<BreakStatement>(line);
}
std::unique_ptr<Statement> clone() const override {
- return std::make_unique<BreakStatement>(fOffset);
+ return std::make_unique<BreakStatement>(fLine);
}
String description() const override {
diff --git a/src/sksl/ir/SkSLChildCall.cpp b/src/sksl/ir/SkSLChildCall.cpp
index e2da51c..c2a3f7f 100644
--- a/src/sksl/ir/SkSLChildCall.cpp
+++ b/src/sksl/ir/SkSLChildCall.cpp
@@ -25,7 +25,7 @@
for (const std::unique_ptr<Expression>& arg : this->arguments()) {
cloned.push_back(arg->clone());
}
- return std::make_unique<ChildCall>(fOffset, &this->type(), &this->child(), std::move(cloned));
+ return std::make_unique<ChildCall>(fLine, &this->type(), &this->child(), std::move(cloned));
}
String ChildCall::description() const {
@@ -68,12 +68,12 @@
}
std::unique_ptr<Expression> ChildCall::Make(const Context& context,
- int offset,
+ int line,
const Type* returnType,
const Variable& child,
ExpressionArray arguments) {
SkASSERT(call_signature_is_valid(context, child, arguments));
- return std::make_unique<ChildCall>(offset, returnType, &child, std::move(arguments));
+ return std::make_unique<ChildCall>(line, returnType, &child, std::move(arguments));
}
} // namespace SkSL
diff --git a/src/sksl/ir/SkSLChildCall.h b/src/sksl/ir/SkSLChildCall.h
index 10ab498..be7e8d6 100644
--- a/src/sksl/ir/SkSLChildCall.h
+++ b/src/sksl/ir/SkSLChildCall.h
@@ -21,14 +21,14 @@
public:
static constexpr Kind kExpressionKind = Kind::kChildCall;
- ChildCall(int offset, const Type* type, const Variable* child, ExpressionArray arguments)
- : INHERITED(offset, kExpressionKind, type)
+ ChildCall(int line, const Type* type, const Variable* child, ExpressionArray arguments)
+ : INHERITED(line, kExpressionKind, type)
, fChild(*child)
, fArguments(std::move(arguments)) {}
// Creates the child call; reports errors via ASSERT.
static std::unique_ptr<Expression> Make(const Context& context,
- int offset,
+ int line,
const Type* returnType,
const Variable& child,
ExpressionArray arguments);
diff --git a/src/sksl/ir/SkSLCodeStringExpression.h b/src/sksl/ir/SkSLCodeStringExpression.h
index 7559cbe..b5573a5 100644
--- a/src/sksl/ir/SkSLCodeStringExpression.h
+++ b/src/sksl/ir/SkSLCodeStringExpression.h
@@ -23,7 +23,7 @@
static constexpr Kind kExpressionKind = Kind::kCodeString;
CodeStringExpression(String code, const Type* type)
- : INHERITED(/*offset=*/-1, kExpressionKind, type)
+ : INHERITED(/*line=*/-1, kExpressionKind, type)
, fCode(std::move(code)) {}
bool hasProperty(Property property) const override {
diff --git a/src/sksl/ir/SkSLConstructor.cpp b/src/sksl/ir/SkSLConstructor.cpp
index 03d7c01..6ac7375 100644
--- a/src/sksl/ir/SkSLConstructor.cpp
+++ b/src/sksl/ir/SkSLConstructor.cpp
@@ -22,7 +22,7 @@
namespace SkSL {
static std::unique_ptr<Expression> convert_compound_constructor(const Context& context,
- int offset,
+ int line,
const Type& type,
ExpressionArray args) {
SkASSERT(type.isVector() || type.isMatrix());
@@ -45,9 +45,9 @@
default: swizzleHint = ""; SkDEBUGFAIL("unexpected slicing cast"); break;
}
- context.fErrors->error(offset, "'" + argument->type().displayName() +
- "' is not a valid parameter to '" + type.displayName() +
- "' constructor" + swizzleHint);
+ context.fErrors->error(line, "'" + argument->type().displayName() +
+ "' is not a valid parameter to '" + type.displayName() +
+ "' constructor" + swizzleHint);
return nullptr;
}
@@ -56,17 +56,17 @@
// (for matrices). It's legal regardless of the scalar's type, so synthesize an explicit
// conversion to the proper type. (This cast is a no-op if it's unnecessary.)
std::unique_ptr<Expression> typecast = ConstructorScalarCast::Make(
- context, offset, type.componentType(), std::move(argument));
+ context, line, type.componentType(), std::move(argument));
// Matrix-from-scalar creates a diagonal matrix; vector-from-scalar creates a splat.
return type.isMatrix()
- ? ConstructorDiagonalMatrix::Make(context, offset, type, std::move(typecast))
- : ConstructorSplat::Make(context, offset, type, std::move(typecast));
+ ? ConstructorDiagonalMatrix::Make(context, line, type, std::move(typecast))
+ : ConstructorSplat::Make(context, line, type, std::move(typecast));
} else if (argument->type().isVector()) {
// A vector constructor containing a single vector with the same number of columns is a
// cast (e.g. float3 -> int3).
if (type.isVector() && argument->type().columns() == type.columns()) {
- return ConstructorCompoundCast::Make(context, offset, type, std::move(argument));
+ return ConstructorCompoundCast::Make(context, line, type, std::move(argument));
}
} else if (argument->type().isMatrix()) {
// A matrix constructor containing a single matrix can be a resize, typecast, or both.
@@ -79,11 +79,11 @@
context,
argument->type().columns(),
argument->type().rows());
- argument = ConstructorCompoundCast::Make(context, offset, typecastType,
+ argument = ConstructorCompoundCast::Make(context, line, typecastType,
std::move(argument));
// Casting a matrix type into another matrix type is a resize.
- return ConstructorMatrixResize::Make(context, offset, type,
+ return ConstructorMatrixResize::Make(context, line, type,
std::move(argument));
}
@@ -96,11 +96,11 @@
/*columns=*/4,
/*rows=*/1);
std::unique_ptr<Expression> vecCtor =
- ConstructorCompound::Make(context, offset, vectorType, std::move(args));
+ ConstructorCompound::Make(context, line, vectorType, std::move(args));
// Then, add a typecast to the result expression to ensure the types match.
// This will be a no-op if no typecasting is needed.
- return ConstructorCompoundCast::Make(context, offset, type, std::move(vecCtor));
+ return ConstructorCompoundCast::Make(context, line, type, std::move(vecCtor));
}
}
}
@@ -111,9 +111,9 @@
for (size_t index = 0; index < args.size(); ++index) {
std::unique_ptr<Expression>& arg = args[index];
if (!arg->type().isScalar() && !arg->type().isVector()) {
- context.fErrors->error(offset, "'" + arg->type().displayName() +
- "' is not a valid parameter to '" +
- type.displayName() + "' constructor");
+ context.fErrors->error(line, "'" + arg->type().displayName() +
+ "' is not a valid parameter to '" + type.displayName() +
+ "' constructor");
return nullptr;
}
@@ -126,7 +126,7 @@
// practice.
int limit = type.rows() - (actual % type.rows());
if (arg->type().columns() > limit) {
- context.fErrors->error(offset,
+ context.fErrors->error(line,
"argument " + std::to_string(index + 1) + " to '" + type.displayName() +
"' constructor is '" + arg->type().displayName() + "', but matrix "
"column only has " + std::to_string(limit) + " slot" +
@@ -140,12 +140,12 @@
// literal, this will make sure it's the right type of literal. If an expression of matching
// type, the expression will be returned as-is. If it's an expression of mismatched type,
// this adds a cast.
- int ctorOffset = arg->fOffset;
+ int ctorLine = arg->fLine;
const Type& ctorType = type.componentType().toCompound(context, arg->type().columns(),
/*rows=*/1);
ExpressionArray ctorArg;
ctorArg.push_back(std::move(arg));
- arg = Constructor::Convert(context, ctorOffset, ctorType, std::move(ctorArg));
+ arg = Constructor::Convert(context, ctorLine, ctorType, std::move(ctorArg));
if (!arg) {
return nullptr;
}
@@ -153,17 +153,17 @@
}
if (actual != expected) {
- context.fErrors->error(offset, "invalid arguments to '" + type.displayName() +
- "' constructor (expected " + to_string(expected) +
- " scalars, but found " + to_string(actual) + ")");
+ context.fErrors->error(line, "invalid arguments to '" + type.displayName() +
+ "' constructor (expected " + to_string(expected) +
+ " scalars, but found " + to_string(actual) + ")");
return nullptr;
}
- return ConstructorCompound::Make(context, offset, type, std::move(args));
+ return ConstructorCompound::Make(context, line, type, std::move(args));
}
std::unique_ptr<Expression> Constructor::Convert(const Context& context,
- int offset,
+ int line,
const Type& type,
ExpressionArray args) {
if (args.size() == 1 && args[0]->type() == type && !type.componentType().isOpaque()) {
@@ -172,19 +172,19 @@
return std::move(args[0]);
}
if (type.isScalar()) {
- return ConstructorScalarCast::Convert(context, offset, type, std::move(args));
+ return ConstructorScalarCast::Convert(context, line, type, std::move(args));
}
if (type.isVector() || type.isMatrix()) {
- return convert_compound_constructor(context, offset, type, std::move(args));
+ return convert_compound_constructor(context, line, type, std::move(args));
}
if (type.isArray() && type.columns() > 0) {
- return ConstructorArray::Convert(context, offset, type, std::move(args));
+ return ConstructorArray::Convert(context, line, type, std::move(args));
}
if (type.isStruct() && type.fields().size() > 0) {
- return ConstructorStruct::Convert(context, offset, type, std::move(args));
+ return ConstructorStruct::Convert(context, line, type, std::move(args));
}
- context.fErrors->error(offset, "cannot construct '" + type.displayName() + "'");
+ context.fErrors->error(line, "cannot construct '" + type.displayName() + "'");
return nullptr;
}
diff --git a/src/sksl/ir/SkSLConstructor.h b/src/sksl/ir/SkSLConstructor.h
index f752565..630fb8b 100644
--- a/src/sksl/ir/SkSLConstructor.h
+++ b/src/sksl/ir/SkSLConstructor.h
@@ -19,8 +19,8 @@
*/
class AnyConstructor : public Expression {
public:
- AnyConstructor(int offset, Kind kind, const Type* type)
- : INHERITED(offset, kind, type) {}
+ AnyConstructor(int line, Kind kind, const Type* type)
+ : INHERITED(line, kind, type) {}
virtual SkSpan<std::unique_ptr<Expression>> argumentSpan() = 0;
virtual SkSpan<const std::unique_ptr<Expression>> argumentSpan() const = 0;
@@ -84,9 +84,9 @@
*/
class SingleArgumentConstructor : public AnyConstructor {
public:
- SingleArgumentConstructor(int offset, Kind kind, const Type* type,
+ SingleArgumentConstructor(int line, Kind kind, const Type* type,
std::unique_ptr<Expression> argument)
- : INHERITED(offset, kind, type)
+ : INHERITED(line, kind, type)
, fArgument(std::move(argument)) {}
std::unique_ptr<Expression>& argument() {
@@ -116,8 +116,8 @@
*/
class MultiArgumentConstructor : public AnyConstructor {
public:
- MultiArgumentConstructor(int offset, Kind kind, const Type* type, ExpressionArray arguments)
- : INHERITED(offset, kind, type)
+ MultiArgumentConstructor(int line, Kind kind, const Type* type, ExpressionArray arguments)
+ : INHERITED(line, kind, type)
, fArguments(std::move(arguments)) {}
ExpressionArray& arguments() {
@@ -169,7 +169,7 @@
// Constructor expression types; this class chooses the proper one based on context, e.g.
// `ConstructorCompound`, `ConstructorScalarCast`, or `ConstructorMatrixResize`.
std::unique_ptr<Expression> Convert(const Context& context,
- int offset,
+ int line,
const Type& type,
ExpressionArray args);
};
diff --git a/src/sksl/ir/SkSLConstructorArray.cpp b/src/sksl/ir/SkSLConstructorArray.cpp
index 3ebd982..50e2ac6 100644
--- a/src/sksl/ir/SkSLConstructorArray.cpp
+++ b/src/sksl/ir/SkSLConstructorArray.cpp
@@ -11,15 +11,15 @@
namespace SkSL {
std::unique_ptr<Expression> ConstructorArray::Convert(const Context& context,
- int offset,
+ int line,
const Type& type,
ExpressionArray args) {
SkASSERTF(type.isArray() && type.columns() > 0, "%s", type.description().c_str());
// ES2 doesn't support first-class array types.
if (context.fConfig->strictES2Mode()) {
- context.fErrors->error(offset, "construction of array type '" + type.displayName() +
- "' is not supported");
+ context.fErrors->error(line, "construction of array type '" + type.displayName() +
+ "' is not supported");
return nullptr;
}
@@ -33,16 +33,16 @@
const Type& exprType = expr.type();
if (exprType.isArray() && exprType.canCoerceTo(type, /*allowNarrowing=*/true)) {
- return ConstructorArrayCast::Make(context, offset, type, std::move(args.front()));
+ return ConstructorArrayCast::Make(context, line, type, std::move(args.front()));
}
}
// Check that the number of constructor arguments matches the array size.
if (type.columns() != args.count()) {
- context.fErrors->error(offset, String::printf("invalid arguments to '%s' constructor "
- "(expected %d elements, but found %d)",
- type.displayName().c_str(), type.columns(),
- args.count()));
+ context.fErrors->error(line, String::printf("invalid arguments to '%s' constructor "
+ "(expected %d elements, but found %d)",
+ type.displayName().c_str(), type.columns(),
+ args.count()));
return nullptr;
}
@@ -55,11 +55,11 @@
}
}
- return ConstructorArray::Make(context, offset, type, std::move(args));
+ return ConstructorArray::Make(context, line, type, std::move(args));
}
std::unique_ptr<Expression> ConstructorArray::Make(const Context& context,
- int offset,
+ int line,
const Type& type,
ExpressionArray args) {
SkASSERT(!context.fConfig->strictES2Mode());
@@ -68,7 +68,7 @@
return type.componentType() == arg->type();
}));
- return std::make_unique<ConstructorArray>(offset, type, std::move(args));
+ return std::make_unique<ConstructorArray>(line, type, std::move(args));
}
} // namespace SkSL
diff --git a/src/sksl/ir/SkSLConstructorArray.h b/src/sksl/ir/SkSLConstructorArray.h
index 139de52..3d8cb00 100644
--- a/src/sksl/ir/SkSLConstructorArray.h
+++ b/src/sksl/ir/SkSLConstructorArray.h
@@ -19,24 +19,24 @@
public:
static constexpr Kind kExpressionKind = Kind::kConstructorArray;
- ConstructorArray(int offset, const Type& type, ExpressionArray arguments)
- : INHERITED(offset, kExpressionKind, &type, std::move(arguments)) {}
+ ConstructorArray(int line, const Type& type, ExpressionArray arguments)
+ : INHERITED(line, kExpressionKind, &type, std::move(arguments)) {}
// ConstructorArray::Convert will typecheck and create array-constructor expressions.
// Reports errors via the ErrorReporter; returns null on error.
static std::unique_ptr<Expression> Convert(const Context& context,
- int offset,
+ int line,
const Type& type,
ExpressionArray args);
// ConstructorArray::Make creates array-constructor expressions; errors reported via SkASSERT.
static std::unique_ptr<Expression> Make(const Context& context,
- int offset,
+ int line,
const Type& type,
ExpressionArray args);
std::unique_ptr<Expression> clone() const override {
- return std::make_unique<ConstructorArray>(fOffset, this->type(), this->cloneArguments());
+ return std::make_unique<ConstructorArray>(fLine, this->type(), this->cloneArguments());
}
private:
diff --git a/src/sksl/ir/SkSLConstructorArrayCast.cpp b/src/sksl/ir/SkSLConstructorArrayCast.cpp
index 8d52c46..46c97d4 100644
--- a/src/sksl/ir/SkSLConstructorArrayCast.cpp
+++ b/src/sksl/ir/SkSLConstructorArrayCast.cpp
@@ -24,21 +24,21 @@
ExpressionArray typecastArgs;
typecastArgs.reserve_back(inputArgs.size());
for (std::unique_ptr<Expression>& arg : inputArgs) {
- int offset = arg->fOffset;
+ int line = arg->fLine;
if (arg->type().isScalar()) {
- typecastArgs.push_back(ConstructorScalarCast::Make(context, offset, scalarType,
+ typecastArgs.push_back(ConstructorScalarCast::Make(context, line, scalarType,
std::move(arg)));
} else {
- typecastArgs.push_back(ConstructorCompoundCast::Make(context, offset, scalarType,
+ typecastArgs.push_back(ConstructorCompoundCast::Make(context, line, scalarType,
std::move(arg)));
}
}
- return ConstructorArray::Make(context, constCtor->fOffset, destType, std::move(typecastArgs));
+ return ConstructorArray::Make(context, constCtor->fLine, destType, std::move(typecastArgs));
}
std::unique_ptr<Expression> ConstructorArrayCast::Make(const Context& context,
- int offset,
+ int line,
const Type& type,
std::unique_ptr<Expression> arg) {
// Only arrays of the same size are allowed.
@@ -60,7 +60,7 @@
if (arg->isCompileTimeConstant()) {
return cast_constant_array(context, type, std::move(arg));
}
- return std::make_unique<ConstructorArrayCast>(offset, type, std::move(arg));
+ return std::make_unique<ConstructorArrayCast>(line, type, std::move(arg));
}
} // namespace SkSL
diff --git a/src/sksl/ir/SkSLConstructorArrayCast.h b/src/sksl/ir/SkSLConstructorArrayCast.h
index 765f75b..eed87fe 100644
--- a/src/sksl/ir/SkSLConstructorArrayCast.h
+++ b/src/sksl/ir/SkSLConstructorArrayCast.h
@@ -28,11 +28,11 @@
public:
static constexpr Kind kExpressionKind = Kind::kConstructorArrayCast;
- ConstructorArrayCast(int offset, const Type& type, std::unique_ptr<Expression> arg)
- : INHERITED(offset, kExpressionKind, &type, std::move(arg)) {}
+ ConstructorArrayCast(int line, const Type& type, std::unique_ptr<Expression> arg)
+ : INHERITED(line, kExpressionKind, &type, std::move(arg)) {}
static std::unique_ptr<Expression> Make(const Context& context,
- int offset,
+ int line,
const Type& type,
std::unique_ptr<Expression> arg);
@@ -42,7 +42,7 @@
}
std::unique_ptr<Expression> clone() const override {
- return std::make_unique<ConstructorArrayCast>(fOffset, this->type(), argument()->clone());
+ return std::make_unique<ConstructorArrayCast>(fLine, this->type(), argument()->clone());
}
private:
diff --git a/src/sksl/ir/SkSLConstructorCompound.cpp b/src/sksl/ir/SkSLConstructorCompound.cpp
index 7a93ec8..59a9a96 100644
--- a/src/sksl/ir/SkSLConstructorCompound.cpp
+++ b/src/sksl/ir/SkSLConstructorCompound.cpp
@@ -14,7 +14,7 @@
namespace SkSL {
std::unique_ptr<Expression> ConstructorCompound::Make(const Context& context,
- int offset,
+ int line,
const Type& type,
ExpressionArray args) {
// A scalar "composite" type with a single scalar argument is a no-op and can be eliminated.
@@ -80,7 +80,7 @@
arg = ConstantFolder::MakeConstantValueForVariable(std::move(arg));
}
- return std::make_unique<ConstructorCompound>(offset, type, std::move(args));
+ return std::make_unique<ConstructorCompound>(line, type, std::move(args));
}
} // namespace SkSL
diff --git a/src/sksl/ir/SkSLConstructorCompound.h b/src/sksl/ir/SkSLConstructorCompound.h
index c315d62..d5276ce 100644
--- a/src/sksl/ir/SkSLConstructorCompound.h
+++ b/src/sksl/ir/SkSLConstructorCompound.h
@@ -28,16 +28,16 @@
public:
static constexpr Kind kExpressionKind = Kind::kConstructorCompound;
- ConstructorCompound(int offset, const Type& type, ExpressionArray args)
- : INHERITED(offset, kExpressionKind, &type, std::move(args)) {}
+ ConstructorCompound(int line, const Type& type, ExpressionArray args)
+ : INHERITED(line, kExpressionKind, &type, std::move(args)) {}
static std::unique_ptr<Expression> Make(const Context& context,
- int offset,
+ int line,
const Type& type,
ExpressionArray args);
std::unique_ptr<Expression> clone() const override {
- return std::make_unique<ConstructorCompound>(fOffset, this->type(), this->cloneArguments());
+ return std::make_unique<ConstructorCompound>(fLine, this->type(), this->cloneArguments());
}
private:
diff --git a/src/sksl/ir/SkSLConstructorCompoundCast.cpp b/src/sksl/ir/SkSLConstructorCompoundCast.cpp
index fd2fdbe..e96c3d0 100644
--- a/src/sksl/ir/SkSLConstructorCompoundCast.cpp
+++ b/src/sksl/ir/SkSLConstructorCompoundCast.cpp
@@ -29,8 +29,8 @@
// replace it with a splat of a different type, e.g. `int4(7)`.
ConstructorSplat& splat = constCtor->as<ConstructorSplat>();
return ConstructorSplat::Make(
- context, constCtor->fOffset, destType,
- ConstructorScalarCast::Make(context, constCtor->fOffset, scalarType,
+ context, constCtor->fLine, destType,
+ ConstructorScalarCast::Make(context, constCtor->fLine, scalarType,
std::move(splat.argument())));
}
@@ -39,8 +39,8 @@
// with a diagonal matrix of a different type, e.g. `half3x3(2)`.
ConstructorDiagonalMatrix& matrixCtor = constCtor->as<ConstructorDiagonalMatrix>();
return ConstructorDiagonalMatrix::Make(
- context, constCtor->fOffset, destType,
- ConstructorScalarCast::Make(context, constCtor->fOffset, scalarType,
+ context, constCtor->fLine, destType,
+ ConstructorScalarCast::Make(context, constCtor->fLine, scalarType,
std::move(matrixCtor.argument())));
}
@@ -52,16 +52,16 @@
typecastArgs.reserve_back(numSlots);
for (size_t index = 0; index < numSlots; ++index) {
const Expression* arg = constCtor->getConstantSubexpression(index);
- typecastArgs.push_back(ConstructorScalarCast::Make(context, constCtor->fOffset, scalarType,
+ typecastArgs.push_back(ConstructorScalarCast::Make(context, constCtor->fLine, scalarType,
arg->clone()));
}
- return ConstructorCompound::Make(context, constCtor->fOffset, destType,
+ return ConstructorCompound::Make(context, constCtor->fLine, destType,
std::move(typecastArgs));
}
std::unique_ptr<Expression> ConstructorCompoundCast::Make(const Context& context,
- int offset,
+ int line,
const Type& type,
std::unique_ptr<Expression> arg) {
// Only vectors or matrices of the same dimensions are allowed.
@@ -85,7 +85,7 @@
if (arg->isCompileTimeConstant()) {
return cast_constant_composite(context, type, std::move(arg));
}
- return std::make_unique<ConstructorCompoundCast>(offset, type, std::move(arg));
+ return std::make_unique<ConstructorCompoundCast>(line, type, std::move(arg));
}
} // namespace SkSL
diff --git a/src/sksl/ir/SkSLConstructorCompoundCast.h b/src/sksl/ir/SkSLConstructorCompoundCast.h
index 1f5d0f3..07c1f1e 100644
--- a/src/sksl/ir/SkSLConstructorCompoundCast.h
+++ b/src/sksl/ir/SkSLConstructorCompoundCast.h
@@ -26,11 +26,11 @@
public:
static constexpr Kind kExpressionKind = Kind::kConstructorCompoundCast;
- ConstructorCompoundCast(int offset, const Type& type, std::unique_ptr<Expression> arg)
- : INHERITED(offset, kExpressionKind, &type, std::move(arg)) {}
+ ConstructorCompoundCast(int line, const Type& type, std::unique_ptr<Expression> arg)
+ : INHERITED(line, kExpressionKind, &type, std::move(arg)) {}
static std::unique_ptr<Expression> Make(const Context& context,
- int offset,
+ int line,
const Type& type,
std::unique_ptr<Expression> arg);
@@ -40,8 +40,7 @@
}
std::unique_ptr<Expression> clone() const override {
- return std::make_unique<ConstructorCompoundCast>(fOffset, this->type(),
- argument()->clone());
+ return std::make_unique<ConstructorCompoundCast>(fLine, this->type(), argument()->clone());
}
private:
diff --git a/src/sksl/ir/SkSLConstructorDiagonalMatrix.cpp b/src/sksl/ir/SkSLConstructorDiagonalMatrix.cpp
index 8c55d43..1762df6 100644
--- a/src/sksl/ir/SkSLConstructorDiagonalMatrix.cpp
+++ b/src/sksl/ir/SkSLConstructorDiagonalMatrix.cpp
@@ -13,13 +13,13 @@
namespace SkSL {
std::unique_ptr<Expression> ConstructorDiagonalMatrix::Make(const Context& context,
- int offset,
+ int line,
const Type& type,
std::unique_ptr<Expression> arg) {
SkASSERT(type.isMatrix());
SkASSERT(arg->type().isScalar());
SkASSERT(arg->type() == type.componentType());
- return std::make_unique<ConstructorDiagonalMatrix>(offset, type, std::move(arg));
+ return std::make_unique<ConstructorDiagonalMatrix>(line, type, std::move(arg));
}
const Expression* ConstructorDiagonalMatrix::getConstantSubexpression(int n) const {
diff --git a/src/sksl/ir/SkSLConstructorDiagonalMatrix.h b/src/sksl/ir/SkSLConstructorDiagonalMatrix.h
index e8c3b91..ec226d2 100644
--- a/src/sksl/ir/SkSLConstructorDiagonalMatrix.h
+++ b/src/sksl/ir/SkSLConstructorDiagonalMatrix.h
@@ -26,17 +26,17 @@
public:
static constexpr Kind kExpressionKind = Kind::kConstructorDiagonalMatrix;
- ConstructorDiagonalMatrix(int offset, const Type& type, std::unique_ptr<Expression> arg)
- : INHERITED(offset, kExpressionKind, &type, std::move(arg))
- , fZeroLiteral(offset, /*value=*/0.0, &type.componentType()) {}
+ ConstructorDiagonalMatrix(int line, const Type& type, std::unique_ptr<Expression> arg)
+ : INHERITED(line, kExpressionKind, &type, std::move(arg))
+ , fZeroLiteral(line, /*value=*/0.0, &type.componentType()) {}
static std::unique_ptr<Expression> Make(const Context& context,
- int offset,
+ int line,
const Type& type,
std::unique_ptr<Expression> arg);
std::unique_ptr<Expression> clone() const override {
- return std::make_unique<ConstructorDiagonalMatrix>(fOffset, this->type(),
+ return std::make_unique<ConstructorDiagonalMatrix>(fLine, this->type(),
argument()->clone());
}
diff --git a/src/sksl/ir/SkSLConstructorMatrixResize.cpp b/src/sksl/ir/SkSLConstructorMatrixResize.cpp
index 4c8b374..3639e4c 100644
--- a/src/sksl/ir/SkSLConstructorMatrixResize.cpp
+++ b/src/sksl/ir/SkSLConstructorMatrixResize.cpp
@@ -13,7 +13,7 @@
namespace SkSL {
std::unique_ptr<Expression> ConstructorMatrixResize::Make(const Context& context,
- int offset,
+ int line,
const Type& type,
std::unique_ptr<Expression> arg) {
SkASSERT(type.isMatrix());
@@ -24,7 +24,7 @@
return arg;
}
- return std::make_unique<ConstructorMatrixResize>(offset, type, std::move(arg));
+ return std::make_unique<ConstructorMatrixResize>(line, type, std::move(arg));
}
const Expression* ConstructorMatrixResize::getConstantSubexpression(int n) const {
diff --git a/src/sksl/ir/SkSLConstructorMatrixResize.h b/src/sksl/ir/SkSLConstructorMatrixResize.h
index 2c8b738..ad47bd2 100644
--- a/src/sksl/ir/SkSLConstructorMatrixResize.h
+++ b/src/sksl/ir/SkSLConstructorMatrixResize.h
@@ -27,18 +27,18 @@
public:
static constexpr Kind kExpressionKind = Kind::kConstructorMatrixResize;
- ConstructorMatrixResize(int offset, const Type& type, std::unique_ptr<Expression> arg)
- : INHERITED(offset, kExpressionKind, &type, std::move(arg))
- , fZeroLiteral(offset, /*value=*/0.0, &type.componentType())
- , fOneLiteral(offset, /*value=*/1.0, &type.componentType()) {}
+ ConstructorMatrixResize(int line, const Type& type, std::unique_ptr<Expression> arg)
+ : INHERITED(line, kExpressionKind, &type, std::move(arg))
+ , fZeroLiteral(line, /*value=*/0.0, &type.componentType())
+ , fOneLiteral(line, /*value=*/1.0, &type.componentType()) {}
static std::unique_ptr<Expression> Make(const Context& context,
- int offset,
+ int line,
const Type& type,
std::unique_ptr<Expression> arg);
std::unique_ptr<Expression> clone() const override {
- return std::make_unique<ConstructorMatrixResize>(fOffset, this->type(),
+ return std::make_unique<ConstructorMatrixResize>(fLine, this->type(),
argument()->clone());
}
diff --git a/src/sksl/ir/SkSLConstructorScalarCast.cpp b/src/sksl/ir/SkSLConstructorScalarCast.cpp
index 7473608..a34b9e4 100644
--- a/src/sksl/ir/SkSLConstructorScalarCast.cpp
+++ b/src/sksl/ir/SkSLConstructorScalarCast.cpp
@@ -11,7 +11,7 @@
namespace SkSL {
std::unique_ptr<Expression> ConstructorScalarCast::Convert(const Context& context,
- int offset,
+ int line,
const Type& rawType,
ExpressionArray args) {
// As you might expect, scalar-cast constructors should only be created with scalar types.
@@ -19,9 +19,9 @@
SkASSERT(type.isScalar());
if (args.size() != 1) {
- context.fErrors->error(offset, "invalid arguments to '" + type.displayName() +
- "' constructor, (expected exactly 1 argument, but found " +
- to_string((uint64_t)args.size()) + ")");
+ context.fErrors->error(line, "invalid arguments to '" + type.displayName() +
+ "' constructor, (expected exactly 1 argument, but found " +
+ to_string((uint64_t)args.size()) + ")");
return nullptr;
}
@@ -38,17 +38,17 @@
}
}
- context.fErrors->error(offset,
+ context.fErrors->error(line,
"'" + argType.displayName() + "' is not a valid parameter to '" +
type.displayName() + "' constructor" + swizzleHint);
return nullptr;
}
- return ConstructorScalarCast::Make(context, offset, type, std::move(args[0]));
+ return ConstructorScalarCast::Make(context, line, type, std::move(args[0]));
}
std::unique_ptr<Expression> ConstructorScalarCast::Make(const Context& context,
- int offset,
+ int line,
const Type& type,
std::unique_ptr<Expression> arg) {
SkASSERT(type.isScalar());
@@ -65,9 +65,9 @@
}
// We can cast scalar literals at compile-time.
if (arg->is<Literal>()) {
- return Literal::Make(offset, arg->as<Literal>().value(), &type);
+ return Literal::Make(line, arg->as<Literal>().value(), &type);
}
- return std::make_unique<ConstructorScalarCast>(offset, type, std::move(arg));
+ return std::make_unique<ConstructorScalarCast>(line, type, std::move(arg));
}
} // namespace SkSL
diff --git a/src/sksl/ir/SkSLConstructorScalarCast.h b/src/sksl/ir/SkSLConstructorScalarCast.h
index 3c0bfc5..bf4dce7 100644
--- a/src/sksl/ir/SkSLConstructorScalarCast.h
+++ b/src/sksl/ir/SkSLConstructorScalarCast.h
@@ -26,25 +26,25 @@
public:
static constexpr Kind kExpressionKind = Kind::kConstructorScalarCast;
- ConstructorScalarCast(int offset, const Type& type, std::unique_ptr<Expression> arg)
- : INHERITED(offset, kExpressionKind, &type, std::move(arg)) {}
+ ConstructorScalarCast(int line, const Type& type, std::unique_ptr<Expression> arg)
+ : INHERITED(line, kExpressionKind, &type, std::move(arg)) {}
// ConstructorScalarCast::Convert will typecheck and create scalar-constructor expressions.
// Reports errors via the ErrorReporter; returns null on error.
static std::unique_ptr<Expression> Convert(const Context& context,
- int offset,
+ int line,
const Type& rawType,
ExpressionArray args);
// ConstructorScalarCast::Make casts a scalar expression. Casts that can be evaluated at
// compile-time will do so (e.g. `int(4.1)` --> `Literal(int 4)`). Errors reported via SkASSERT.
static std::unique_ptr<Expression> Make(const Context& context,
- int offset,
+ int line,
const Type& type,
std::unique_ptr<Expression> arg);
std::unique_ptr<Expression> clone() const override {
- return std::make_unique<ConstructorScalarCast>(fOffset, this->type(), argument()->clone());
+ return std::make_unique<ConstructorScalarCast>(fLine, this->type(), argument()->clone());
}
bool isCompileTimeConstant() const override {
diff --git a/src/sksl/ir/SkSLConstructorSplat.cpp b/src/sksl/ir/SkSLConstructorSplat.cpp
index aba519f..54d30bf 100644
--- a/src/sksl/ir/SkSLConstructorSplat.cpp
+++ b/src/sksl/ir/SkSLConstructorSplat.cpp
@@ -11,7 +11,7 @@
namespace SkSL {
std::unique_ptr<Expression> ConstructorSplat::Make(const Context& context,
- int offset,
+ int line,
const Type& type,
std::unique_ptr<Expression> arg) {
SkASSERT(arg->type().scalarTypeForLiteral() == type.componentType().scalarTypeForLiteral());
@@ -29,7 +29,7 @@
}
SkASSERT(type.isVector());
- return std::make_unique<ConstructorSplat>(offset, type, std::move(arg));
+ return std::make_unique<ConstructorSplat>(line, type, std::move(arg));
}
} // namespace SkSL
diff --git a/src/sksl/ir/SkSLConstructorSplat.h b/src/sksl/ir/SkSLConstructorSplat.h
index 0409bee..eb9cd59 100644
--- a/src/sksl/ir/SkSLConstructorSplat.h
+++ b/src/sksl/ir/SkSLConstructorSplat.h
@@ -25,17 +25,17 @@
public:
static constexpr Kind kExpressionKind = Kind::kConstructorSplat;
- ConstructorSplat(int offset, const Type& type, std::unique_ptr<Expression> arg)
- : INHERITED(offset, kExpressionKind, &type, std::move(arg)) {}
+ ConstructorSplat(int line, const Type& type, std::unique_ptr<Expression> arg)
+ : INHERITED(line, kExpressionKind, &type, std::move(arg)) {}
// The input argument must be scalar. A "splat" to a scalar type will be optimized into a no-op.
static std::unique_ptr<Expression> Make(const Context& context,
- int offset,
+ int line,
const Type& type,
std::unique_ptr<Expression> arg);
std::unique_ptr<Expression> clone() const override {
- return std::make_unique<ConstructorSplat>(fOffset, this->type(), argument()->clone());
+ return std::make_unique<ConstructorSplat>(fLine, this->type(), argument()->clone());
}
bool allowsConstantSubexpressions() const override {
diff --git a/src/sksl/ir/SkSLConstructorStruct.cpp b/src/sksl/ir/SkSLConstructorStruct.cpp
index b5e9947..ab062e1 100644
--- a/src/sksl/ir/SkSLConstructorStruct.cpp
+++ b/src/sksl/ir/SkSLConstructorStruct.cpp
@@ -10,14 +10,14 @@
namespace SkSL {
std::unique_ptr<Expression> ConstructorStruct::Convert(const Context& context,
- int offset,
+ int line,
const Type& type,
ExpressionArray args) {
SkASSERTF(type.isStruct() && type.fields().size() > 0, "%s", type.description().c_str());
// Check that the number of constructor arguments matches the array size.
if (type.fields().size() != args.size()) {
- context.fErrors->error(offset,
+ context.fErrors->error(line,
String::printf("invalid arguments to '%s' constructor "
"(expected %zu elements, but found %zu)",
type.displayName().c_str(), type.fields().size(),
@@ -36,7 +36,7 @@
}
}
- return ConstructorStruct::Make(context, offset, type, std::move(args));
+ return ConstructorStruct::Make(context, line, type, std::move(args));
}
[[maybe_unused]] static bool arguments_match_field_types(const ExpressionArray& args,
@@ -55,11 +55,11 @@
}
std::unique_ptr<Expression> ConstructorStruct::Make(const Context& context,
- int offset,
+ int line,
const Type& type,
ExpressionArray args) {
SkASSERT(arguments_match_field_types(args, type));
- return std::make_unique<ConstructorStruct>(offset, type, std::move(args));
+ return std::make_unique<ConstructorStruct>(line, type, std::move(args));
}
} // namespace SkSL
diff --git a/src/sksl/ir/SkSLConstructorStruct.h b/src/sksl/ir/SkSLConstructorStruct.h
index e578e87..154545d 100644
--- a/src/sksl/ir/SkSLConstructorStruct.h
+++ b/src/sksl/ir/SkSLConstructorStruct.h
@@ -19,24 +19,24 @@
public:
static constexpr Kind kExpressionKind = Kind::kConstructorStruct;
- ConstructorStruct(int offset, const Type& type, ExpressionArray arguments)
- : INHERITED(offset, kExpressionKind, &type, std::move(arguments)) {}
+ ConstructorStruct(int line, const Type& type, ExpressionArray arguments)
+ : INHERITED(line, kExpressionKind, &type, std::move(arguments)) {}
// ConstructorStruct::Convert will typecheck and create struct-constructor expressions.
// Reports errors via the ErrorReporter; returns null on error.
static std::unique_ptr<Expression> Convert(const Context& context,
- int offset,
+ int line,
const Type& type,
ExpressionArray args);
// ConstructorStruct::Make creates struct-constructor expressions; errors reported via SkASSERT.
static std::unique_ptr<Expression> Make(const Context& context,
- int offset,
+ int line,
const Type& type,
ExpressionArray args);
std::unique_ptr<Expression> clone() const override {
- return std::make_unique<ConstructorStruct>(fOffset, this->type(), this->cloneArguments());
+ return std::make_unique<ConstructorStruct>(fLine, this->type(), this->cloneArguments());
}
private:
diff --git a/src/sksl/ir/SkSLContinueStatement.h b/src/sksl/ir/SkSLContinueStatement.h
index 959a95e..2ab951d 100644
--- a/src/sksl/ir/SkSLContinueStatement.h
+++ b/src/sksl/ir/SkSLContinueStatement.h
@@ -20,15 +20,15 @@
public:
static constexpr Kind kStatementKind = Kind::kContinue;
- ContinueStatement(int offset)
- : INHERITED(offset, kStatementKind) {}
+ ContinueStatement(int line)
+ : INHERITED(line, kStatementKind) {}
- static std::unique_ptr<Statement> Make(int offset) {
- return std::make_unique<ContinueStatement>(offset);
+ static std::unique_ptr<Statement> Make(int line) {
+ return std::make_unique<ContinueStatement>(line);
}
std::unique_ptr<Statement> clone() const override {
- return std::make_unique<ContinueStatement>(fOffset);
+ return std::make_unique<ContinueStatement>(fLine);
}
String description() const override {
diff --git a/src/sksl/ir/SkSLDiscardStatement.h b/src/sksl/ir/SkSLDiscardStatement.h
index df9a54a..643cb38 100644
--- a/src/sksl/ir/SkSLDiscardStatement.h
+++ b/src/sksl/ir/SkSLDiscardStatement.h
@@ -20,15 +20,15 @@
public:
static constexpr Kind kStatementKind = Kind::kDiscard;
- DiscardStatement(int offset)
- : INHERITED(offset, kStatementKind) {}
+ DiscardStatement(int line)
+ : INHERITED(line, kStatementKind) {}
- static std::unique_ptr<Statement> Make(int offset) {
- return std::make_unique<DiscardStatement>(offset);
+ static std::unique_ptr<Statement> Make(int line) {
+ return std::make_unique<DiscardStatement>(line);
}
std::unique_ptr<Statement> clone() const override {
- return std::make_unique<DiscardStatement>(fOffset);
+ return std::make_unique<DiscardStatement>(fLine);
}
String description() const override {
diff --git a/src/sksl/ir/SkSLDoStatement.cpp b/src/sksl/ir/SkSLDoStatement.cpp
index 8d159d0..b0883f0 100644
--- a/src/sksl/ir/SkSLDoStatement.cpp
+++ b/src/sksl/ir/SkSLDoStatement.cpp
@@ -18,7 +18,7 @@
std::unique_ptr<Statement> stmt,
std::unique_ptr<Expression> test) {
if (context.fConfig->strictES2Mode()) {
- context.fErrors->error(stmt->fOffset, "do-while loops are not supported");
+ context.fErrors->error(stmt->fLine, "do-while loops are not supported");
return nullptr;
}
test = context.fTypes.fBool->coerceExpression(std::move(test), context);
@@ -37,11 +37,11 @@
SkASSERT(!context.fConfig->strictES2Mode());
SkASSERT(test->type() == *context.fTypes.fBool);
SkASSERT(!Analysis::DetectVarDeclarationWithoutScope(*stmt));
- return std::make_unique<DoStatement>(stmt->fOffset, std::move(stmt), std::move(test));
+ return std::make_unique<DoStatement>(stmt->fLine, std::move(stmt), std::move(test));
}
std::unique_ptr<Statement> DoStatement::clone() const {
- return std::make_unique<DoStatement>(fOffset, this->statement()->clone(),
+ return std::make_unique<DoStatement>(fLine, this->statement()->clone(),
this->test()->clone());
}
diff --git a/src/sksl/ir/SkSLDoStatement.h b/src/sksl/ir/SkSLDoStatement.h
index 068f20e..d3d9162 100644
--- a/src/sksl/ir/SkSLDoStatement.h
+++ b/src/sksl/ir/SkSLDoStatement.h
@@ -20,8 +20,8 @@
public:
static constexpr Kind kStatementKind = Kind::kDo;
- DoStatement(int offset, std::unique_ptr<Statement> statement, std::unique_ptr<Expression> test)
- : INHERITED(offset, kStatementKind)
+ DoStatement(int line, std::unique_ptr<Statement> statement, std::unique_ptr<Expression> test)
+ : INHERITED(line, kStatementKind)
, fStatement(std::move(statement))
, fTest(std::move(test)) {}
diff --git a/src/sksl/ir/SkSLExpression.h b/src/sksl/ir/SkSLExpression.h
index ce07e4e..eee4e83 100644
--- a/src/sksl/ir/SkSLExpression.h
+++ b/src/sksl/ir/SkSLExpression.h
@@ -65,8 +65,8 @@
kContainsRTAdjust
};
- Expression(int offset, Kind kind, const Type* type)
- : INHERITED(offset, (int) kind)
+ Expression(int line, Kind kind, const Type* type)
+ : INHERITED(line, (int) kind)
, fType(type) {
SkASSERT(kind >= Kind::kFirst && kind <= Kind::kLast);
}
diff --git a/src/sksl/ir/SkSLExpressionStatement.h b/src/sksl/ir/SkSLExpressionStatement.h
index bcd1fdd..f7177b2 100644
--- a/src/sksl/ir/SkSLExpressionStatement.h
+++ b/src/sksl/ir/SkSLExpressionStatement.h
@@ -21,7 +21,7 @@
static constexpr Kind kStatementKind = Kind::kExpression;
ExpressionStatement(std::unique_ptr<Expression> expression)
- : INHERITED(expression->fOffset, kStatementKind)
+ : INHERITED(expression->fLine, kStatementKind)
, fExpression(std::move(expression)) {}
// Creates an SkSL expression-statement. Note that there is never any type-coercion and no error
diff --git a/src/sksl/ir/SkSLExtension.h b/src/sksl/ir/SkSLExtension.h
index 1894d7e..28cf6ff 100644
--- a/src/sksl/ir/SkSLExtension.h
+++ b/src/sksl/ir/SkSLExtension.h
@@ -19,8 +19,8 @@
public:
static constexpr Kind kProgramElementKind = Kind::kExtension;
- Extension(int offset, skstd::string_view name)
- : INHERITED(offset, kProgramElementKind)
+ Extension(int line, skstd::string_view name)
+ : INHERITED(line, kProgramElementKind)
, fName(name) {}
skstd::string_view name() const {
@@ -28,7 +28,7 @@
}
std::unique_ptr<ProgramElement> clone() const override {
- return std::unique_ptr<ProgramElement>(new Extension(fOffset, this->name()));
+ return std::unique_ptr<ProgramElement>(new Extension(fLine, this->name()));
}
String description() const override {
diff --git a/src/sksl/ir/SkSLExternalFunctionCall.h b/src/sksl/ir/SkSLExternalFunctionCall.h
index 61c9425..35958fd 100644
--- a/src/sksl/ir/SkSLExternalFunctionCall.h
+++ b/src/sksl/ir/SkSLExternalFunctionCall.h
@@ -22,8 +22,8 @@
public:
static constexpr Kind kExpressionKind = Kind::kExternalFunctionCall;
- ExternalFunctionCall(int offset, const ExternalFunction* function, ExpressionArray arguments)
- : INHERITED(offset, kExpressionKind, &function->type())
+ ExternalFunctionCall(int line, const ExternalFunction* function, ExpressionArray arguments)
+ : INHERITED(line, kExpressionKind, &function->type())
, fFunction(*function)
, fArguments(std::move(arguments)) {}
@@ -57,7 +57,7 @@
for (const auto& arg : this->arguments()) {
cloned.push_back(arg->clone());
}
- return std::make_unique<ExternalFunctionCall>(fOffset, &this->function(),
+ return std::make_unique<ExternalFunctionCall>(fLine, &this->function(),
std::move(cloned));
}
diff --git a/src/sksl/ir/SkSLExternalFunctionReference.h b/src/sksl/ir/SkSLExternalFunctionReference.h
index 5605b98..c63a890 100644
--- a/src/sksl/ir/SkSLExternalFunctionReference.h
+++ b/src/sksl/ir/SkSLExternalFunctionReference.h
@@ -22,8 +22,8 @@
public:
static constexpr Kind kExpressionKind = Kind::kExternalFunctionReference;
- ExternalFunctionReference(int offset, const ExternalFunction* ef)
- : INHERITED(offset, kExpressionKind, &ef->type())
+ ExternalFunctionReference(int line, const ExternalFunction* ef)
+ : INHERITED(line, kExpressionKind, &ef->type())
, fFunction(*ef) {}
const ExternalFunction& function() const {
@@ -39,7 +39,7 @@
}
std::unique_ptr<Expression> clone() const override {
- return std::make_unique<ExternalFunctionReference>(fOffset, &this->function());
+ return std::make_unique<ExternalFunctionReference>(fLine, &this->function());
}
private:
diff --git a/src/sksl/ir/SkSLField.h b/src/sksl/ir/SkSLField.h
index c09572e..09275f4 100644
--- a/src/sksl/ir/SkSLField.h
+++ b/src/sksl/ir/SkSLField.h
@@ -24,8 +24,8 @@
public:
static constexpr Kind kSymbolKind = Kind::kField;
- Field(int offset, const Variable* owner, int fieldIndex)
- : INHERITED(offset, kSymbolKind, owner->type().fields()[fieldIndex].fName,
+ Field(int line, const Variable* owner, int fieldIndex)
+ : INHERITED(line, kSymbolKind, owner->type().fields()[fieldIndex].fName,
owner->type().fields()[fieldIndex].fType)
, fOwner(owner)
, fFieldIndex(fieldIndex) {}
diff --git a/src/sksl/ir/SkSLFieldAccess.cpp b/src/sksl/ir/SkSLFieldAccess.cpp
index 6aea8c6..4210007 100644
--- a/src/sksl/ir/SkSLFieldAccess.cpp
+++ b/src/sksl/ir/SkSLFieldAccess.cpp
@@ -29,19 +29,19 @@
std::vector<const FunctionDeclaration*> f = {
&result->as<FunctionDeclaration>()};
return std::make_unique<MethodReference>(
- context, base->fOffset, std::move(base), f);
+ context, base->fLine, std::move(base), f);
}
case Symbol::Kind::kUnresolvedFunction: {
const UnresolvedFunction& f = result->as<UnresolvedFunction>();
return std::make_unique<MethodReference>(
- context, base->fOffset, std::move(base), f.functions());
+ context, base->fLine, std::move(base), f.functions());
}
default:
break;
}
}
context.fErrors->error(
- base->fOffset,
+ base->fLine,
"type '" + baseType.displayName() + "' has no method named '" + field + "'");
return nullptr;
}
@@ -54,10 +54,10 @@
}
}
if (baseType == *context.fTypes.fSkCaps) {
- return Setting::Convert(context, base->fOffset, field);
+ return Setting::Convert(context, base->fLine, field);
}
- context.fErrors->error(base->fOffset, "type '" + baseType.displayName() +
+ context.fErrors->error(base->fLine, "type '" + baseType.displayName() +
"' does not have a field named '" + field + "'");
return nullptr;
}
diff --git a/src/sksl/ir/SkSLFieldAccess.h b/src/sksl/ir/SkSLFieldAccess.h
index a5cbc92..f1df7cb 100644
--- a/src/sksl/ir/SkSLFieldAccess.h
+++ b/src/sksl/ir/SkSLFieldAccess.h
@@ -31,7 +31,7 @@
FieldAccess(std::unique_ptr<Expression> base, int fieldIndex,
OwnerKind ownerKind = OwnerKind::kDefault)
- : INHERITED(base->fOffset, kExpressionKind, base->type().fields()[fieldIndex].fType)
+ : INHERITED(base->fLine, kExpressionKind, base->type().fields()[fieldIndex].fType)
, fFieldIndex(fieldIndex)
, fOwnerKind(ownerKind)
, fBase(std::move(base)) {}
diff --git a/src/sksl/ir/SkSLForStatement.cpp b/src/sksl/ir/SkSLForStatement.cpp
index 9f8eb97..0c88553 100644
--- a/src/sksl/ir/SkSLForStatement.cpp
+++ b/src/sksl/ir/SkSLForStatement.cpp
@@ -48,7 +48,7 @@
}
return std::make_unique<ForStatement>(
- fOffset,
+ fLine,
this->initializer() ? this->initializer()->clone() : nullptr,
this->test() ? this->test()->clone() : nullptr,
this->next() ? this->next()->clone() : nullptr,
@@ -76,7 +76,7 @@
return result;
}
-std::unique_ptr<Statement> ForStatement::Convert(const Context& context, int offset,
+std::unique_ptr<Statement> ForStatement::Convert(const Context& context, int line,
std::unique_ptr<Statement> initializer,
std::unique_ptr<Expression> test,
std::unique_ptr<Expression> next,
@@ -87,7 +87,7 @@
!isSimpleInitializer && is_vardecl_block_initializer(initializer.get());
if (!isSimpleInitializer && !isVardeclBlockInitializer) {
- context.fErrors->error(initializer->fOffset, "invalid for loop initializer");
+ context.fErrors->error(initializer->fLine, "invalid for loop initializer");
return nullptr;
}
@@ -110,7 +110,7 @@
std::unique_ptr<LoopUnrollInfo> unrollInfo;
if (context.fConfig->strictES2Mode()) {
- unrollInfo = Analysis::GetLoopUnrollInfo(offset, initializer.get(), test.get(),
+ unrollInfo = Analysis::GetLoopUnrollInfo(line, initializer.get(), test.get(),
next.get(), statement.get(), context.fErrors);
if (!unrollInfo) {
return nullptr;
@@ -130,30 +130,30 @@
// unilaterally for all for-statements, because the resulting for loop isn't ES2-compliant.)
StatementArray scope;
scope.push_back(std::move(initializer));
- scope.push_back(ForStatement::Make(context, offset, /*initializer=*/nullptr,
+ scope.push_back(ForStatement::Make(context, line, /*initializer=*/nullptr,
std::move(test), std::move(next), std::move(statement),
std::move(unrollInfo), std::move(symbolTable)));
- return Block::Make(offset, std::move(scope));
+ return Block::Make(line, std::move(scope));
}
- return ForStatement::Make(context, offset, std::move(initializer), std::move(test),
+ return ForStatement::Make(context, line, std::move(initializer), std::move(test),
std::move(next), std::move(statement), std::move(unrollInfo),
std::move(symbolTable));
}
-std::unique_ptr<Statement> ForStatement::ConvertWhile(const Context& context, int offset,
+std::unique_ptr<Statement> ForStatement::ConvertWhile(const Context& context, int line,
std::unique_ptr<Expression> test,
std::unique_ptr<Statement> statement,
std::shared_ptr<SymbolTable> symbolTable) {
if (context.fConfig->strictES2Mode()) {
- context.fErrors->error(offset, "while loops are not supported");
+ context.fErrors->error(line, "while loops are not supported");
return nullptr;
}
- return ForStatement::Convert(context, offset, /*initializer=*/nullptr, std::move(test),
+ return ForStatement::Convert(context, line, /*initializer=*/nullptr, std::move(test),
/*next=*/nullptr, std::move(statement), std::move(symbolTable));
}
-std::unique_ptr<Statement> ForStatement::Make(const Context& context, int offset,
+std::unique_ptr<Statement> ForStatement::Make(const Context& context, int line,
std::unique_ptr<Statement> initializer,
std::unique_ptr<Expression> test,
std::unique_ptr<Expression> next,
@@ -167,12 +167,12 @@
// If the caller didn't provide us with unroll info, we can compute it here if needed.
if (!unrollInfo && context.fConfig->strictES2Mode()) {
- unrollInfo = Analysis::GetLoopUnrollInfo(offset, initializer.get(), test.get(),
+ unrollInfo = Analysis::GetLoopUnrollInfo(line, initializer.get(), test.get(),
next.get(), statement.get(), /*errors=*/nullptr);
SkASSERT(unrollInfo);
}
- return std::make_unique<ForStatement>(offset, std::move(initializer), std::move(test),
+ return std::make_unique<ForStatement>(line, std::move(initializer), std::move(test),
std::move(next), std::move(statement),
std::move(unrollInfo), std::move(symbolTable));
}
diff --git a/src/sksl/ir/SkSLForStatement.h b/src/sksl/ir/SkSLForStatement.h
index 2f98b8f..0aa1a4e 100644
--- a/src/sksl/ir/SkSLForStatement.h
+++ b/src/sksl/ir/SkSLForStatement.h
@@ -31,14 +31,14 @@
public:
static constexpr Kind kStatementKind = Kind::kFor;
- ForStatement(int offset,
+ ForStatement(int line,
std::unique_ptr<Statement> initializer,
std::unique_ptr<Expression> test,
std::unique_ptr<Expression> next,
std::unique_ptr<Statement> statement,
std::unique_ptr<LoopUnrollInfo> unrollInfo,
std::shared_ptr<SymbolTable> symbols)
- : INHERITED(offset, kStatementKind)
+ : INHERITED(line, kStatementKind)
, fSymbolTable(std::move(symbols))
, fInitializer(std::move(initializer))
, fTest(std::move(test))
@@ -47,7 +47,7 @@
, fUnrollInfo(std::move(unrollInfo)) {}
// Creates an SkSL for loop; handles type-coercion and uses the ErrorReporter to report errors.
- static std::unique_ptr<Statement> Convert(const Context& context, int offset,
+ static std::unique_ptr<Statement> Convert(const Context& context, int line,
std::unique_ptr<Statement> initializer,
std::unique_ptr<Expression> test,
std::unique_ptr<Expression> next,
@@ -55,13 +55,13 @@
std::shared_ptr<SymbolTable> symbolTable);
// Creates an SkSL while loop; handles type-coercion and uses the ErrorReporter for errors.
- static std::unique_ptr<Statement> ConvertWhile(const Context& context, int offset,
+ static std::unique_ptr<Statement> ConvertWhile(const Context& context, int line,
std::unique_ptr<Expression> test,
std::unique_ptr<Statement> statement,
std::shared_ptr<SymbolTable> symbolTable);
// Creates an SkSL for/while loop. Assumes properly coerced types and reports errors via assert.
- static std::unique_ptr<Statement> Make(const Context& context, int offset,
+ static std::unique_ptr<Statement> Make(const Context& context, int line,
std::unique_ptr<Statement> initializer,
std::unique_ptr<Expression> test,
std::unique_ptr<Expression> next,
diff --git a/src/sksl/ir/SkSLFunctionCall.cpp b/src/sksl/ir/SkSLFunctionCall.cpp
index 7b9d5b7..c9e9327 100644
--- a/src/sksl/ir/SkSLFunctionCall.cpp
+++ b/src/sksl/ir/SkSLFunctionCall.cpp
@@ -60,16 +60,16 @@
}
static std::unique_ptr<Expression> assemble_compound(const Context& context,
- int offset,
+ int line,
const Type& returnType,
double value[]) {
int numSlots = returnType.slotCount();
ExpressionArray array;
array.reserve_back(numSlots);
for (int index = 0; index < numSlots; ++index) {
- array.push_back(Literal::Make(offset, value[index], &returnType.componentType()));
+ array.push_back(Literal::Make(line, value[index], &returnType.componentType()));
}
- return ConstructorCompound::Make(context, offset, returnType, std::move(array));
+ return ConstructorCompound::Make(context, line, returnType, std::move(array));
}
using CoalesceFn = double (*)(double, double, double);
@@ -93,7 +93,7 @@
// of scalars and vectors, the scalars is interpreted as a vector containing the same value for
// every component.
- int offset = arg0->fOffset;
+ int line = arg0->fLine;
const Type& vecType = arg0->type().isVector() ? arg0->type() :
(arg1 && arg1->type().isVector()) ? arg1->type() :
@@ -128,7 +128,7 @@
value = finalize(value);
}
- return Literal::Make(offset, value, &returnType);
+ return Literal::Make(line, value, &returnType);
}
template <typename T>
@@ -188,7 +188,7 @@
}
const Type& bvecType = context.fTypes.fBool->toCompound(context, type.columns(), /*rows=*/1);
- return assemble_compound(context, left->fOffset, bvecType, array);
+ return assemble_compound(context, left->fLine, bvecType, array);
}
using EvaluateFn = double (*)(double, double, double);
@@ -243,7 +243,7 @@
}
}
- return assemble_compound(context, arg0->fOffset, returnType, array);
+ return assemble_compound(context, arg0->fLine, returnType, array);
}
template <typename T>
@@ -633,7 +633,7 @@
double vec[3] = {X(1) * Y(2) - Y(1) * X(2),
X(2) * Y(0) - Y(2) * X(0),
X(0) * Y(1) - Y(0) * X(1)};
- return assemble_compound(context, arguments[0]->fOffset, returnType, vec);
+ return assemble_compound(context, arguments[0]->fLine, returnType, vec);
}
case k_normalize_IntrinsicKind: {
auto Vec = [&] { return DSLExpression{arguments[0]->clone()}; };
@@ -678,7 +678,7 @@
mat[index++] = Get(0, (returnType.columns() * r) + c);
}
}
- return assemble_compound(context, arguments[0]->fOffset, returnType, mat);
+ return assemble_compound(context, arguments[0]->fLine, returnType, mat);
}
case k_outerProduct_IntrinsicKind: {
double mat[16];
@@ -688,7 +688,7 @@
mat[index++] = Get(0, r) * Get(1, c);
}
}
- return assemble_compound(context, arguments[0]->fOffset, returnType, mat);
+ return assemble_compound(context, arguments[0]->fLine, returnType, mat);
}
case k_determinant_IntrinsicKind: {
float mat[16];
@@ -708,7 +708,7 @@
SkDEBUGFAILF("unsupported type %s", arguments[0]->type().description().c_str());
return nullptr;
}
- return Literal::MakeFloat(arguments[0]->fOffset, determinant, &returnType);
+ return Literal::MakeFloat(arguments[0]->fLine, determinant, &returnType);
}
case k_inverse_IntrinsicKind: {
float mat[16] = {};
@@ -736,7 +736,7 @@
double dmat[16];
std::copy(mat, mat + SK_ARRAY_COUNT(mat), dmat);
- return assemble_compound(context, arguments[0]->fOffset, returnType, dmat);
+ return assemble_compound(context, arguments[0]->fLine, returnType, dmat);
}
// 8.7 : Vector Relational Functions
case k_lessThan_IntrinsicKind:
@@ -793,7 +793,7 @@
cloned.push_back(arg->clone());
}
return std::make_unique<FunctionCall>(
- fOffset, &this->type(), &this->function(), std::move(cloned));
+ fLine, &this->type(), &this->function(), std::move(cloned));
}
String FunctionCall::description() const {
@@ -809,12 +809,12 @@
}
std::unique_ptr<Expression> FunctionCall::Convert(const Context& context,
- int offset,
+ int line,
const FunctionDeclaration& function,
ExpressionArray arguments) {
// Reject ES3 function calls in strict ES2 mode.
if (context.fConfig->strictES2Mode() && (function.modifiers().fFlags & Modifiers::kES3_Flag)) {
- context.fErrors->error(offset, "call to '" + function.description() + "' is not supported");
+ context.fErrors->error(line, "call to '" + function.description() + "' is not supported");
return nullptr;
}
@@ -826,7 +826,7 @@
msg += "s";
}
msg += ", but found " + to_string(arguments.count());
- context.fErrors->error(offset, msg);
+ context.fErrors->error(line, msg);
return nullptr;
}
@@ -842,7 +842,7 @@
separator = ", ";
}
msg += ")";
- context.fErrors->error(offset, msg);
+ context.fErrors->error(line, msg);
return nullptr;
}
@@ -869,14 +869,14 @@
// handling in the generators and analysis code.
const Variable& child = *arguments.back()->as<VariableReference>().variable();
arguments.pop_back();
- return ChildCall::Make(context, offset, returnType, child, std::move(arguments));
+ return ChildCall::Make(context, line, returnType, child, std::move(arguments));
}
- return Make(context, offset, returnType, function, std::move(arguments));
+ return Make(context, line, returnType, function, std::move(arguments));
}
std::unique_ptr<Expression> FunctionCall::Make(const Context& context,
- int offset,
+ int line,
const Type* returnType,
const FunctionDeclaration& function,
ExpressionArray arguments) {
@@ -895,7 +895,7 @@
}
}
- return std::make_unique<FunctionCall>(offset, returnType, &function, std::move(arguments));
+ return std::make_unique<FunctionCall>(line, returnType, &function, std::move(arguments));
}
} // namespace SkSL
diff --git a/src/sksl/ir/SkSLFunctionCall.h b/src/sksl/ir/SkSLFunctionCall.h
index 7af940e..bb22c84 100644
--- a/src/sksl/ir/SkSLFunctionCall.h
+++ b/src/sksl/ir/SkSLFunctionCall.h
@@ -21,22 +21,22 @@
public:
static constexpr Kind kExpressionKind = Kind::kFunctionCall;
- FunctionCall(int offset, const Type* type, const FunctionDeclaration* function,
+ FunctionCall(int line, const Type* type, const FunctionDeclaration* function,
ExpressionArray arguments)
- : INHERITED(offset, kExpressionKind, type)
+ : INHERITED(line, kExpressionKind, type)
, fFunction(*function)
, fArguments(std::move(arguments)) {}
// Resolves generic types, performs type conversion on arguments, determines return type, and
// reports errors via the ErrorReporter.
static std::unique_ptr<Expression> Convert(const Context& context,
- int offset,
+ int line,
const FunctionDeclaration& function,
ExpressionArray arguments);
// Creates the function call; reports errors via ASSERT.
static std::unique_ptr<Expression> Make(const Context& context,
- int offset,
+ int line,
const Type* returnType,
const FunctionDeclaration& function,
ExpressionArray arguments);
diff --git a/src/sksl/ir/SkSLFunctionDeclaration.cpp b/src/sksl/ir/SkSLFunctionDeclaration.cpp
index 75ca0f1..8dc29a2 100644
--- a/src/sksl/ir/SkSLFunctionDeclaration.cpp
+++ b/src/sksl/ir/SkSLFunctionDeclaration.cpp
@@ -33,35 +33,35 @@
}
static bool check_modifiers(const Context& context,
- int offset,
+ int line,
const Modifiers& modifiers,
bool isBuiltin) {
const int permitted = Modifiers::kHasSideEffects_Flag |
Modifiers::kInline_Flag |
Modifiers::kNoInline_Flag |
(isBuiltin ? Modifiers::kES3_Flag : 0);
- IRGenerator::CheckModifiers(context, offset, modifiers, permitted, /*permittedLayoutFlags=*/0);
+ IRGenerator::CheckModifiers(context, line, modifiers, permitted, /*permittedLayoutFlags=*/0);
if ((modifiers.fFlags & Modifiers::kInline_Flag) &&
(modifiers.fFlags & Modifiers::kNoInline_Flag)) {
- context.fErrors->error(offset, "functions cannot be both 'inline' and 'noinline'");
+ context.fErrors->error(line, "functions cannot be both 'inline' and 'noinline'");
return false;
}
return true;
}
-static bool check_return_type(const Context& context, int offset, const Type& returnType,
+static bool check_return_type(const Context& context, int line, const Type& returnType,
bool isBuiltin) {
ErrorReporter& errors = *context.fErrors;
if (returnType.isArray()) {
- errors.error(offset, "functions may not return type '" + returnType.displayName() + "'");
+ errors.error(line, "functions may not return type '" + returnType.displayName() + "'");
return false;
}
if (context.fConfig->strictES2Mode() && returnType.isOrContainsArray()) {
- errors.error(offset, "functions may not return structs containing arrays");
+ errors.error(line, "functions may not return structs containing arrays");
return false;
}
if (!isBuiltin && !returnType.isVoid() && returnType.componentType().isOpaque()) {
- errors.error(offset, "functions may not return opaque type '" + returnType.displayName() +
+ errors.error(line, "functions may not return opaque type '" + returnType.displayName() +
"'");
return false;
}
@@ -81,7 +81,7 @@
// Check modifiers on each function parameter.
for (auto& param : parameters) {
- IRGenerator::CheckModifiers(context, param->fOffset, param->modifiers(),
+ IRGenerator::CheckModifiers(context, param->fLine, param->modifiers(),
Modifiers::kConst_Flag | Modifiers::kIn_Flag |
Modifiers::kOut_Flag, /*permittedLayoutFlags=*/0);
const Type& type = param->type();
@@ -89,7 +89,7 @@
// parameters. You can pass other opaque types to functions safely; this restriction is
// specific to "child" objects.
if (type.isEffectChild() && !isBuiltin) {
- context.fErrors->error(param->fOffset, "parameters of type '" + type.displayName() +
+ context.fErrors->error(param->fLine, "parameters of type '" + type.displayName() +
"' not allowed");
return false;
}
@@ -123,7 +123,7 @@
return true;
}
-static bool check_main_signature(const Context& context, int offset, const Type& returnType,
+static bool check_main_signature(const Context& context, int line, const Type& returnType,
std::vector<std::unique_ptr<Variable>>& parameters,
bool isBuiltin) {
ErrorReporter& errors = *context.fErrors;
@@ -154,12 +154,12 @@
case ProgramKind::kRuntimeColorFilter: {
// (half4|float4) main(half4|float4)
if (!typeIsValidForColor(returnType)) {
- errors.error(offset, "'main' must return: 'vec4', 'float4', or 'half4'");
+ errors.error(line, "'main' must return: 'vec4', 'float4', or 'half4'");
return false;
}
bool validParams = (parameters.size() == 1 && paramIsInputColor(0));
if (!validParams) {
- errors.error(offset, "'main' parameter must be 'vec4', 'float4', or 'half4'");
+ errors.error(line, "'main' parameter must be 'vec4', 'float4', or 'half4'");
return false;
}
break;
@@ -167,14 +167,14 @@
case ProgramKind::kRuntimeShader: {
// (half4|float4) main(float2) -or- (half4|float4) main(float2, half4|float4)
if (!typeIsValidForColor(returnType)) {
- errors.error(offset, "'main' must return: 'vec4', 'float4', or 'half4'");
+ errors.error(line, "'main' must return: 'vec4', 'float4', or 'half4'");
return false;
}
bool validParams =
(parameters.size() == 1 && paramIsCoords(0)) ||
(parameters.size() == 2 && paramIsCoords(0) && paramIsInputColor(1));
if (!validParams) {
- errors.error(offset, "'main' parameters must be (float2, (vec4|float4|half4)?)");
+ errors.error(line, "'main' parameters must be (float2, (vec4|float4|half4)?)");
return false;
}
break;
@@ -182,13 +182,13 @@
case ProgramKind::kRuntimeBlender: {
// (half4|float4) main(half4|float4, half4|float4)
if (!typeIsValidForColor(returnType)) {
- errors.error(offset, "'main' must return: 'vec4', 'float4', or 'half4'");
+ errors.error(line, "'main' must return: 'vec4', 'float4', or 'half4'");
return false;
}
if (!(parameters.size() == 2 &&
paramIsInputColor(0) &&
paramIsDestColor(1))) {
- errors.error(offset, "'main' parameters must be (vec4|float4|half4, "
+ errors.error(line, "'main' parameters must be (vec4|float4|half4, "
"vec4|float4|half4)");
return false;
}
@@ -201,14 +201,14 @@
bool validParams = (parameters.size() == 0) ||
(parameters.size() == 1 && paramIsCoords(0));
if (!validParams) {
- errors.error(offset, "shader 'main' must be main() or main(float2)");
+ errors.error(line, "shader 'main' must be main() or main(float2)");
return false;
}
break;
}
case ProgramKind::kVertex:
if (parameters.size()) {
- errors.error(offset, "shader 'main' must have zero parameters");
+ errors.error(line, "shader 'main' must have zero parameters");
return false;
}
break;
@@ -221,7 +221,7 @@
* incompatible symbol. Returns true and sets outExistingDecl to point to the existing declaration
* (or null if none) on success, returns false on error.
*/
-static bool find_existing_declaration(const Context& context, SymbolTable& symbols, int offset,
+static bool find_existing_declaration(const Context& context, SymbolTable& symbols, int line,
skstd::string_view name,
std::vector<std::unique_ptr<Variable>>& parameters,
const Type* returnType, bool isBuiltin,
@@ -239,7 +239,7 @@
functions.push_back(&entry->as<FunctionDeclaration>());
break;
default:
- errors.error(offset, "symbol '" + name + "' was already defined");
+ errors.error(line, "symbol '" + name + "' was already defined");
return false;
}
for (const FunctionDeclaration* other : functions) {
@@ -263,27 +263,27 @@
for (std::unique_ptr<Variable>& param : parameters) {
paramPtrs.push_back(param.get());
}
- FunctionDeclaration invalidDecl(offset,
+ FunctionDeclaration invalidDecl(line,
&other->modifiers(),
name,
std::move(paramPtrs),
returnType,
isBuiltin);
- errors.error(offset,
+ errors.error(line,
"functions '" + invalidDecl.description() + "' and '" +
other->description() + "' differ only in return type");
return false;
}
for (size_t i = 0; i < parameters.size(); i++) {
if (parameters[i]->modifiers() != other->parameters()[i]->modifiers()) {
- errors.error(offset,
+ errors.error(line,
"modifiers on parameter " + to_string((uint64_t)i + 1) +
" differ between declaration and definition");
return false;
}
}
if (other->definition() && !other->isBuiltin()) {
- errors.error(offset, "duplicate definition of " + other->description());
+ errors.error(line, "duplicate definition of " + other->description());
return false;
}
*outExistingDecl = other;
@@ -293,13 +293,13 @@
return true;
}
-FunctionDeclaration::FunctionDeclaration(int offset,
+FunctionDeclaration::FunctionDeclaration(int line,
const Modifiers* modifiers,
skstd::string_view name,
std::vector<const Variable*> parameters,
const Type* returnType,
bool builtin)
- : INHERITED(offset, kSymbolKind, name, /*type=*/nullptr)
+ : INHERITED(line, kSymbolKind, name, /*type=*/nullptr)
, fDefinition(nullptr)
, fModifiers(modifiers)
, fParameters(std::move(parameters))
@@ -309,17 +309,17 @@
, fIntrinsicKind(builtin ? identify_intrinsic(name) : kNotIntrinsic) {}
const FunctionDeclaration* FunctionDeclaration::Convert(const Context& context,
- SymbolTable& symbols, int offset, const Modifiers* modifiers,
+ SymbolTable& symbols, int line, const Modifiers* modifiers,
skstd::string_view name, std::vector<std::unique_ptr<Variable>> parameters,
const Type* returnType, bool isBuiltin) {
bool isMain = (name == "main");
const FunctionDeclaration* decl = nullptr;
- if (!check_modifiers(context, offset, *modifiers, isBuiltin) ||
- !check_return_type(context, offset, *returnType, isBuiltin) ||
+ if (!check_modifiers(context, line, *modifiers, isBuiltin) ||
+ !check_return_type(context, line, *returnType, isBuiltin) ||
!check_parameters(context, parameters, isMain, isBuiltin) ||
- (isMain && !check_main_signature(context, offset, *returnType, parameters, isBuiltin)) ||
- !find_existing_declaration(context, symbols, offset, name, parameters, returnType,
+ (isMain && !check_main_signature(context, line, *returnType, parameters, isBuiltin)) ||
+ !find_existing_declaration(context, symbols, line, name, parameters, returnType,
isBuiltin, &decl)) {
return nullptr;
}
@@ -331,7 +331,7 @@
if (decl) {
return decl;
}
- auto result = std::make_unique<FunctionDeclaration>(offset, modifiers, name,
+ auto result = std::make_unique<FunctionDeclaration>(line, modifiers, name,
std::move(finalParameters), returnType,
isBuiltin);
return symbols.add(std::move(result));
diff --git a/src/sksl/ir/SkSLFunctionDeclaration.h b/src/sksl/ir/SkSLFunctionDeclaration.h
index b843695..9acac38 100644
--- a/src/sksl/ir/SkSLFunctionDeclaration.h
+++ b/src/sksl/ir/SkSLFunctionDeclaration.h
@@ -37,7 +37,7 @@
public:
static constexpr Kind kSymbolKind = Kind::kFunctionDeclaration;
- FunctionDeclaration(int offset,
+ FunctionDeclaration(int line,
const Modifiers* modifiers,
skstd::string_view name,
std::vector<const Variable*> parameters,
@@ -46,7 +46,7 @@
static const FunctionDeclaration* Convert(const Context& context,
SymbolTable& symbols,
- int offset,
+ int line,
const Modifiers* modifiers,
skstd::string_view name,
std::vector<std::unique_ptr<Variable>> parameters,
diff --git a/src/sksl/ir/SkSLFunctionDefinition.cpp b/src/sksl/ir/SkSLFunctionDefinition.cpp
index a92aa58..fd5e3bb 100644
--- a/src/sksl/ir/SkSLFunctionDefinition.cpp
+++ b/src/sksl/ir/SkSLFunctionDefinition.cpp
@@ -17,7 +17,7 @@
namespace SkSL {
std::unique_ptr<FunctionDefinition> FunctionDefinition::Convert(const Context& context,
- int offset,
+ int line,
const FunctionDeclaration& function,
std::unique_ptr<Statement> body,
bool builtin) {
@@ -56,7 +56,7 @@
// issue, we can add normalization before each return statement.
if (fContext.fConfig->fKind == ProgramKind::kVertex && fFunction.isMain()) {
fContext.fErrors->error(
- stmt.fOffset,
+ stmt.fLine,
"early returns from vertex programs are not supported");
}
@@ -70,13 +70,13 @@
} else {
// Returning something from a function with a void return type.
returnStmt.setExpression(nullptr);
- fContext.fErrors->error(returnStmt.fOffset,
+ fContext.fErrors->error(returnStmt.fLine,
"may not return a value from a void function");
}
} else {
if (this->functionReturnsValue()) {
// Returning nothing from a function with a non-void return type.
- fContext.fErrors->error(returnStmt.fOffset,
+ fContext.fErrors->error(returnStmt.fLine,
"expected function to return '" +
fFunction.returnType().displayName() + "'");
}
@@ -102,7 +102,7 @@
}
case Statement::Kind::kBreak:
if (fBreakableLevel == 0) {
- fContext.fErrors->error(stmt.fOffset,
+ fContext.fErrors->error(stmt.fLine,
"break statement must be inside a loop or switch");
}
break;
@@ -111,10 +111,10 @@
if (std::any_of(fContinuableLevel.begin(),
fContinuableLevel.end(),
[](int level) { return level > 0; })) {
- fContext.fErrors->error(stmt.fOffset,
+ fContext.fErrors->error(stmt.fLine,
"continue statement cannot be used in a switch");
} else {
- fContext.fErrors->error(stmt.fOffset,
+ fContext.fErrors->error(stmt.fLine,
"continue statement must be inside a loop");
}
}
@@ -143,11 +143,11 @@
Finalizer(context, function, &referencedIntrinsics).visitStatement(*body);
if (Analysis::CanExitWithoutReturningValue(function, *body)) {
- context.fErrors->error(function.fOffset, "function '" + function.name() +
+ context.fErrors->error(function.fLine, "function '" + function.name() +
"' can exit without returning a value");
}
- return std::make_unique<FunctionDefinition>(offset, &function, builtin, std::move(body),
+ return std::make_unique<FunctionDefinition>(line, &function, builtin, std::move(body),
std::move(referencedIntrinsics));
}
diff --git a/src/sksl/ir/SkSLFunctionDefinition.h b/src/sksl/ir/SkSLFunctionDefinition.h
index 76f64e9..d0f38e3 100644
--- a/src/sksl/ir/SkSLFunctionDefinition.h
+++ b/src/sksl/ir/SkSLFunctionDefinition.h
@@ -25,9 +25,9 @@
using IntrinsicSet = std::unordered_set<const FunctionDeclaration*>;
- FunctionDefinition(int offset, const FunctionDeclaration* declaration, bool builtin,
+ FunctionDefinition(int line, const FunctionDeclaration* declaration, bool builtin,
std::unique_ptr<Statement> body, IntrinsicSet referencedIntrinsics)
- : INHERITED(offset, kProgramElementKind)
+ : INHERITED(line, kProgramElementKind)
, fDeclaration(declaration)
, fBuiltin(builtin)
, fBody(std::move(body))
@@ -46,7 +46,7 @@
* errors when trying to call a function with an error in it.)
*/
static std::unique_ptr<FunctionDefinition> Convert(const Context& context,
- int offset,
+ int line,
const FunctionDeclaration& function,
std::unique_ptr<Statement> body,
bool builtin);
@@ -80,7 +80,7 @@
}
std::unique_ptr<ProgramElement> clone() const override {
- return std::make_unique<FunctionDefinition>(fOffset, &this->declaration(),
+ return std::make_unique<FunctionDefinition>(fLine, &this->declaration(),
/*builtin=*/false, this->body()->clone(),
this->referencedIntrinsics());
}
diff --git a/src/sksl/ir/SkSLFunctionPrototype.h b/src/sksl/ir/SkSLFunctionPrototype.h
index 34d7f32..0b4a16f 100644
--- a/src/sksl/ir/SkSLFunctionPrototype.h
+++ b/src/sksl/ir/SkSLFunctionPrototype.h
@@ -23,8 +23,8 @@
public:
static constexpr Kind kProgramElementKind = Kind::kFunctionPrototype;
- FunctionPrototype(int offset, const FunctionDeclaration* declaration, bool builtin)
- : INHERITED(offset, kProgramElementKind)
+ FunctionPrototype(int line, const FunctionDeclaration* declaration, bool builtin)
+ : INHERITED(line, kProgramElementKind)
, fDeclaration(declaration)
, fBuiltin(builtin) {}
@@ -37,8 +37,7 @@
}
std::unique_ptr<ProgramElement> clone() const override {
- return std::make_unique<FunctionPrototype>(fOffset, &this->declaration(),
- /*builtin=*/false);
+ return std::make_unique<FunctionPrototype>(fLine, &this->declaration(), /*builtin=*/false);
}
String description() const override {
diff --git a/src/sksl/ir/SkSLFunctionReference.h b/src/sksl/ir/SkSLFunctionReference.h
index 1030db0..fd492f8 100644
--- a/src/sksl/ir/SkSLFunctionReference.h
+++ b/src/sksl/ir/SkSLFunctionReference.h
@@ -22,9 +22,9 @@
public:
static constexpr Kind kExpressionKind = Kind::kFunctionReference;
- FunctionReference(const Context& context, int offset,
+ FunctionReference(const Context& context, int line,
std::vector<const FunctionDeclaration*> functions)
- : INHERITED(offset, kExpressionKind, context.fTypes.fInvalid.get())
+ : INHERITED(line, kExpressionKind, context.fTypes.fInvalid.get())
, fFunctions(std::move(functions)) {}
const std::vector<const FunctionDeclaration*>& functions() const {
@@ -36,7 +36,7 @@
}
std::unique_ptr<Expression> clone() const override {
- return std::unique_ptr<Expression>(new FunctionReference(fOffset, this->functions(),
+ return std::unique_ptr<Expression>(new FunctionReference(fLine, this->functions(),
&this->type()));
}
@@ -45,9 +45,9 @@
}
private:
- FunctionReference(int offset, std::vector<const FunctionDeclaration*> functions,
+ FunctionReference(int line, std::vector<const FunctionDeclaration*> functions,
const Type* type)
- : INHERITED(offset, kExpressionKind, type)
+ : INHERITED(line, kExpressionKind, type)
, fFunctions(std::move(functions)) {}
std::vector<const FunctionDeclaration*> fFunctions;
diff --git a/src/sksl/ir/SkSLIfStatement.cpp b/src/sksl/ir/SkSLIfStatement.cpp
index f9f0149..7a6181a 100644
--- a/src/sksl/ir/SkSLIfStatement.cpp
+++ b/src/sksl/ir/SkSLIfStatement.cpp
@@ -18,7 +18,7 @@
namespace SkSL {
std::unique_ptr<Statement> IfStatement::clone() const {
- return std::make_unique<IfStatement>(fOffset, this->isStatic(), this->test()->clone(),
+ return std::make_unique<IfStatement>(fLine, this->isStatic(), this->test()->clone(),
this->ifTrue()->clone(),
this->ifFalse() ? this->ifFalse()->clone() : nullptr);
}
@@ -35,7 +35,7 @@
return result;
}
-std::unique_ptr<Statement> IfStatement::Convert(const Context& context, int offset, bool isStatic,
+std::unique_ptr<Statement> IfStatement::Convert(const Context& context, int line, bool isStatic,
std::unique_ptr<Expression> test,
std::unique_ptr<Statement> ifTrue,
std::unique_ptr<Statement> ifFalse) {
@@ -50,7 +50,7 @@
if (ifFalse && Analysis::DetectVarDeclarationWithoutScope(*ifFalse, context.fErrors)) {
return nullptr;
}
- return IfStatement::Make(context, offset, isStatic, std::move(test),
+ return IfStatement::Make(context, line, isStatic, std::move(test),
std::move(ifTrue), std::move(ifFalse));
}
@@ -60,7 +60,7 @@
: Nop::Make();
}
-std::unique_ptr<Statement> IfStatement::Make(const Context& context, int offset, bool isStatic,
+std::unique_ptr<Statement> IfStatement::Make(const Context& context, int line, bool isStatic,
std::unique_ptr<Expression> test,
std::unique_ptr<Statement> ifTrue,
std::unique_ptr<Statement> ifFalse) {
@@ -101,7 +101,7 @@
}
}
- return std::make_unique<IfStatement>(offset, isStatic, std::move(test),
+ return std::make_unique<IfStatement>(line, isStatic, std::move(test),
std::move(ifTrue), std::move(ifFalse));
}
diff --git a/src/sksl/ir/SkSLIfStatement.h b/src/sksl/ir/SkSLIfStatement.h
index d690522..3b0ec5d 100644
--- a/src/sksl/ir/SkSLIfStatement.h
+++ b/src/sksl/ir/SkSLIfStatement.h
@@ -22,9 +22,9 @@
public:
static constexpr Kind kStatementKind = Kind::kIf;
- IfStatement(int offset, bool isStatic, std::unique_ptr<Expression> test,
+ IfStatement(int line, bool isStatic, std::unique_ptr<Expression> test,
std::unique_ptr<Statement> ifTrue, std::unique_ptr<Statement> ifFalse)
- : INHERITED(offset, kStatementKind)
+ : INHERITED(line, kStatementKind)
, fTest(std::move(test))
, fIfTrue(std::move(ifTrue))
, fIfFalse(std::move(ifFalse))
@@ -32,13 +32,13 @@
// Creates a potentially-simplified form of the if-statement. Typechecks and coerces the test
// expression; reports errors via ErrorReporter.
- static std::unique_ptr<Statement> Convert(const Context& context, int offset, bool isStatic,
+ static std::unique_ptr<Statement> Convert(const Context& context, int line, bool isStatic,
std::unique_ptr<Expression> test,
std::unique_ptr<Statement> ifTrue,
std::unique_ptr<Statement> ifFalse);
// Creates a potentially-simplified form of the if-statement; reports errors via ASSERT.
- static std::unique_ptr<Statement> Make(const Context& context, int offset, bool isStatic,
+ static std::unique_ptr<Statement> Make(const Context& context, int line, bool isStatic,
std::unique_ptr<Expression> test,
std::unique_ptr<Statement> ifTrue,
std::unique_ptr<Statement> ifFalse);
diff --git a/src/sksl/ir/SkSLIndexExpression.cpp b/src/sksl/ir/SkSLIndexExpression.cpp
index b5fef74..e4434e2 100644
--- a/src/sksl/ir/SkSLIndexExpression.cpp
+++ b/src/sksl/ir/SkSLIndexExpression.cpp
@@ -43,13 +43,13 @@
if (!arraySize) {
return nullptr;
}
- return std::make_unique<TypeReference>(context, base->fOffset,
+ return std::make_unique<TypeReference>(context, base->fLine,
symbolTable.addArrayDimension(&baseType, arraySize));
}
// Convert an index expression with an expression inside of it: `arr[a * 3]`.
const Type& baseType = base->type();
if (!baseType.isArray() && !baseType.isMatrix() && !baseType.isVector()) {
- context.fErrors->error(base->fOffset,
+ context.fErrors->error(base->fLine,
"expected array, but found '" + baseType.displayName() + "'");
return nullptr;
}
@@ -64,9 +64,9 @@
if (indexExpr->isIntLiteral()) {
SKSL_INT indexValue = indexExpr->as<Literal>().intValue();
if (indexValue < 0 || indexValue >= baseType.columns()) {
- context.fErrors->error(base->fOffset, "index " + to_string(indexValue) +
- " out of range for '" + baseType.displayName() +
- "'");
+ context.fErrors->error(base->fLine, "index " + to_string(indexValue) +
+ " out of range for '" + baseType.displayName() +
+ "'");
return nullptr;
}
}
diff --git a/src/sksl/ir/SkSLIndexExpression.h b/src/sksl/ir/SkSLIndexExpression.h
index 1814f3f..ab888d5 100644
--- a/src/sksl/ir/SkSLIndexExpression.h
+++ b/src/sksl/ir/SkSLIndexExpression.h
@@ -22,7 +22,7 @@
IndexExpression(const Context& context, std::unique_ptr<Expression> base,
std::unique_ptr<Expression> index)
- : INHERITED(base->fOffset, kExpressionKind, &IndexType(context, base->type()))
+ : INHERITED(base->fLine, kExpressionKind, &IndexType(context, base->type()))
, fBase(std::move(base))
, fIndex(std::move(index)) {}
@@ -77,7 +77,7 @@
private:
IndexExpression(std::unique_ptr<Expression> base, std::unique_ptr<Expression> index,
const Type* type)
- : INHERITED(base->fOffset, Kind::kIndex, type)
+ : INHERITED(base->fLine, Kind::kIndex, type)
, fBase(std::move(base))
, fIndex(std::move(index)) {}
diff --git a/src/sksl/ir/SkSLInlineMarker.h b/src/sksl/ir/SkSLInlineMarker.h
index 61e4d3b..62d63ee 100644
--- a/src/sksl/ir/SkSLInlineMarker.h
+++ b/src/sksl/ir/SkSLInlineMarker.h
@@ -23,7 +23,7 @@
static constexpr Kind kStatementKind = Kind::kInlineMarker;
InlineMarker(const FunctionDeclaration* function)
- : INHERITED(/*offset=*/-1, kStatementKind)
+ : INHERITED(/*line=*/-1, kStatementKind)
, fFunction(*function) {}
static std::unique_ptr<Statement> Make(const FunctionDeclaration* function) {
diff --git a/src/sksl/ir/SkSLInterfaceBlock.h b/src/sksl/ir/SkSLInterfaceBlock.h
index 1665446..cbe7af6 100644
--- a/src/sksl/ir/SkSLInterfaceBlock.h
+++ b/src/sksl/ir/SkSLInterfaceBlock.h
@@ -31,10 +31,10 @@
public:
static constexpr Kind kProgramElementKind = Kind::kInterfaceBlock;
- InterfaceBlock(int offset, const Variable& var, skstd::string_view typeName,
+ InterfaceBlock(int line, const Variable& var, skstd::string_view typeName,
skstd::string_view instanceName, int arraySize,
std::shared_ptr<SymbolTable> typeOwner)
- : INHERITED(offset, kProgramElementKind)
+ : INHERITED(line, kProgramElementKind)
, fVariable(var)
, fTypeName(typeName)
, fInstanceName(instanceName)
@@ -62,7 +62,7 @@
}
std::unique_ptr<ProgramElement> clone() const override {
- return std::make_unique<InterfaceBlock>(fOffset, this->variable(), this->typeName(),
+ return std::make_unique<InterfaceBlock>(fLine, this->variable(), this->typeName(),
this->instanceName(), this->arraySize(),
SymbolTable::WrapIfBuiltin(this->typeOwner()));
}
diff --git a/src/sksl/ir/SkSLLiteral.h b/src/sksl/ir/SkSLLiteral.h
index 7851465..fb80347 100644
--- a/src/sksl/ir/SkSLLiteral.h
+++ b/src/sksl/ir/SkSLLiteral.h
@@ -21,54 +21,54 @@
public:
static constexpr Kind kExpressionKind = Kind::kLiteral;
- Literal(int offset, double value, const Type* type)
- : INHERITED(offset, kExpressionKind, type)
+ Literal(int line, double value, const Type* type)
+ : INHERITED(line, kExpressionKind, type)
, fValue(value) {}
// Makes a literal of $floatLiteral type.
- static std::unique_ptr<Literal> MakeFloat(const Context& context, int offset, float value) {
- return std::make_unique<Literal>(offset, value, context.fTypes.fFloatLiteral.get());
+ static std::unique_ptr<Literal> MakeFloat(const Context& context, int line, float value) {
+ return std::make_unique<Literal>(line, value, context.fTypes.fFloatLiteral.get());
}
// Makes a float literal of the specified type.
- static std::unique_ptr<Literal> MakeFloat(int offset, float value, const Type* type) {
+ static std::unique_ptr<Literal> MakeFloat(int line, float value, const Type* type) {
SkASSERT(type->isFloat());
- return std::make_unique<Literal>(offset, value, type);
+ return std::make_unique<Literal>(line, value, type);
}
// Makes a literal of $intLiteral type.
- static std::unique_ptr<Literal> MakeInt(const Context& context, int offset, SKSL_INT value) {
- return std::make_unique<Literal>(offset, value, context.fTypes.fIntLiteral.get());
+ static std::unique_ptr<Literal> MakeInt(const Context& context, int line, SKSL_INT value) {
+ return std::make_unique<Literal>(line, value, context.fTypes.fIntLiteral.get());
}
// Makes an int literal of the specified type.
- static std::unique_ptr<Literal> MakeInt(int offset, SKSL_INT value, const Type* type) {
+ static std::unique_ptr<Literal> MakeInt(int line, SKSL_INT value, const Type* type) {
SkASSERT(type->isInteger());
- return std::make_unique<Literal>(offset, value, type);
+ return std::make_unique<Literal>(line, value, type);
}
// Makes a literal of boolean type.
- static std::unique_ptr<Literal> MakeBool(const Context& context, int offset, bool value) {
- return std::make_unique<Literal>(offset, value, context.fTypes.fBool.get());
+ static std::unique_ptr<Literal> MakeBool(const Context& context, int line, bool value) {
+ return std::make_unique<Literal>(line, value, context.fTypes.fBool.get());
}
// Makes a literal of boolean type. (Functionally identical to the above, but useful if you
// don't have access to the Context.)
- static std::unique_ptr<Literal> MakeBool(int offset, bool value, const Type* type) {
+ static std::unique_ptr<Literal> MakeBool(int line, bool value, const Type* type) {
SkASSERT(type->isBoolean());
- return std::make_unique<Literal>(offset, value, type);
+ return std::make_unique<Literal>(line, value, type);
}
// Makes a literal of the specified type, rounding as needed.
- static std::unique_ptr<Literal> Make(int offset, double value, const Type* type) {
+ static std::unique_ptr<Literal> Make(int line, double value, const Type* type) {
if (type->isFloat()) {
- return MakeFloat(offset, value, type);
+ return MakeFloat(line, value, type);
}
if (type->isInteger()) {
- return MakeInt(offset, value, type);
+ return MakeInt(line, value, type);
}
SkASSERT(type->isBoolean());
- return MakeBool(offset, value, type);
+ return MakeBool(line, value, type);
}
float floatValue() const {
@@ -119,7 +119,7 @@
}
std::unique_ptr<Expression> clone() const override {
- return std::make_unique<Literal>(fOffset, this->value(), &this->type());
+ return std::make_unique<Literal>(fLine, this->value(), &this->type());
}
bool allowsConstantSubexpressions() const override {
diff --git a/src/sksl/ir/SkSLMethodReference.h b/src/sksl/ir/SkSLMethodReference.h
index a38a4ee..028fffa 100644
--- a/src/sksl/ir/SkSLMethodReference.h
+++ b/src/sksl/ir/SkSLMethodReference.h
@@ -32,10 +32,10 @@
static constexpr Kind kExpressionKind = Kind::kMethodReference;
MethodReference(const Context& context,
- int offset,
+ int line,
std::unique_ptr<Expression> self,
std::vector<const FunctionDeclaration*> functions)
- : INHERITED(offset, kExpressionKind, context.fTypes.fInvalid.get())
+ : INHERITED(line, kExpressionKind, context.fTypes.fInvalid.get())
, fSelf(std::move(self))
, fFunctions(std::move(functions)) {}
@@ -48,7 +48,7 @@
std::unique_ptr<Expression> clone() const override {
return std::unique_ptr<Expression>(new MethodReference(
- fOffset, this->self()->clone(), this->functions(), &this->type()));
+ fLine, this->self()->clone(), this->functions(), &this->type()));
}
String description() const override {
@@ -56,11 +56,11 @@
}
private:
- MethodReference(int offset,
+ MethodReference(int line,
std::unique_ptr<Expression> self,
std::vector<const FunctionDeclaration*> functions,
const Type* type)
- : INHERITED(offset, kExpressionKind, type)
+ : INHERITED(line, kExpressionKind, type)
, fSelf(std::move(self))
, fFunctions(std::move(functions)) {}
diff --git a/src/sksl/ir/SkSLNop.h b/src/sksl/ir/SkSLNop.h
index ebd713f..9a24516 100644
--- a/src/sksl/ir/SkSLNop.h
+++ b/src/sksl/ir/SkSLNop.h
@@ -21,7 +21,7 @@
static constexpr Kind kStatementKind = Kind::kNop;
Nop()
- : INHERITED(/*offset=*/-1, kStatementKind) {}
+ : INHERITED(/*line=*/-1, kStatementKind) {}
static std::unique_ptr<Statement> Make() {
return std::make_unique<Nop>();
diff --git a/src/sksl/ir/SkSLPoison.h b/src/sksl/ir/SkSLPoison.h
index a6b58fc..16dd355 100644
--- a/src/sksl/ir/SkSLPoison.h
+++ b/src/sksl/ir/SkSLPoison.h
@@ -14,19 +14,19 @@
public:
static constexpr Kind kExpressionKind = Kind::kPoison;
- static std::unique_ptr<Expression> Make(int offset, const Context& context) {
- return std::make_unique<Poison>(offset, context.fTypes.fPoison.get());
+ static std::unique_ptr<Expression> Make(int line, const Context& context) {
+ return std::make_unique<Poison>(line, context.fTypes.fPoison.get());
}
- Poison(int offset, const Type* type)
- : INHERITED(offset, kExpressionKind, type) {}
+ Poison(int line, const Type* type)
+ : INHERITED(line, kExpressionKind, type) {}
bool hasProperty(Property property) const override {
return false;
}
std::unique_ptr<Expression> clone() const override {
- return std::make_unique<Poison>(fOffset, &this->type());
+ return std::make_unique<Poison>(fLine, &this->type());
}
String description() const override {
diff --git a/src/sksl/ir/SkSLPostfixExpression.cpp b/src/sksl/ir/SkSLPostfixExpression.cpp
index 05758fc..98241bd 100644
--- a/src/sksl/ir/SkSLPostfixExpression.cpp
+++ b/src/sksl/ir/SkSLPostfixExpression.cpp
@@ -19,7 +19,7 @@
Operator op) {
const Type& baseType = base->type();
if (!baseType.isNumber()) {
- context.fErrors->error(base->fOffset,
+ context.fErrors->error(base->fLine,
"'" + String(op.operatorName()) + "' cannot operate on '" +
baseType.displayName() + "'");
return nullptr;
diff --git a/src/sksl/ir/SkSLPostfixExpression.h b/src/sksl/ir/SkSLPostfixExpression.h
index 703f68f..870e970 100644
--- a/src/sksl/ir/SkSLPostfixExpression.h
+++ b/src/sksl/ir/SkSLPostfixExpression.h
@@ -22,7 +22,7 @@
static constexpr Kind kExpressionKind = Kind::kPostfix;
PostfixExpression(std::unique_ptr<Expression> operand, Operator op)
- : INHERITED(operand->fOffset, kExpressionKind, &operand->type())
+ : INHERITED(operand->fLine, kExpressionKind, &operand->type())
, fOperand(std::move(operand))
, fOperator(op) {}
diff --git a/src/sksl/ir/SkSLPrefixExpression.cpp b/src/sksl/ir/SkSLPrefixExpression.cpp
index 7ba77e4..9c505d2 100644
--- a/src/sksl/ir/SkSLPrefixExpression.cpp
+++ b/src/sksl/ir/SkSLPrefixExpression.cpp
@@ -25,7 +25,7 @@
switch (value->kind()) {
case Expression::Kind::kLiteral:
// Convert -literal(1) to literal(-1).
- return Literal::Make(originalExpr.fOffset,
+ return Literal::Make(originalExpr.fLine,
-value->as<Literal>().value(),
&value->type());
@@ -43,7 +43,7 @@
// Convert `-array[N](literal, ...)` into `array[N](-literal, ...)`.
if (context.fConfig->fSettings.fOptimize && value->isCompileTimeConstant()) {
const ConstructorArray& ctor = value->as<ConstructorArray>();
- return ConstructorArray::Make(context, originalExpr.fOffset, ctor.type(),
+ return ConstructorArray::Make(context, originalExpr.fLine, ctor.type(),
negate_operands(context, ctor.arguments()));
}
break;
@@ -52,7 +52,7 @@
// Convert `-matrix(literal)` into `matrix(-literal)`.
if (context.fConfig->fSettings.fOptimize && value->isCompileTimeConstant()) {
const ConstructorDiagonalMatrix& ctor = value->as<ConstructorDiagonalMatrix>();
- return ConstructorDiagonalMatrix::Make(context, originalExpr.fOffset, ctor.type(),
+ return ConstructorDiagonalMatrix::Make(context, originalExpr.fLine, ctor.type(),
simplify_negation(context, *ctor.argument()));
}
break;
@@ -61,7 +61,7 @@
// Convert `-vector(literal)` into `vector(-literal)`.
if (context.fConfig->fSettings.fOptimize && value->isCompileTimeConstant()) {
const ConstructorSplat& ctor = value->as<ConstructorSplat>();
- return ConstructorSplat::Make(context, originalExpr.fOffset, ctor.type(),
+ return ConstructorSplat::Make(context, originalExpr.fLine, ctor.type(),
simplify_negation(context, *ctor.argument()));
}
break;
@@ -70,7 +70,7 @@
// Convert `-vecN(literal, ...)` into `vecN(-literal, ...)`.
if (context.fConfig->fSettings.fOptimize && value->isCompileTimeConstant()) {
const ConstructorCompound& ctor = value->as<ConstructorCompound>();
- return ConstructorCompound::Make(context, originalExpr.fOffset, ctor.type(),
+ return ConstructorCompound::Make(context, originalExpr.fLine, ctor.type(),
negate_operands(context, ctor.arguments()));
}
break;
@@ -115,7 +115,7 @@
// Convert !boolLiteral(true) to boolLiteral(false).
SkASSERT(value->type().isBoolean());
const Literal& b = value->as<Literal>();
- return Literal::MakeBool(operand->fOffset, !b.boolValue(), &operand->type());
+ return Literal::MakeBool(operand->fLine, !b.boolValue(), &operand->type());
}
case Expression::Kind::kPrefix:
if (context.fConfig->fSettings.fOptimize) {
@@ -142,7 +142,7 @@
switch (op.kind()) {
case Token::Kind::TK_PLUS:
if (!baseType.componentType().isNumber()) {
- context.fErrors->error(base->fOffset,
+ context.fErrors->error(base->fLine,
"'+' cannot operate on '" + baseType.displayName() + "'");
return nullptr;
}
@@ -150,7 +150,7 @@
case Token::Kind::TK_MINUS:
if (!baseType.componentType().isNumber()) {
- context.fErrors->error(base->fOffset,
+ context.fErrors->error(base->fLine,
"'-' cannot operate on '" + baseType.displayName() + "'");
return nullptr;
}
@@ -159,7 +159,7 @@
case Token::Kind::TK_PLUSPLUS:
case Token::Kind::TK_MINUSMINUS:
if (!baseType.isNumber()) {
- context.fErrors->error(base->fOffset,
+ context.fErrors->error(base->fLine,
String("'") + op.operatorName() + "' cannot operate on '" +
baseType.displayName() + "'");
return nullptr;
@@ -172,7 +172,7 @@
case Token::Kind::TK_LOGICALNOT:
if (!baseType.isBoolean()) {
- context.fErrors->error(base->fOffset,
+ context.fErrors->error(base->fLine,
String("'") + op.operatorName() + "' cannot operate on '" +
baseType.displayName() + "'");
return nullptr;
@@ -183,12 +183,12 @@
if (context.fConfig->strictES2Mode()) {
// GLSL ES 1.00, Section 5.1
context.fErrors->error(
- base->fOffset,
+ base->fLine,
String("operator '") + op.operatorName() + "' is not allowed");
return nullptr;
}
if (!baseType.isInteger()) {
- context.fErrors->error(base->fOffset,
+ context.fErrors->error(base->fLine,
String("'") + op.operatorName() + "' cannot operate on '" +
baseType.displayName() + "'");
return nullptr;
diff --git a/src/sksl/ir/SkSLPrefixExpression.h b/src/sksl/ir/SkSLPrefixExpression.h
index 0475359..7476624 100644
--- a/src/sksl/ir/SkSLPrefixExpression.h
+++ b/src/sksl/ir/SkSLPrefixExpression.h
@@ -26,7 +26,7 @@
// Use PrefixExpression::Make to automatically simplify various prefix expression types.
PrefixExpression(Operator op, std::unique_ptr<Expression> operand)
- : INHERITED(operand->fOffset, kExpressionKind, &operand->type())
+ : INHERITED(operand->fLine, kExpressionKind, &operand->type())
, fOperator(op)
, fOperand(std::move(operand)) {}
diff --git a/src/sksl/ir/SkSLReturnStatement.h b/src/sksl/ir/SkSLReturnStatement.h
index dc3767d..70488ce 100644
--- a/src/sksl/ir/SkSLReturnStatement.h
+++ b/src/sksl/ir/SkSLReturnStatement.h
@@ -20,12 +20,12 @@
public:
static constexpr Kind kStatementKind = Kind::kReturn;
- ReturnStatement(int offset, std::unique_ptr<Expression> expression)
- : INHERITED(offset, kStatementKind)
+ ReturnStatement(int line, std::unique_ptr<Expression> expression)
+ : INHERITED(line, kStatementKind)
, fExpression(std::move(expression)) {}
- static std::unique_ptr<Statement> Make(int offset, std::unique_ptr<Expression> expression) {
- return std::make_unique<ReturnStatement>(offset, std::move(expression));
+ static std::unique_ptr<Statement> Make(int line, std::unique_ptr<Expression> expression) {
+ return std::make_unique<ReturnStatement>(line, std::move(expression));
}
std::unique_ptr<Expression>& expression() {
@@ -41,7 +41,7 @@
}
std::unique_ptr<Statement> clone() const override {
- return std::make_unique<ReturnStatement>(fOffset, this->expression()->clone());
+ return std::make_unique<ReturnStatement>(fLine, this->expression()->clone());
}
String description() const override {
diff --git a/src/sksl/ir/SkSLSetting.cpp b/src/sksl/ir/SkSLSetting.cpp
index d931256..e5464cd 100644
--- a/src/sksl/ir/SkSLSetting.cpp
+++ b/src/sksl/ir/SkSLSetting.cpp
@@ -31,7 +31,7 @@
return context.fTypes.fBool.get();
}
std::unique_ptr<Expression> value(const Context& context) const override {
- return Literal::MakeBool(context, /*offset=*/-1, (context.fCaps.*fGetCap)());
+ return Literal::MakeBool(context, /*line=*/-1, (context.fCaps.*fGetCap)());
}
private:
@@ -48,7 +48,7 @@
return context.fTypes.fInt.get();
}
std::unique_ptr<Expression> value(const Context& context) const override {
- return Literal::MakeInt(context, /*offset=*/-1, (context.fCaps.*fGetCap)());
+ return Literal::MakeInt(context, /*line=*/-1, (context.fCaps.*fGetCap)());
}
private:
@@ -102,37 +102,37 @@
} // namespace
-static const Type* get_type(const Context& context, int offset, skstd::string_view name) {
+static const Type* get_type(const Context& context, int line, skstd::string_view name) {
if (const CapsLookupMethod* caps = caps_lookup_table().lookup(name)) {
return caps->type(context);
}
- context.fErrors->error(offset, "unknown capability flag '" + name + "'");
+ context.fErrors->error(line, "unknown capability flag '" + name + "'");
return nullptr;
}
-static std::unique_ptr<Expression> get_value(const Context& context, int offset,
+static std::unique_ptr<Expression> get_value(const Context& context, int line,
const skstd::string_view& name) {
if (const CapsLookupMethod* caps = caps_lookup_table().lookup(name)) {
return caps->value(context);
}
- context.fErrors->error(offset, "unknown capability flag '" + name + "'");
+ context.fErrors->error(line, "unknown capability flag '" + name + "'");
return nullptr;
}
-std::unique_ptr<Expression> Setting::Convert(const Context& context, int offset,
+std::unique_ptr<Expression> Setting::Convert(const Context& context, int line,
const skstd::string_view& name) {
SkASSERT(context.fConfig);
if (context.fConfig->fSettings.fReplaceSettings) {
// Insert the settings value directly into the IR.
- return get_value(context, offset, name);
+ return get_value(context, line, name);
}
// Generate a Setting IRNode.
- const Type* type = get_type(context, offset, name);
- return type ? std::make_unique<Setting>(offset, name, type) : nullptr;
+ const Type* type = get_type(context, line, name);
+ return type ? std::make_unique<Setting>(line, name, type) : nullptr;
}
} // namespace SkSL
diff --git a/src/sksl/ir/SkSLSetting.h b/src/sksl/ir/SkSLSetting.h
index a30aab6..e003cfc 100644
--- a/src/sksl/ir/SkSLSetting.h
+++ b/src/sksl/ir/SkSLSetting.h
@@ -22,19 +22,19 @@
public:
static constexpr Kind kExpressionKind = Kind::kSetting;
- Setting(int offset, skstd::string_view name, const Type* type)
- : INHERITED(offset, kExpressionKind, type)
+ Setting(int line, skstd::string_view name, const Type* type)
+ : INHERITED(line, kExpressionKind, type)
, fName(std::move(name)) {}
// Creates an SkSL setting expression if `fReplaceSettings` is false, or the current value of
// the setting when it is true. Reports errors via the ErrorReporter.
// (There's no failsafe Make equivalent, because there really isn't a good fallback expression
// to produce when the `name` lookup fails. We wouldn't even know the expected type.)
- static std::unique_ptr<Expression> Convert(const Context& context, int offset,
+ static std::unique_ptr<Expression> Convert(const Context& context, int line,
const skstd::string_view& name);
std::unique_ptr<Expression> clone() const override {
- return std::make_unique<Setting>(fOffset, this->name(), &this->type());
+ return std::make_unique<Setting>(fLine, this->name(), &this->type());
}
const skstd::string_view& name() const {
diff --git a/src/sksl/ir/SkSLStructDefinition.h b/src/sksl/ir/SkSLStructDefinition.h
index b8af26b..8ed4e2f 100644
--- a/src/sksl/ir/SkSLStructDefinition.h
+++ b/src/sksl/ir/SkSLStructDefinition.h
@@ -28,8 +28,8 @@
public:
static constexpr Kind kProgramElementKind = Kind::kStructDefinition;
- StructDefinition(int offset, const Type& type)
- : INHERITED(offset, kProgramElementKind)
+ StructDefinition(int line, const Type& type)
+ : INHERITED(line, kProgramElementKind)
, fType(&type) {}
const Type& type() const {
@@ -37,7 +37,7 @@
}
std::unique_ptr<ProgramElement> clone() const override {
- return std::make_unique<StructDefinition>(fOffset, this->type());
+ return std::make_unique<StructDefinition>(fLine, this->type());
}
String description() const override {
diff --git a/src/sksl/ir/SkSLSwitchCase.h b/src/sksl/ir/SkSLSwitchCase.h
index 8526ba1..35125a8 100644
--- a/src/sksl/ir/SkSLSwitchCase.h
+++ b/src/sksl/ir/SkSLSwitchCase.h
@@ -21,8 +21,8 @@
static constexpr Kind kStatementKind = Kind::kSwitchCase;
// null value implies "default" case
- SwitchCase(int offset, std::unique_ptr<Expression> value, std::unique_ptr<Statement> statement)
- : INHERITED(offset, kStatementKind)
+ SwitchCase(int line, std::unique_ptr<Expression> value, std::unique_ptr<Statement> statement)
+ : INHERITED(line, kStatementKind)
, fValue(std::move(value))
, fStatement(std::move(statement)) {}
@@ -43,7 +43,7 @@
}
std::unique_ptr<Statement> clone() const override {
- return std::make_unique<SwitchCase>(fOffset,
+ return std::make_unique<SwitchCase>(fLine,
this->value() ? this->value()->clone() : nullptr,
this->statement()->clone());
}
diff --git a/src/sksl/ir/SkSLSwitchStatement.cpp b/src/sksl/ir/SkSLSwitchStatement.cpp
index c41c52f..c4fae53 100644
--- a/src/sksl/ir/SkSLSwitchStatement.cpp
+++ b/src/sksl/ir/SkSLSwitchStatement.cpp
@@ -27,7 +27,7 @@
for (const std::unique_ptr<Statement>& stmt : this->cases()) {
cases.push_back(stmt->clone());
}
- return std::make_unique<SwitchStatement>(fOffset,
+ return std::make_unique<SwitchStatement>(fLine,
this->isStatic(),
this->value()->clone(),
std::move(cases),
@@ -93,7 +93,7 @@
move_all_but_break(blockStmt, &blockStmts);
}
- target->push_back(Block::Make(block.fOffset, std::move(blockStmts),
+ target->push_back(Block::Make(block.fLine, std::move(blockStmts),
block.symbolTable(), block.isScope()));
break;
}
@@ -161,11 +161,11 @@
}
// Return our newly-synthesized block.
- return Block::Make(caseToCapture->fOffset, std::move(caseStmts), std::move(symbolTable));
+ return Block::Make(caseToCapture->fLine, std::move(caseStmts), std::move(symbolTable));
}
std::unique_ptr<Statement> SwitchStatement::Convert(const Context& context,
- int offset,
+ int line,
bool isStatic,
std::unique_ptr<Expression> value,
ExpressionArray caseValues,
@@ -180,10 +180,10 @@
StatementArray cases;
for (int i = 0; i < caseValues.count(); ++i) {
- int caseOffset;
+ int caseLine;
std::unique_ptr<Expression> caseValue;
if (caseValues[i]) {
- caseOffset = caseValues[i]->fOffset;
+ caseLine = caseValues[i]->fLine;
// Case values must be the same type as the switch value--`int` or a particular enum.
caseValue = value->type().coerceExpression(std::move(caseValues[i]), context);
@@ -193,14 +193,14 @@
// Case values must be a literal integer or a `const int` variable reference.
SKSL_INT intValue;
if (!ConstantFolder::GetConstantInt(*caseValue, &intValue)) {
- context.fErrors->error(caseValue->fOffset, "case value must be a constant integer");
+ context.fErrors->error(caseValue->fLine, "case value must be a constant integer");
return nullptr;
}
} else {
// The null case-expression corresponds to `default:`.
- caseOffset = offset;
+ caseLine = line;
}
- cases.push_back(std::make_unique<SwitchCase>(caseOffset, std::move(caseValue),
+ cases.push_back(std::make_unique<SwitchCase>(caseLine, std::move(caseValue),
std::move(caseStatements[i])));
}
@@ -211,21 +211,21 @@
duplicateCases.reverse();
for (const SwitchCase* sc : duplicateCases) {
if (sc->value() != nullptr) {
- context.fErrors->error(sc->fOffset,
+ context.fErrors->error(sc->fLine,
"duplicate case value '" + sc->value()->description() + "'");
} else {
- context.fErrors->error(sc->fOffset, "duplicate default case");
+ context.fErrors->error(sc->fLine, "duplicate default case");
}
}
return nullptr;
}
- return SwitchStatement::Make(context, offset, isStatic, std::move(value), std::move(cases),
+ return SwitchStatement::Make(context, line, isStatic, std::move(value), std::move(cases),
std::move(symbolTable));
}
std::unique_ptr<Statement> SwitchStatement::Make(const Context& context,
- int offset,
+ int line,
bool isStatic,
std::unique_ptr<Expression> value,
StatementArray cases,
@@ -284,7 +284,7 @@
// Report an error if this was a static switch and BlockForCase failed us.
if (isStatic && !context.fConfig->fSettings.fPermitInvalidStaticTests) {
- context.fErrors->error(value->fOffset,
+ context.fErrors->error(value->fLine,
"static switch contains non-static conditional exit");
return nullptr;
}
@@ -292,7 +292,7 @@
}
// The switch couldn't be optimized away; emit it normally.
- return std::make_unique<SwitchStatement>(offset, isStatic, std::move(value), std::move(cases),
+ return std::make_unique<SwitchStatement>(line, isStatic, std::move(value), std::move(cases),
std::move(symbolTable));
}
diff --git a/src/sksl/ir/SkSLSwitchStatement.h b/src/sksl/ir/SkSLSwitchStatement.h
index cd8ca0e..f1f3190 100644
--- a/src/sksl/ir/SkSLSwitchStatement.h
+++ b/src/sksl/ir/SkSLSwitchStatement.h
@@ -26,9 +26,9 @@
public:
static constexpr Kind kStatementKind = Kind::kSwitch;
- SwitchStatement(int offset, bool isStatic, std::unique_ptr<Expression> value,
+ SwitchStatement(int line, bool isStatic, std::unique_ptr<Expression> value,
StatementArray cases, std::shared_ptr<SymbolTable> symbols)
- : INHERITED(offset, kStatementKind)
+ : INHERITED(line, kStatementKind)
, fIsStatic(isStatic)
, fValue(std::move(value))
, fCases(std::move(cases))
@@ -38,7 +38,7 @@
// Coerces case values to the proper type and reports an error if cases are duplicated.
// Reports errors via the ErrorReporter.
static std::unique_ptr<Statement> Convert(const Context& context,
- int offset,
+ int line,
bool isStatic,
std::unique_ptr<Expression> value,
ExpressionArray caseValues,
@@ -48,7 +48,7 @@
// Create a `switch` statement with an array of SwitchCases. The array of SwitchCases must
// already contain non-overlapping, correctly-typed case values. Reports errors via ASSERT.
static std::unique_ptr<Statement> Make(const Context& context,
- int offset,
+ int line,
bool isStatic,
std::unique_ptr<Expression> value,
StatementArray cases,
diff --git a/src/sksl/ir/SkSLSwizzle.cpp b/src/sksl/ir/SkSLSwizzle.cpp
index 398c20e..605886c 100644
--- a/src/sksl/ir/SkSLSwizzle.cpp
+++ b/src/sksl/ir/SkSLSwizzle.cpp
@@ -221,7 +221,7 @@
// Wrap the new argument list in a constructor.
auto ctor = Constructor::Convert(context,
- base.fOffset,
+ base.fLine,
componentType.toCompound(context, swizzleSize, /*rows=*/1),
std::move(newArgs));
SkASSERT(ctor);
@@ -253,7 +253,7 @@
case 'q': components.push_back(SwizzleComponent::Q); break;
case 'B': components.push_back(SwizzleComponent::UB); break;
default:
- context.fErrors->error(base->fOffset,
+ context.fErrors->error(base->fLine,
String::printf("invalid swizzle component '%c'", field));
return nullptr;
}
@@ -270,22 +270,22 @@
std::unique_ptr<Expression> base,
ComponentArray inComponents) {
if (!validate_swizzle_domain(inComponents)) {
- context.fErrors->error(base->fOffset,
+ context.fErrors->error(base->fLine,
"invalid swizzle mask '" + mask_string(inComponents) + "'");
return nullptr;
}
- const int offset = base->fOffset;
+ const int line = base->fLine;
const Type& baseType = base->type();
if (!baseType.isVector() && !baseType.isScalar()) {
context.fErrors->error(
- offset, "cannot swizzle value of type '" + baseType.displayName() + "'");
+ line, "cannot swizzle value of type '" + baseType.displayName() + "'");
return nullptr;
}
if (inComponents.count() > 4) {
- context.fErrors->error(offset,
+ context.fErrors->error(line,
"too many components in swizzle mask '" + mask_string(inComponents) + "'");
return nullptr;
}
@@ -337,7 +337,7 @@
[[fallthrough]];
default:
// The swizzle component references a field that doesn't exist in the base type.
- context.fErrors->error(offset,
+ context.fErrors->error(line,
String::printf("invalid swizzle component '%c'",
mask_char(inComponents[i])));
return nullptr;
@@ -345,7 +345,7 @@
}
if (!foundXYZW) {
- context.fErrors->error(offset, "swizzle must refer to base expression");
+ context.fErrors->error(line, "swizzle must refer to base expression");
return nullptr;
}
@@ -389,8 +389,8 @@
if (constantZeroIdx == -1) {
// Synthesize a 'type(0)' argument at the end of the constructor.
constructorArgs.push_back(ConstructorScalarCast::Make(
- context, offset, *scalarType,
- Literal::MakeInt(context, offset, /*value=*/0)));
+ context, line, *scalarType,
+ Literal::MakeInt(context, line, /*value=*/0)));
constantZeroIdx = constantFieldIdx++;
}
swizzleComponents.push_back(constantZeroIdx);
@@ -399,8 +399,8 @@
if (constantOneIdx == -1) {
// Synthesize a 'type(1)' argument at the end of the constructor.
constructorArgs.push_back(ConstructorScalarCast::Make(
- context, offset, *scalarType,
- Literal::MakeInt(context, offset, /*value=*/1)));
+ context, line, *scalarType,
+ Literal::MakeInt(context, line, /*value=*/1)));
constantOneIdx = constantFieldIdx++;
}
swizzleComponents.push_back(constantOneIdx);
@@ -412,7 +412,7 @@
}
}
- expr = Constructor::Convert(context, offset,
+ expr = Constructor::Convert(context, line,
scalarType->toCompound(context, constantFieldIdx, /*rows=*/1),
std::move(constructorArgs));
if (!expr) {
@@ -441,8 +441,8 @@
// SkSL supports splatting a scalar via `scalar.xxxx`, but not all versions of GLSL allow this.
// Replace swizzles with equivalent splat constructors (`scalar.xxx` --> `half3(value)`).
if (exprType.isScalar()) {
- int offset = expr->fOffset;
- return ConstructorSplat::Make(context, offset,
+ int line = expr->fLine;
+ return ConstructorSplat::Make(context, line,
exprType.toCompound(context, components.size(), /*rows=*/1),
std::move(expr));
}
@@ -485,7 +485,7 @@
if (value->is<ConstructorSplat>()) {
const ConstructorSplat& splat = value->as<ConstructorSplat>();
return ConstructorSplat::Make(
- context, splat.fOffset,
+ context, splat.fLine,
splat.type().componentType().toCompound(context, components.size(), /*rows=*/1),
splat.argument()->clone());
}
diff --git a/src/sksl/ir/SkSLSwizzle.h b/src/sksl/ir/SkSLSwizzle.h
index 107c420..a187a61 100644
--- a/src/sksl/ir/SkSLSwizzle.h
+++ b/src/sksl/ir/SkSLSwizzle.h
@@ -25,7 +25,7 @@
Swizzle(const Context& context, std::unique_ptr<Expression> base,
const ComponentArray& components)
- : INHERITED(base->fOffset, kExpressionKind,
+ : INHERITED(base->fLine, kExpressionKind,
&base->type().componentType().toCompound(context, components.size(), 1))
, fBase(std::move(base))
, fComponents(components) {
@@ -80,7 +80,7 @@
private:
Swizzle(const Type* type, std::unique_ptr<Expression> base, const ComponentArray& components)
- : INHERITED(base->fOffset, kExpressionKind, type)
+ : INHERITED(base->fLine, kExpressionKind, type)
, fBase(std::move(base))
, fComponents(components) {
SkASSERT(this->components().size() >= 1 && this->components().size() <= 4);
diff --git a/src/sksl/ir/SkSLSymbolAlias.h b/src/sksl/ir/SkSLSymbolAlias.h
index 39d2a32..21e139b 100644
--- a/src/sksl/ir/SkSLSymbolAlias.h
+++ b/src/sksl/ir/SkSLSymbolAlias.h
@@ -19,8 +19,8 @@
public:
static constexpr Kind kSymbolKind = Kind::kSymbolAlias;
- SymbolAlias(int offset, skstd::string_view name, const Symbol* origSymbol)
- : INHERITED(offset, kSymbolKind, name)
+ SymbolAlias(int line, skstd::string_view name, const Symbol* origSymbol)
+ : INHERITED(line, kSymbolKind, name)
, fOrigSymbol(origSymbol) {}
const Symbol* origSymbol() const {
diff --git a/src/sksl/ir/SkSLSymbolTable.cpp b/src/sksl/ir/SkSLSymbolTable.cpp
index fecaec1..8009b09 100644
--- a/src/sksl/ir/SkSLSymbolTable.cpp
+++ b/src/sksl/ir/SkSLSymbolTable.cpp
@@ -89,7 +89,7 @@
}
void SymbolTable::addAlias(skstd::string_view name, const Symbol* symbol) {
- this->add(std::make_unique<SymbolAlias>(symbol->fOffset, name, symbol));
+ this->add(std::make_unique<SymbolAlias>(symbol->fLine, name, symbol));
}
void SymbolTable::addWithoutOwnership(const Symbol* symbol) {
@@ -102,7 +102,7 @@
}
if (!symbol->is<FunctionDeclaration>()) {
- fContext.fErrors->error(symbol->fOffset, "symbol '" + name + "' was already defined");
+ fContext.fErrors->error(symbol->fLine, "symbol '" + name + "' was already defined");
return;
}
diff --git a/src/sksl/ir/SkSLTernaryExpression.cpp b/src/sksl/ir/SkSLTernaryExpression.cpp
index 602a66a..6cbdc88 100644
--- a/src/sksl/ir/SkSLTernaryExpression.cpp
+++ b/src/sksl/ir/SkSLTernaryExpression.cpp
@@ -24,7 +24,7 @@
if (!test || !ifTrue || !ifFalse) {
return nullptr;
}
- int offset = test->fOffset;
+ int line = test->fLine;
const Type* trueType;
const Type* falseType;
const Type* resultType;
@@ -32,19 +32,19 @@
if (!equalityOp.determineBinaryType(context, ifTrue->type(), ifFalse->type(),
&trueType, &falseType, &resultType) ||
(*trueType != *falseType)) {
- context.fErrors->error(offset, "ternary operator result mismatch: '" +
- ifTrue->type().displayName() + "', '" +
- ifFalse->type().displayName() + "'");
+ context.fErrors->error(line, "ternary operator result mismatch: '" +
+ ifTrue->type().displayName() + "', '" +
+ ifFalse->type().displayName() + "'");
return nullptr;
}
if (trueType->componentType().isOpaque()) {
- context.fErrors->error(offset, "ternary expression of opaque type '" +
- trueType->displayName() + "' not allowed");
+ context.fErrors->error(line, "ternary expression of opaque type '" +
+ trueType->displayName() + "' not allowed");
return nullptr;
}
if (context.fConfig->strictES2Mode() && trueType->isOrContainsArray()) {
- context.fErrors->error(offset, "ternary operator result may not be an array (or struct "
- "containing an array)");
+ context.fErrors->error(line, "ternary operator result may not be an array (or struct "
+ "containing an array)");
return nullptr;
}
ifTrue = trueType->coerceExpression(std::move(ifTrue), context);
@@ -75,8 +75,8 @@
}
}
- return std::make_unique<TernaryExpression>(test->fOffset, std::move(test),
- std::move(ifTrue), std::move(ifFalse));
+ return std::make_unique<TernaryExpression>(test->fLine, std::move(test), std::move(ifTrue),
+ std::move(ifFalse));
}
} // namespace SkSL
diff --git a/src/sksl/ir/SkSLTernaryExpression.h b/src/sksl/ir/SkSLTernaryExpression.h
index ae104e6..4988705 100644
--- a/src/sksl/ir/SkSLTernaryExpression.h
+++ b/src/sksl/ir/SkSLTernaryExpression.h
@@ -19,9 +19,9 @@
public:
static constexpr Kind kExpressionKind = Kind::kTernary;
- TernaryExpression(int offset, std::unique_ptr<Expression> test,
+ TernaryExpression(int line, std::unique_ptr<Expression> test,
std::unique_ptr<Expression> ifTrue, std::unique_ptr<Expression> ifFalse)
- : INHERITED(offset, kExpressionKind, &ifTrue->type())
+ : INHERITED(line, kExpressionKind, &ifTrue->type())
, fTest(std::move(test))
, fIfTrue(std::move(ifTrue))
, fIfFalse(std::move(ifFalse)) {
@@ -76,7 +76,7 @@
}
std::unique_ptr<Expression> clone() const override {
- return std::make_unique<TernaryExpression>(fOffset, this->test()->clone(),
+ return std::make_unique<TernaryExpression>(fLine, this->test()->clone(),
this->ifTrue()->clone(),
this->ifFalse()->clone());
}
diff --git a/src/sksl/ir/SkSLType.cpp b/src/sksl/ir/SkSLType.cpp
index 8f4277a..05eb143 100644
--- a/src/sksl/ir/SkSLType.cpp
+++ b/src/sksl/ir/SkSLType.cpp
@@ -309,8 +309,8 @@
public:
static constexpr TypeKind kTypeKind = TypeKind::kStruct;
- StructType(int offset, skstd::string_view name, std::vector<Field> fields)
- : INHERITED(std::move(name), "S", kTypeKind, offset)
+ StructType(int line, skstd::string_view name, std::vector<Field> fields)
+ : INHERITED(std::move(name), "S", kTypeKind, line)
, fFields(std::move(fields)) {}
const std::vector<Field>& fields() const override {
@@ -417,9 +417,9 @@
}
-std::unique_ptr<Type> Type::MakeStructType(int offset, skstd::string_view name,
+std::unique_ptr<Type> Type::MakeStructType(int line, skstd::string_view name,
std::vector<Field> fields) {
- return std::make_unique<StructType>(offset, name, std::move(fields));
+ return std::make_unique<StructType>(line, name, std::move(fields));
}
std::unique_ptr<Type> Type::MakeTextureType(const char* name, SpvDim_ dimensions, bool isDepth,
@@ -474,7 +474,7 @@
const Type* Type::applyPrecisionQualifiers(const Context& context,
const Modifiers& modifiers,
SymbolTable* symbols,
- int offset) const {
+ int line) const {
// SkSL doesn't support low precision, so `lowp` is interpreted as medium precision.
bool highp = modifiers.fFlags & Modifiers::kHighp_Flag;
bool mediump = modifiers.fFlags & Modifiers::kMediump_Flag;
@@ -488,12 +488,12 @@
if (!ProgramConfig::IsRuntimeEffect(context.fConfig->fKind)) {
// We want to discourage precision modifiers internally. Instead, use the type that
// corresponds to the precision you need. (e.g. half vs float, short vs int)
- context.fErrors->error(offset, "precision qualifiers are not allowed");
+ context.fErrors->error(line, "precision qualifiers are not allowed");
return nullptr;
}
if ((int(lowp) + int(mediump) + int(highp)) != 1) {
- context.fErrors->error(offset, "only one precision qualifier can be used");
+ context.fErrors->error(line, "only one precision qualifier can be used");
return nullptr;
}
@@ -532,8 +532,8 @@
}
}
- context.fErrors->error(offset, "type '" + this->displayName() +
- "' does not support precision qualifiers");
+ context.fErrors->error(line, "type '" + this->displayName() +
+ "' does not support precision qualifiers");
return nullptr;
}
@@ -692,7 +692,7 @@
}
case TypeKind::kStruct: {
const String* name = symbolTable->takeOwnershipOfString(String(this->name()));
- return symbolTable->add(Type::MakeStructType(this->fOffset, *name, this->fields()));
+ return symbolTable->add(Type::MakeStructType(this->fLine, *name, this->fields()));
}
default:
SkDEBUGFAILF("don't know how to clone type '%s'", this->description().c_str());
@@ -705,13 +705,13 @@
if (!expr) {
return nullptr;
}
- const int offset = expr->fOffset;
+ const int line = expr->fLine;
if (expr->is<FunctionReference>() || expr->is<ExternalFunctionReference>()) {
- context.fErrors->error(offset, "expected '(' to begin function call");
+ context.fErrors->error(line, "expected '(' to begin function call");
return nullptr;
}
if (expr->is<TypeReference>()) {
- context.fErrors->error(offset, "expected '(' to begin constructor invocation");
+ context.fErrors->error(line, "expected '(' to begin constructor invocation");
return nullptr;
}
if (expr->type() == *this) {
@@ -720,21 +720,21 @@
const Program::Settings& settings = context.fConfig->fSettings;
if (!expr->coercionCost(*this).isPossible(settings.fAllowNarrowingConversions)) {
- context.fErrors->error(offset, "expected '" + this->displayName() + "', but found '" +
- expr->type().displayName() + "'");
+ context.fErrors->error(line, "expected '" + this->displayName() + "', but found '" +
+ expr->type().displayName() + "'");
return nullptr;
}
if (this->isScalar()) {
- return ConstructorScalarCast::Make(context, offset, *this, std::move(expr));
+ return ConstructorScalarCast::Make(context, line, *this, std::move(expr));
}
if (this->isVector() || this->isMatrix()) {
- return ConstructorCompoundCast::Make(context, offset, *this, std::move(expr));
+ return ConstructorCompoundCast::Make(context, line, *this, std::move(expr));
}
if (this->isArray()) {
- return ConstructorArrayCast::Make(context, offset, *this, std::move(expr));
+ return ConstructorArrayCast::Make(context, line, *this, std::move(expr));
}
- context.fErrors->error(offset, "cannot construct '" + this->displayName() + "'");
+ context.fErrors->error(line, "cannot construct '" + this->displayName() + "'");
return nullptr;
}
@@ -804,7 +804,7 @@
SKSL_INT value = subexpr->as<Literal>().intValue();
if (value < baseType.minimumValue() || value > baseType.maximumValue()) {
// We found a value that can't fit in the type. Flag it as an error.
- context.fErrors->error(expr.fOffset,
+ context.fErrors->error(expr.fLine,
String("integer is out of range for type '") +
this->displayName().c_str() + "': " + to_string(value));
foundError = true;
@@ -823,29 +823,29 @@
return 0;
}
if (this->isArray()) {
- context.fErrors->error(size->fOffset, "multi-dimensional arrays are not supported");
+ context.fErrors->error(size->fLine, "multi-dimensional arrays are not supported");
return 0;
}
if (this->isVoid()) {
- context.fErrors->error(size->fOffset, "type 'void' may not be used in an array");
+ context.fErrors->error(size->fLine, "type 'void' may not be used in an array");
return 0;
}
if (this->isOpaque()) {
- context.fErrors->error(size->fOffset, "opaque type '" + this->name() +
- "' may not be used in an array");
+ context.fErrors->error(size->fLine, "opaque type '" + this->name() +
+ "' may not be used in an array");
return 0;
}
if (!size->isIntLiteral()) {
- context.fErrors->error(size->fOffset, "array size must be an integer");
+ context.fErrors->error(size->fLine, "array size must be an integer");
return 0;
}
SKSL_INT count = size->as<Literal>().intValue();
if (count <= 0) {
- context.fErrors->error(size->fOffset, "array size must be positive");
+ context.fErrors->error(size->fLine, "array size must be positive");
return 0;
}
if (!SkTFitsIn<int32_t>(count)) {
- context.fErrors->error(size->fOffset, "array size is too large");
+ context.fErrors->error(size->fLine, "array size is too large");
return 0;
}
return static_cast<int>(count);
diff --git a/src/sksl/ir/SkSLType.h b/src/sksl/ir/SkSLType.h
index bdc29f6..e161770 100644
--- a/src/sksl/ir/SkSLType.h
+++ b/src/sksl/ir/SkSLType.h
@@ -141,7 +141,7 @@
Type::TypeKind typeKind);
/** Creates a struct type with the given fields. */
- static std::unique_ptr<Type> MakeStructType(int offset, skstd::string_view name,
+ static std::unique_ptr<Type> MakeStructType(int line, skstd::string_view name,
std::vector<Field> fields);
/** Create a texture type. */
@@ -534,7 +534,7 @@
const Type* applyPrecisionQualifiers(const Context& context,
const Modifiers& modifiers,
SymbolTable* symbols,
- int offset) const;
+ int line) const;
/**
* Coerces the passed-in expression to this type. If the types are incompatible, reports an
@@ -553,8 +553,8 @@
SKSL_INT convertArraySize(const Context& context, std::unique_ptr<Expression> size) const;
protected:
- Type(skstd::string_view name, const char* abbrev, TypeKind kind, int offset = -1)
- : INHERITED(offset, kSymbolKind, name)
+ Type(skstd::string_view name, const char* abbrev, TypeKind kind, int line = -1)
+ : INHERITED(line, kSymbolKind, name)
, fTypeKind(kind) {
SkASSERT(strlen(abbrev) <= kMaxAbbrevLength);
strcpy(fAbbreviatedName, abbrev);
diff --git a/src/sksl/ir/SkSLTypeReference.h b/src/sksl/ir/SkSLTypeReference.h
index a4ea694..5bab7ed 100644
--- a/src/sksl/ir/SkSLTypeReference.h
+++ b/src/sksl/ir/SkSLTypeReference.h
@@ -21,8 +21,8 @@
public:
static constexpr Kind kExpressionKind = Kind::kTypeReference;
- TypeReference(const Context& context, int offset, const Type* value)
- : INHERITED(offset, kExpressionKind, context.fTypes.fInvalid.get())
+ TypeReference(const Context& context, int line, const Type* value)
+ : INHERITED(line, kExpressionKind, context.fTypes.fInvalid.get())
, fValue(*value) {}
const Type& value() const {
@@ -38,13 +38,12 @@
}
std::unique_ptr<Expression> clone() const override {
- return std::unique_ptr<Expression>(new TypeReference(fOffset, &this->value(),
- &this->type()));
+ return std::unique_ptr<Expression>(new TypeReference(fLine, &this->value(), &this->type()));
}
private:
- TypeReference(int offset, const Type* value, const Type* type)
- : INHERITED(offset, kExpressionKind, type)
+ TypeReference(int line, const Type* value, const Type* type)
+ : INHERITED(line, kExpressionKind, type)
, fValue(*value) {}
const Type& fValue;
diff --git a/src/sksl/ir/SkSLVarDeclarations.cpp b/src/sksl/ir/SkSLVarDeclarations.cpp
index f985fd7..537001d 100644
--- a/src/sksl/ir/SkSLVarDeclarations.cpp
+++ b/src/sksl/ir/SkSLVarDeclarations.cpp
@@ -39,22 +39,22 @@
std::unique_ptr<Expression> value) {
if (value) {
if (var->type().isOpaque()) {
- context.fErrors->error(value->fOffset, "opaque type '" + var->type().name() +
+ context.fErrors->error(value->fLine, "opaque type '" + var->type().name() +
"' cannot use initializer expressions");
return nullptr;
}
if (var->modifiers().fFlags & Modifiers::kIn_Flag) {
- context.fErrors->error(value->fOffset,
+ context.fErrors->error(value->fLine,
"'in' variables cannot use initializer expressions");
return nullptr;
}
if (var->modifiers().fFlags & Modifiers::kUniform_Flag) {
- context.fErrors->error(value->fOffset,
+ context.fErrors->error(value->fLine,
"'uniform' variables cannot use initializer expressions");
return nullptr;
}
if (var->storage() == Variable::Storage::kInterfaceBlock) {
- context.fErrors->error(value->fOffset,
+ context.fErrors->error(value->fLine,
"initializers are not permitted on interface block fields");
return nullptr;
}
@@ -65,25 +65,25 @@
}
if (var->modifiers().fFlags & Modifiers::kConst_Flag) {
if (!value) {
- context.fErrors->error(var->fOffset, "'const' variables must be initialized");
+ context.fErrors->error(var->fLine, "'const' variables must be initialized");
return nullptr;
}
if (!Analysis::IsConstantExpression(*value)) {
- context.fErrors->error(value->fOffset,
+ context.fErrors->error(value->fLine,
"'const' variable initializer must be a constant expression");
return nullptr;
}
}
if (var->storage() == Variable::Storage::kInterfaceBlock) {
if (var->type().isOpaque()) {
- context.fErrors->error(var->fOffset, "opaque type '" + var->type().name() +
+ context.fErrors->error(var->fLine, "opaque type '" + var->type().name() +
"' is not permitted in an interface block");
return nullptr;
}
}
if (var->storage() == Variable::Storage::kGlobal) {
if (value && !Analysis::IsConstantExpression(*value)) {
- context.fErrors->error(value->fOffset,
+ context.fErrors->error(value->fLine,
"global variable initializer must be a constant expression");
return nullptr;
}
diff --git a/src/sksl/ir/SkSLVarDeclarations.h b/src/sksl/ir/SkSLVarDeclarations.h
index 52ce919..8c32e57 100644
--- a/src/sksl/ir/SkSLVarDeclarations.h
+++ b/src/sksl/ir/SkSLVarDeclarations.h
@@ -32,7 +32,7 @@
const Type* baseType,
int arraySize,
std::unique_ptr<Expression> value)
- : INHERITED(var->fOffset, kStatementKind)
+ : INHERITED(var->fLine, kStatementKind)
, fVar(var)
, fBaseType(*baseType)
, fArraySize(arraySize)
@@ -106,7 +106,7 @@
static constexpr Kind kProgramElementKind = Kind::kGlobalVar;
GlobalVarDeclaration(std::unique_ptr<Statement> decl)
- : INHERITED(decl->fOffset, kProgramElementKind)
+ : INHERITED(decl->fLine, kProgramElementKind)
, fDeclaration(std::move(decl)) {
SkASSERT(this->declaration()->is<VarDeclaration>());
}
diff --git a/src/sksl/ir/SkSLVariable.cpp b/src/sksl/ir/SkSLVariable.cpp
index e74ec00..0179af9 100644
--- a/src/sksl/ir/SkSLVariable.cpp
+++ b/src/sksl/ir/SkSLVariable.cpp
@@ -48,7 +48,7 @@
// Create our new variable and add it to the symbol table.
ScratchVariable result;
- auto var = std::make_unique<Variable>(initialValue ? initialValue->fOffset : -1,
+ auto var = std::make_unique<Variable>(initialValue ? initialValue->fLine : -1,
context.fModifiersPool->add(Modifiers{}),
name->c_str(),
type,
diff --git a/src/sksl/ir/SkSLVariable.h b/src/sksl/ir/SkSLVariable.h
index 7c12cfd..bb84719 100644
--- a/src/sksl/ir/SkSLVariable.h
+++ b/src/sksl/ir/SkSLVariable.h
@@ -42,9 +42,9 @@
static constexpr Kind kSymbolKind = Kind::kVariable;
- Variable(int offset, const Modifiers* modifiers, skstd::string_view name, const Type* type,
+ Variable(int line, const Modifiers* modifiers, skstd::string_view name, const Type* type,
bool builtin, Storage storage)
- : INHERITED(offset, kSymbolKind, name, type)
+ : INHERITED(line, kSymbolKind, name, type)
, fModifiers(modifiers)
, fStorage(storage)
, fBuiltin(builtin) {}
diff --git a/src/sksl/ir/SkSLVariableReference.cpp b/src/sksl/ir/SkSLVariableReference.cpp
index 411452c..fce77f8 100644
--- a/src/sksl/ir/SkSLVariableReference.cpp
+++ b/src/sksl/ir/SkSLVariableReference.cpp
@@ -14,8 +14,8 @@
namespace SkSL {
-VariableReference::VariableReference(int offset, const Variable* variable, RefKind refKind)
- : INHERITED(offset, kExpressionKind, &variable->type())
+VariableReference::VariableReference(int line, const Variable* variable, RefKind refKind)
+ : INHERITED(line, kExpressionKind, &variable->type())
, fVariable(variable)
, fRefKind(refKind) {
SkASSERT(this->variable());
diff --git a/src/sksl/ir/SkSLVariableReference.h b/src/sksl/ir/SkSLVariableReference.h
index e5a6d80..a88ea96 100644
--- a/src/sksl/ir/SkSLVariableReference.h
+++ b/src/sksl/ir/SkSLVariableReference.h
@@ -37,15 +37,15 @@
static constexpr Kind kExpressionKind = Kind::kVariableReference;
- VariableReference(int offset, const Variable* variable, RefKind refKind);
+ VariableReference(int line, const Variable* variable, RefKind refKind);
// Creates a VariableReference. There isn't much in the way of error-checking or optimization
// opportunities here.
- static std::unique_ptr<Expression> Make(int offset,
+ static std::unique_ptr<Expression> Make(int line,
const Variable* variable,
RefKind refKind = RefKind::kRead) {
SkASSERT(variable);
- return std::make_unique<VariableReference>(offset, variable, refKind);
+ return std::make_unique<VariableReference>(line, variable, refKind);
}
VariableReference(const VariableReference&) = delete;
@@ -67,7 +67,7 @@
bool isConstantOrUniform() const override;
std::unique_ptr<Expression> clone() const override {
- return std::make_unique<VariableReference>(fOffset, this->variable(), this->refKind());
+ return std::make_unique<VariableReference>(fLine, this->variable(), this->refKind());
}
String description() const override;
diff --git a/tests/SkSLDSLTest.cpp b/tests/SkSLDSLTest.cpp
index af640a1..3450e46 100644
--- a/tests/SkSLDSLTest.cpp
+++ b/tests/SkSLDSLTest.cpp
@@ -1249,14 +1249,14 @@
DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLCall, r, ctxInfo) {
AutoDSLContext context(ctxInfo.directContext()->priv().getGpu());
{
- DSLExpression sqrt(DSLWriter::IRGenerator().convertIdentifier(/*offset=*/-1, "sqrt"));
+ DSLExpression sqrt(DSLWriter::IRGenerator().convertIdentifier(/*line=*/-1, "sqrt"));
SkTArray<DSLWrapper<DSLExpression>> args;
args.emplace_back(16);
EXPECT_EQUAL(sqrt(std::move(args)), "4.0"); // sqrt(16) gets optimized to 4
}
{
- DSLExpression pow(DSLWriter::IRGenerator().convertIdentifier(/*offset=*/-1, "pow"));
+ DSLExpression pow(DSLWriter::IRGenerator().convertIdentifier(/*line=*/-1, "pow"));
DSLVar a(kFloat_Type, "a");
DSLVar b(kFloat_Type, "b");
SkTArray<DSLWrapper<DSLExpression>> args;