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/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));