Remove no-op versions of skstd::to_string.
The float/double versions of skstd::to_string produce better output than the standard version, so let's keep those. Other versions of to_string don't do anything at all now that SkSL::String no longer exists. (Previously they existed to convert the return type from std::string to SkSL::String.) We can just use the std::to_string functions directly. Change-Id: Ief513e474bd47ed97f1c13f4f64fb161f1654065 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/503832 Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: John Stiles <johnstiles@google.com> Auto-Submit: John Stiles <johnstiles@google.com>
This commit is contained in:
parent
9907a8637c
commit
2ad035378c
@ -37,15 +37,15 @@ bool FuzzSKSL2Pipeline(sk_sp<SkData> bytes) {
|
||||
void declareGlobal(const char* /*declaration*/) override {}
|
||||
|
||||
std::string sampleShader(int index, std::string coords) override {
|
||||
return "child_" + skstd::to_string(index) + ".eval(" + coords + ")";
|
||||
return "child_" + std::to_string(index) + ".eval(" + coords + ")";
|
||||
}
|
||||
|
||||
std::string sampleColorFilter(int index, std::string color) override {
|
||||
return "child_" + skstd::to_string(index) + ".eval(" + color + ")";
|
||||
return "child_" + std::to_string(index) + ".eval(" + color + ")";
|
||||
}
|
||||
|
||||
std::string sampleBlender(int index, std::string src, std::string dst) override {
|
||||
return "child_" + skstd::to_string(index) + ".eval(" + src + ", " + dst + ")";
|
||||
return "child_" + std::to_string(index) + ".eval(" + src + ", " + dst + ")";
|
||||
}
|
||||
|
||||
std::string toLinearSrgb(std::string color) override { return color; }
|
||||
|
@ -71,26 +71,26 @@ struct Layout {
|
||||
return ", ";
|
||||
}};
|
||||
if (fLocation >= 0) {
|
||||
result += separator() + "location = " + skstd::to_string(fLocation);
|
||||
result += separator() + "location = " + std::to_string(fLocation);
|
||||
}
|
||||
if (fOffset >= 0) {
|
||||
result += separator() + "offset = " + skstd::to_string(fOffset);
|
||||
result += separator() + "offset = " + std::to_string(fOffset);
|
||||
}
|
||||
if (fBinding >= 0) {
|
||||
result += separator() + "binding = " + skstd::to_string(fBinding);
|
||||
result += separator() + "binding = " + std::to_string(fBinding);
|
||||
}
|
||||
if (fIndex >= 0) {
|
||||
result += separator() + "index = " + skstd::to_string(fIndex);
|
||||
result += separator() + "index = " + std::to_string(fIndex);
|
||||
}
|
||||
if (fSet >= 0) {
|
||||
result += separator() + "set = " + skstd::to_string(fSet);
|
||||
result += separator() + "set = " + std::to_string(fSet);
|
||||
}
|
||||
if (fBuiltin >= 0) {
|
||||
result += separator() + "builtin = " + skstd::to_string(fBuiltin);
|
||||
result += separator() + "builtin = " + std::to_string(fBuiltin);
|
||||
}
|
||||
if (fInputAttachmentIndex >= 0) {
|
||||
result += separator() + "input_attachment_index = " +
|
||||
skstd::to_string(fInputAttachmentIndex);
|
||||
std::to_string(fInputAttachmentIndex);
|
||||
}
|
||||
if (fFlags & kOriginUpperLeft_Flag) {
|
||||
result += separator() + "origin_upper_left";
|
||||
|
@ -34,14 +34,10 @@ void vappendf(std::string* str, const char* fmt, va_list va);
|
||||
|
||||
namespace skstd {
|
||||
|
||||
// For most types, pass-through to std::to_string as-is.
|
||||
template <typename T> std::string to_string(T value) {
|
||||
return std::to_string(value);
|
||||
}
|
||||
|
||||
// We customize the output from to_string(float|double) slightly.
|
||||
template <> std::string to_string(float value);
|
||||
template <> std::string to_string(double value);
|
||||
// We use a custom to_string(float|double) which ignores locale settings and writes `1.0` instead
|
||||
// of `1.00000`.
|
||||
std::string to_string(float value);
|
||||
std::string to_string(double value);
|
||||
|
||||
} // namespace skstd
|
||||
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
size_t slots = type->slotCount();
|
||||
for (size_t i = 0; i < slots; ++i) {
|
||||
value.append(isFloat ? skstd::to_string(floatData[i])
|
||||
: skstd::to_string(intData[i]));
|
||||
: std::to_string(intData[i]));
|
||||
value.append(",");
|
||||
}
|
||||
value.back() = ')';
|
||||
|
@ -741,7 +741,7 @@ bool Compiler::toMetal(Program& program, std::string* out) {
|
||||
void Compiler::handleError(std::string_view msg, PositionInfo pos) {
|
||||
fErrorText += "error: ";
|
||||
if (pos.line() >= 1) {
|
||||
fErrorText += skstd::to_string(pos.line()) + ": ";
|
||||
fErrorText += std::to_string(pos.line()) + ": ";
|
||||
}
|
||||
fErrorText += std::string(msg) + "\n";
|
||||
}
|
||||
@ -758,7 +758,7 @@ std::string Compiler::errorText(bool showCount) {
|
||||
void Compiler::writeErrorCount() {
|
||||
int count = this->errorCount();
|
||||
if (count) {
|
||||
fErrorText += skstd::to_string(count) + " error";
|
||||
fErrorText += std::to_string(count) + " error";
|
||||
if (count > 1) {
|
||||
fErrorText += "s";
|
||||
}
|
||||
|
@ -483,17 +483,17 @@ ResultCode processCommand(const std::vector<std::string>& args) {
|
||||
}
|
||||
|
||||
std::string sampleShader(int index, std::string coords) override {
|
||||
return "child_" + skstd::to_string(index) + ".eval(" + coords + ")";
|
||||
return "child_" + std::to_string(index) + ".eval(" + coords + ")";
|
||||
}
|
||||
|
||||
std::string sampleColorFilter(int index, std::string color) override {
|
||||
return "child_" + skstd::to_string(index) + ".eval(" + color + ")";
|
||||
return "child_" + std::to_string(index) + ".eval(" + color + ")";
|
||||
}
|
||||
|
||||
std::string sampleBlender(int index,
|
||||
std::string src,
|
||||
std::string dst) override {
|
||||
return "child_" + skstd::to_string(index) + ".eval(" + src + ", " +
|
||||
return "child_" + std::to_string(index) + ".eval(" + src + ", " +
|
||||
dst + ")";
|
||||
}
|
||||
|
||||
|
@ -15,12 +15,10 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
template <>
|
||||
std::string skstd::to_string(float value) {
|
||||
return skstd::to_string((double)value);
|
||||
}
|
||||
|
||||
template <>
|
||||
std::string skstd::to_string(double value) {
|
||||
std::stringstream buffer;
|
||||
buffer.imbue(std::locale::classic());
|
||||
|
@ -100,7 +100,7 @@ std::string GLSLCodeGenerator::getTypeName(const Type& raw) {
|
||||
else {
|
||||
SK_ABORT("unsupported vector type");
|
||||
}
|
||||
result += skstd::to_string(type.columns());
|
||||
result += std::to_string(type.columns());
|
||||
return result;
|
||||
}
|
||||
case Type::TypeKind::kMatrix: {
|
||||
@ -113,10 +113,10 @@ std::string GLSLCodeGenerator::getTypeName(const Type& raw) {
|
||||
else {
|
||||
SK_ABORT("unsupported matrix type");
|
||||
}
|
||||
result += skstd::to_string(type.columns());
|
||||
result += std::to_string(type.columns());
|
||||
if (type.columns() != type.rows()) {
|
||||
result += "x";
|
||||
result += skstd::to_string(type.rows());
|
||||
result += std::to_string(type.rows());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -158,7 +158,7 @@ void GLSLCodeGenerator::writeStructDefinition(const StructDefinition& s) {
|
||||
this->write(" ");
|
||||
this->write(f.fName);
|
||||
if (f.fType->isArray()) {
|
||||
this->write("[" + skstd::to_string(f.fType->columns()) + "]");
|
||||
this->write("[" + std::to_string(f.fType->columns()) + "]");
|
||||
}
|
||||
this->writeLine(";");
|
||||
}
|
||||
@ -238,8 +238,8 @@ static bool is_abs(Expression& expr) {
|
||||
// Tegra3 compiler bug.
|
||||
void GLSLCodeGenerator::writeMinAbsHack(Expression& absExpr, Expression& otherExpr) {
|
||||
SkASSERT(!this->caps().canUseMinAndAbsTogether());
|
||||
std::string tmpVar1 = "minAbsHackVar" + skstd::to_string(fVarCount++);
|
||||
std::string tmpVar2 = "minAbsHackVar" + skstd::to_string(fVarCount++);
|
||||
std::string tmpVar1 = "minAbsHackVar" + std::to_string(fVarCount++);
|
||||
std::string tmpVar2 = "minAbsHackVar" + std::to_string(fVarCount++);
|
||||
this->fFunctionHeader += std::string(" ") + this->getTypePrecision(absExpr.type()) +
|
||||
this->getTypeName(absExpr.type()) + " " + tmpVar1 + ";\n";
|
||||
this->fFunctionHeader += std::string(" ") + this->getTypePrecision(otherExpr.type()) +
|
||||
@ -413,8 +413,7 @@ void GLSLCodeGenerator::writeInverseHack(const Expression& mat) {
|
||||
|
||||
void GLSLCodeGenerator::writeTransposeHack(const Expression& mat) {
|
||||
const Type& type = mat.type();
|
||||
std::string name = "transpose" + skstd::to_string(type.columns()) +
|
||||
skstd::to_string(type.rows());
|
||||
std::string name = "transpose" + std::to_string(type.columns()) + std::to_string(type.rows());
|
||||
if (fWrittenIntrinsics.find(name) == fWrittenIntrinsics.end()) {
|
||||
fWrittenIntrinsics.insert(name);
|
||||
std::string typeName = this->getTypeName(type);
|
||||
@ -428,8 +427,8 @@ void GLSLCodeGenerator::writeTransposeHack(const Expression& mat) {
|
||||
for (int row = 0; row < type.rows(); ++row) {
|
||||
for (int column = 0; column < type.columns(); ++column) {
|
||||
fExtraFunctions.writeText(separator);
|
||||
fExtraFunctions.writeText(("m[" + skstd::to_string(column) + "][" +
|
||||
skstd::to_string(row) + "]").c_str());
|
||||
fExtraFunctions.writeText(("m[" + std::to_string(column) + "][" +
|
||||
std::to_string(row) + "]").c_str());
|
||||
separator = ", ";
|
||||
}
|
||||
}
|
||||
@ -861,8 +860,8 @@ void GLSLCodeGenerator::writeMatrixComparisonWorkaround(const BinaryExpression&
|
||||
SkASSERT(left.type().isMatrix());
|
||||
SkASSERT(right.type().isMatrix());
|
||||
|
||||
std::string tempMatrix1 = "_tempMatrix" + skstd::to_string(fVarCount++);
|
||||
std::string tempMatrix2 = "_tempMatrix" + skstd::to_string(fVarCount++);
|
||||
std::string tempMatrix1 = "_tempMatrix" + std::to_string(fVarCount++);
|
||||
std::string tempMatrix2 = "_tempMatrix" + std::to_string(fVarCount++);
|
||||
|
||||
this->fFunctionHeader += std::string(" ") + this->getTypePrecision(left.type()) +
|
||||
this->getTypeName(left.type()) + " " + tempMatrix1 + ";\n " +
|
||||
@ -995,11 +994,11 @@ void GLSLCodeGenerator::writeLiteral(const Literal& l) {
|
||||
}
|
||||
if (type.isInteger()) {
|
||||
if (type.matches(*fContext.fTypes.fUInt)) {
|
||||
this->write(skstd::to_string(l.intValue() & 0xffffffff) + "u");
|
||||
this->write(std::to_string(l.intValue() & 0xffffffff) + "u");
|
||||
} else if (type.matches(*fContext.fTypes.fUShort)) {
|
||||
this->write(skstd::to_string(l.intValue() & 0xffff) + "u");
|
||||
this->write(std::to_string(l.intValue() & 0xffff) + "u");
|
||||
} else {
|
||||
this->write(skstd::to_string(l.intValue()));
|
||||
this->write(std::to_string(l.intValue()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1036,7 +1035,7 @@ void GLSLCodeGenerator::writeFunctionDeclaration(const FunctionDeclaration& f) {
|
||||
this->writeType(*type);
|
||||
this->write(" " + std::string(param->name()));
|
||||
for (int s : sizes) {
|
||||
this->write("[" + skstd::to_string(s) + "]");
|
||||
this->write("[" + std::to_string(s) + "]");
|
||||
}
|
||||
}
|
||||
this->write(")");
|
||||
@ -1141,7 +1140,7 @@ void GLSLCodeGenerator::writeInterfaceBlock(const InterfaceBlock& intf) {
|
||||
this->write(intf.instanceName());
|
||||
if (intf.arraySize() > 0) {
|
||||
this->write("[");
|
||||
this->write(skstd::to_string(intf.arraySize()));
|
||||
this->write(std::to_string(intf.arraySize()));
|
||||
this->write("]");
|
||||
}
|
||||
}
|
||||
@ -1195,7 +1194,7 @@ void GLSLCodeGenerator::writeVarDeclaration(const VarDeclaration& var, bool glob
|
||||
this->write(var.var().name());
|
||||
if (var.arraySize() > 0) {
|
||||
this->write("[");
|
||||
this->write(skstd::to_string(var.arraySize()));
|
||||
this->write(std::to_string(var.arraySize()));
|
||||
this->write("]");
|
||||
}
|
||||
if (var.value()) {
|
||||
@ -1355,7 +1354,7 @@ void GLSLCodeGenerator::writeDoStatement(const DoStatement& d) {
|
||||
// temp = true;
|
||||
// CODE;
|
||||
// }
|
||||
std::string tmpVar = "_tmpLoopSeenOnce" + skstd::to_string(fVarCount++);
|
||||
std::string tmpVar = "_tmpLoopSeenOnce" + std::to_string(fVarCount++);
|
||||
this->write("bool ");
|
||||
this->write(tmpVar);
|
||||
this->writeLine(" = false;");
|
||||
@ -1391,9 +1390,9 @@ void GLSLCodeGenerator::writeExpressionStatement(const ExpressionStatement& s) {
|
||||
|
||||
void GLSLCodeGenerator::writeSwitchStatement(const SwitchStatement& s) {
|
||||
if (this->caps().rewriteSwitchStatements()) {
|
||||
std::string fallthroughVar = "_tmpSwitchFallthrough" + skstd::to_string(fVarCount++);
|
||||
std::string valueVar = "_tmpSwitchValue" + skstd::to_string(fVarCount++);
|
||||
std::string loopVar = "_tmpSwitchLoop" + skstd::to_string(fVarCount++);
|
||||
std::string fallthroughVar = "_tmpSwitchFallthrough" + std::to_string(fVarCount++);
|
||||
std::string valueVar = "_tmpSwitchValue" + std::to_string(fVarCount++);
|
||||
std::string loopVar = "_tmpSwitchLoop" + std::to_string(fVarCount++);
|
||||
this->write("int ");
|
||||
this->write(valueVar);
|
||||
this->write(" = ");
|
||||
@ -1423,7 +1422,7 @@ void GLSLCodeGenerator::writeSwitchStatement(const SwitchStatement& s) {
|
||||
}
|
||||
this->write(valueVar);
|
||||
this->write(" == ");
|
||||
this->write(skstd::to_string(c.value()));
|
||||
this->write(std::to_string(c.value()));
|
||||
this->writeLine(")) {");
|
||||
fIndentation++;
|
||||
|
||||
@ -1469,7 +1468,7 @@ void GLSLCodeGenerator::writeSwitchStatement(const SwitchStatement& s) {
|
||||
this->writeLine("default:");
|
||||
} else {
|
||||
this->write("case ");
|
||||
this->write(skstd::to_string(c.value()));
|
||||
this->write(std::to_string(c.value()));
|
||||
this->writeLine(":");
|
||||
}
|
||||
if (!c.statement()->isEmpty()) {
|
||||
|
@ -101,11 +101,11 @@ std::string MetalCodeGenerator::typeName(const Type& type) {
|
||||
this->typeName(type.componentType()).c_str(), type.columns());
|
||||
|
||||
case Type::TypeKind::kVector:
|
||||
return this->typeName(type.componentType()) + skstd::to_string(type.columns());
|
||||
return this->typeName(type.componentType()) + std::to_string(type.columns());
|
||||
|
||||
case Type::TypeKind::kMatrix:
|
||||
return this->typeName(type.componentType()) + skstd::to_string(type.columns()) + "x" +
|
||||
skstd::to_string(type.rows());
|
||||
return this->typeName(type.componentType()) + std::to_string(type.columns()) + "x" +
|
||||
std::to_string(type.rows());
|
||||
|
||||
case Type::TypeKind::kSampler:
|
||||
return "texture2d<half>"; // FIXME - support other texture types
|
||||
@ -197,7 +197,7 @@ std::string MetalCodeGenerator::getOutParamHelper(const FunctionCall& call,
|
||||
AutoOutputStream outputToExtraFunctions(this, &fExtraFunctions, &fIndentation);
|
||||
const FunctionDeclaration& function = call.function();
|
||||
|
||||
std::string name = "_skOutParamHelper" + skstd::to_string(fSwizzleHelperCount++) +
|
||||
std::string name = "_skOutParamHelper" + std::to_string(fSwizzleHelperCount++) +
|
||||
"_" + function.mangledName();
|
||||
const char* separator = "";
|
||||
|
||||
@ -248,7 +248,7 @@ std::string MetalCodeGenerator::getOutParamHelper(const FunctionCall& call,
|
||||
}
|
||||
} else {
|
||||
this->write(" _var");
|
||||
this->write(skstd::to_string(index));
|
||||
this->write(std::to_string(index));
|
||||
}
|
||||
}
|
||||
this->writeLine(") {");
|
||||
@ -261,7 +261,7 @@ std::string MetalCodeGenerator::getOutParamHelper(const FunctionCall& call,
|
||||
// float3 _var2[ = outParam.zyx];
|
||||
this->writeType(arguments[index]->type());
|
||||
this->write(" _var");
|
||||
this->write(skstd::to_string(index));
|
||||
this->write(std::to_string(index));
|
||||
|
||||
const Variable* param = function.parameters()[index];
|
||||
if (param->modifiers().fFlags & Modifiers::kIn_Flag) {
|
||||
@ -291,7 +291,7 @@ std::string MetalCodeGenerator::getOutParamHelper(const FunctionCall& call,
|
||||
separator = ", ";
|
||||
|
||||
this->write("_var");
|
||||
this->write(skstd::to_string(index));
|
||||
this->write(std::to_string(index));
|
||||
}
|
||||
this->writeLine(");");
|
||||
|
||||
@ -304,7 +304,7 @@ std::string MetalCodeGenerator::getOutParamHelper(const FunctionCall& call,
|
||||
this->writeExpression(*arguments[index], Precedence::kAssignment);
|
||||
fIgnoreVariableReferenceModifiers = false;
|
||||
this->write(" = _var");
|
||||
this->write(skstd::to_string(index));
|
||||
this->write(std::to_string(index));
|
||||
this->writeLine(";");
|
||||
}
|
||||
|
||||
@ -511,7 +511,7 @@ matrix<T, C, R> outerProduct(const vec<T, R> a, const vec<T, C> b) {
|
||||
}
|
||||
|
||||
std::string MetalCodeGenerator::getTempVariable(const Type& type) {
|
||||
std::string tempVar = "_skTemp" + skstd::to_string(fVarCount++);
|
||||
std::string tempVar = "_skTemp" + std::to_string(fVarCount++);
|
||||
this->fFunctionHeader += " " + this->typeName(type) + " " + tempVar + ";\n";
|
||||
return tempVar;
|
||||
}
|
||||
@ -1739,13 +1739,13 @@ void MetalCodeGenerator::writeLiteral(const Literal& l) {
|
||||
}
|
||||
if (type.isInteger()) {
|
||||
if (type.matches(*fContext.fTypes.fUInt)) {
|
||||
this->write(skstd::to_string(l.intValue() & 0xffffffff));
|
||||
this->write(std::to_string(l.intValue() & 0xffffffff));
|
||||
this->write("u");
|
||||
} else if (type.matches(*fContext.fTypes.fUShort)) {
|
||||
this->write(skstd::to_string(l.intValue() & 0xffff));
|
||||
this->write(std::to_string(l.intValue() & 0xffff));
|
||||
this->write("u");
|
||||
} else {
|
||||
this->write(skstd::to_string(l.intValue()));
|
||||
this->write(std::to_string(l.intValue()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1847,7 +1847,7 @@ bool MetalCodeGenerator::writeFunctionDeclaration(const FunctionDeclaration& f)
|
||||
this->write("(Inputs _in [[stage_in]]");
|
||||
if (-1 != fUniformBuffer) {
|
||||
this->write(", constant Uniforms& _uniforms [[buffer(" +
|
||||
skstd::to_string(fUniformBuffer) + ")]]");
|
||||
std::to_string(fUniformBuffer) + ")]]");
|
||||
}
|
||||
for (const ProgramElement* e : fProgram.elements()) {
|
||||
if (e->is<GlobalVarDeclaration>()) {
|
||||
@ -1863,13 +1863,13 @@ bool MetalCodeGenerator::writeFunctionDeclaration(const FunctionDeclaration& f)
|
||||
this->write(", texture2d<half> ");
|
||||
this->writeName(var.var().name());
|
||||
this->write("[[texture(");
|
||||
this->write(skstd::to_string(binding));
|
||||
this->write(std::to_string(binding));
|
||||
this->write(")]]");
|
||||
this->write(", sampler ");
|
||||
this->writeName(var.var().name());
|
||||
this->write(SAMPLER_SUFFIX);
|
||||
this->write("[[sampler(");
|
||||
this->write(skstd::to_string(binding));
|
||||
this->write(std::to_string(binding));
|
||||
this->write(")]]");
|
||||
}
|
||||
} else if (e->is<InterfaceBlock>()) {
|
||||
@ -1882,7 +1882,7 @@ bool MetalCodeGenerator::writeFunctionDeclaration(const FunctionDeclaration& f)
|
||||
this->write("& " );
|
||||
this->write(fInterfaceBlockNameMap[&intf]);
|
||||
this->write(" [[buffer(");
|
||||
this->write(skstd::to_string(this->getUniformBinding(intf.variable().modifiers())));
|
||||
this->write(std::to_string(this->getUniformBinding(intf.variable().modifiers())));
|
||||
this->write(")]]");
|
||||
}
|
||||
}
|
||||
@ -2024,13 +2024,13 @@ void MetalCodeGenerator::writeInterfaceBlock(const InterfaceBlock& intf) {
|
||||
this->write(intf.instanceName());
|
||||
if (intf.arraySize() > 0) {
|
||||
this->write("[");
|
||||
this->write(skstd::to_string(intf.arraySize()));
|
||||
this->write(std::to_string(intf.arraySize()));
|
||||
this->write("]");
|
||||
}
|
||||
fInterfaceBlockNameMap[&intf] = intf.instanceName();
|
||||
} else {
|
||||
fInterfaceBlockNameMap[&intf] = *fProgram.fSymbols->takeOwnershipOfString(
|
||||
"_anonInterface" + skstd::to_string(fAnonInterfaceCount++));
|
||||
"_anonInterface" + std::to_string(fAnonInterfaceCount++));
|
||||
}
|
||||
this->writeLine(";");
|
||||
}
|
||||
@ -2051,13 +2051,13 @@ void MetalCodeGenerator::writeFields(const std::vector<Type::Field>& fields, int
|
||||
if (currentOffset > fieldOffset) {
|
||||
fContext.fErrors->error(parentLine,
|
||||
"offset of field '" + std::string(field.fName) +
|
||||
"' must be at least " + skstd::to_string(currentOffset));
|
||||
"' must be at least " + std::to_string(currentOffset));
|
||||
return;
|
||||
} else if (currentOffset < fieldOffset) {
|
||||
this->write("char pad");
|
||||
this->write(skstd::to_string(fPaddingCount++));
|
||||
this->write(std::to_string(fPaddingCount++));
|
||||
this->write("[");
|
||||
this->write(skstd::to_string(fieldOffset - currentOffset));
|
||||
this->write(std::to_string(fieldOffset - currentOffset));
|
||||
this->writeLine("];");
|
||||
currentOffset = fieldOffset;
|
||||
}
|
||||
@ -2065,7 +2065,7 @@ void MetalCodeGenerator::writeFields(const std::vector<Type::Field>& fields, int
|
||||
if (fieldOffset % alignment) {
|
||||
fContext.fErrors->error(parentLine,
|
||||
"offset of field '" + std::string(field.fName) +
|
||||
"' must be a multiple of " + skstd::to_string(alignment));
|
||||
"' must be a multiple of " + std::to_string(alignment));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2238,7 +2238,7 @@ void MetalCodeGenerator::writeSwitchStatement(const SwitchStatement& s) {
|
||||
this->writeLine("default:");
|
||||
} else {
|
||||
this->write("case ");
|
||||
this->write(skstd::to_string(c.value()));
|
||||
this->write(std::to_string(c.value()));
|
||||
this->writeLine(":");
|
||||
}
|
||||
if (!c.statement()->isEmpty()) {
|
||||
@ -2340,10 +2340,10 @@ void MetalCodeGenerator::writeInputStruct() {
|
||||
if (-1 != var.modifiers().fLayout.fLocation) {
|
||||
if (fProgram.fConfig->fKind == ProgramKind::kVertex) {
|
||||
this->write(" [[attribute(" +
|
||||
skstd::to_string(var.modifiers().fLayout.fLocation) + ")]]");
|
||||
std::to_string(var.modifiers().fLayout.fLocation) + ")]]");
|
||||
} else if (fProgram.fConfig->fKind == ProgramKind::kFragment) {
|
||||
this->write(" [[user(locn" +
|
||||
skstd::to_string(var.modifiers().fLayout.fLocation) + ")]]");
|
||||
std::to_string(var.modifiers().fLayout.fLocation) + ")]]");
|
||||
}
|
||||
}
|
||||
this->write(";\n");
|
||||
@ -2376,12 +2376,12 @@ void MetalCodeGenerator::writeOutputStruct() {
|
||||
fContext.fErrors->error(var.fLine,
|
||||
"Metal out variables must have 'layout(location=...)'");
|
||||
} else if (fProgram.fConfig->fKind == ProgramKind::kVertex) {
|
||||
this->write(" [[user(locn" + skstd::to_string(location) + ")]]");
|
||||
this->write(" [[user(locn" + std::to_string(location) + ")]]");
|
||||
} else if (fProgram.fConfig->fKind == ProgramKind::kFragment) {
|
||||
this->write(" [[color(" + skstd::to_string(location) + ")");
|
||||
this->write(" [[color(" + std::to_string(location) + ")");
|
||||
int colorIndex = var.modifiers().fLayout.fIndex;
|
||||
if (colorIndex) {
|
||||
this->write(", index(" + skstd::to_string(colorIndex) + ")");
|
||||
this->write(", index(" + std::to_string(colorIndex) + ")");
|
||||
}
|
||||
this->write("]]");
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ void PipelineStageCodeGenerator::writeSwitchStatement(const SwitchStatement& s)
|
||||
this->writeLine("default:");
|
||||
} else {
|
||||
this->write("case ");
|
||||
this->write(skstd::to_string(c.value()));
|
||||
this->write(std::to_string(c.value()));
|
||||
this->writeLine(":");
|
||||
}
|
||||
if (!c.statement()->isEmpty()) {
|
||||
@ -472,7 +472,7 @@ std::string PipelineStageCodeGenerator::typeName(const Type& raw) {
|
||||
// This is necessary so that name mangling on arrays-of-structs works properly.
|
||||
std::string arrayName = this->typeName(type.componentType());
|
||||
arrayName.push_back('[');
|
||||
arrayName += skstd::to_string(type.columns());
|
||||
arrayName += std::to_string(type.columns());
|
||||
arrayName.push_back(']');
|
||||
return arrayName;
|
||||
}
|
||||
@ -656,7 +656,7 @@ std::string PipelineStageCodeGenerator::typedVariable(const Type& type, std::str
|
||||
|
||||
std::string decl = this->typeName(baseType) + " " + std::string(name);
|
||||
if (type.isArray()) {
|
||||
decl += "[" + skstd::to_string(type.columns()) + "]";
|
||||
decl += "[" + std::to_string(type.columns()) + "]";
|
||||
}
|
||||
return decl;
|
||||
}
|
||||
|
@ -474,14 +474,13 @@ void SPIRVCodeGenerator::writeStruct(const Type& type, const MemoryLayout& memor
|
||||
const Layout& fieldLayout = field.fModifiers.fLayout;
|
||||
if (fieldLayout.fOffset >= 0) {
|
||||
if (fieldLayout.fOffset < (int) offset) {
|
||||
fContext.fErrors->error(type.fLine,
|
||||
"offset of field '" + std::string(field.fName) +
|
||||
"' must be at least " + skstd::to_string(offset));
|
||||
fContext.fErrors->error(type.fLine, "offset of field '" + std::string(field.fName) +
|
||||
"' must be at least " + std::to_string(offset));
|
||||
}
|
||||
if (fieldLayout.fOffset % alignment) {
|
||||
fContext.fErrors->error(type.fLine,
|
||||
"offset of field '" + std::string(field.fName) +
|
||||
"' must be a multiple of " + skstd::to_string(alignment));
|
||||
"' must be a multiple of " + std::to_string(alignment));
|
||||
}
|
||||
offset = fieldLayout.fOffset;
|
||||
} else {
|
||||
@ -562,14 +561,14 @@ SpvId SPIRVCodeGenerator::getType(const Type& rawType, const MemoryLayout& layou
|
||||
|
||||
std::string key(type->name());
|
||||
if (type->isStruct() || type->isArray()) {
|
||||
key += skstd::to_string(layout.fStd);
|
||||
key += std::to_string(layout.fStd);
|
||||
#ifdef SK_DEBUG
|
||||
SkASSERT(layout.fStd == MemoryLayout::Standard::k140_Standard ||
|
||||
layout.fStd == MemoryLayout::Standard::k430_Standard);
|
||||
MemoryLayout::Standard otherStd = layout.fStd == MemoryLayout::Standard::k140_Standard
|
||||
? MemoryLayout::Standard::k430_Standard
|
||||
: MemoryLayout::Standard::k140_Standard;
|
||||
std::string otherKey = type->displayName() + skstd::to_string(otherStd);
|
||||
std::string otherKey = type->displayName() + std::to_string(otherStd);
|
||||
SkASSERT(fTypeMap.find(otherKey) == fTypeMap.end());
|
||||
#endif
|
||||
}
|
||||
@ -677,19 +676,19 @@ SpvId SPIRVCodeGenerator::getType(const Type& rawType, const MemoryLayout& layou
|
||||
SpvId SPIRVCodeGenerator::getImageType(const Type& type) {
|
||||
SkASSERT(type.typeKind() == Type::TypeKind::kSampler);
|
||||
this->getType(type);
|
||||
std::string key = type.displayName() + skstd::to_string(fDefaultLayout.fStd);
|
||||
std::string key = type.displayName() + std::to_string(fDefaultLayout.fStd);
|
||||
SkASSERT(fImageTypeMap.find(key) != fImageTypeMap.end());
|
||||
return fImageTypeMap[key];
|
||||
}
|
||||
|
||||
SpvId SPIRVCodeGenerator::getFunctionType(const FunctionDeclaration& function) {
|
||||
std::string key = skstd::to_string(this->getType(function.returnType())) + "(";
|
||||
std::string key = std::to_string(this->getType(function.returnType())) + "(";
|
||||
std::string separator;
|
||||
const std::vector<const Variable*>& parameters = function.parameters();
|
||||
for (size_t i = 0; i < parameters.size(); i++) {
|
||||
key += separator;
|
||||
separator = ", ";
|
||||
key += skstd::to_string(this->getType(parameters[i]->type()));
|
||||
key += std::to_string(this->getType(parameters[i]->type()));
|
||||
}
|
||||
key += ")";
|
||||
auto entry = fTypeMap.find(key);
|
||||
@ -743,8 +742,8 @@ SpvId SPIRVCodeGenerator::getPointerType(const Type& type, SpvStorageClass_ stor
|
||||
SpvId SPIRVCodeGenerator::getPointerType(const Type& rawType, const MemoryLayout& layout,
|
||||
SpvStorageClass_ storageClass) {
|
||||
const Type& type = this->getActualType(rawType);
|
||||
std::string key = type.displayName() + "*" + skstd::to_string(layout.fStd) +
|
||||
skstd::to_string(storageClass);
|
||||
std::string key = type.displayName() + "*" + std::to_string(layout.fStd) +
|
||||
std::to_string(storageClass);
|
||||
auto entry = fTypeMap.find(key);
|
||||
if (entry == fTypeMap.end()) {
|
||||
SpvId result = this->nextId(nullptr);
|
||||
|
@ -584,7 +584,7 @@ void SkVMGenerator::addDebugSlotInfo(std::string varName,
|
||||
int nslots = type.columns();
|
||||
const Type& elemType = type.componentType();
|
||||
for (int slot = 0; slot < nslots; ++slot) {
|
||||
this->addDebugSlotInfo(varName + "[" + skstd::to_string(slot) + "]",
|
||||
this->addDebugSlotInfo(varName + "[" + std::to_string(slot) + "]",
|
||||
elemType, line, fnReturnValue);
|
||||
}
|
||||
break;
|
||||
|
@ -139,8 +139,8 @@ static std::unique_ptr<Expression> convert_compound_constructor(const Context& c
|
||||
|
||||
if (actual != expected) {
|
||||
context.fErrors->error(line, "invalid arguments to '" + type.displayName() +
|
||||
"' constructor (expected " + skstd::to_string(expected) +
|
||||
" scalars, but found " + skstd::to_string(actual) + ")");
|
||||
"' constructor (expected " + std::to_string(expected) +
|
||||
" scalars, but found " + std::to_string(actual) + ")");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ std::unique_ptr<Expression> ConstructorScalarCast::Convert(const Context& contex
|
||||
if (args.size() != 1) {
|
||||
context.fErrors->error(line, "invalid arguments to '" + type.displayName() +
|
||||
"' constructor, (expected exactly 1 argument, but found " +
|
||||
skstd::to_string(args.size()) + ")");
|
||||
std::to_string(args.size()) + ")");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -862,8 +862,8 @@ std::unique_ptr<Expression> FunctionCall::Convert(const Context& context,
|
||||
int count = f.callParameterCount();
|
||||
if (count != (int) arguments.size()) {
|
||||
context.fErrors->error(line,
|
||||
"external function expected " + skstd::to_string(count) +
|
||||
" arguments, but found " + skstd::to_string(arguments.size()));
|
||||
"external function expected " + std::to_string(count) +
|
||||
" arguments, but found " + std::to_string(arguments.size()));
|
||||
return nullptr;
|
||||
}
|
||||
static constexpr int PARAMETER_MAX = 16;
|
||||
@ -940,11 +940,11 @@ std::unique_ptr<Expression> FunctionCall::Convert(const Context& context,
|
||||
// Reject function calls with the wrong number of arguments.
|
||||
if (function.parameters().size() != arguments.size()) {
|
||||
std::string msg = "call to '" + std::string(function.name()) + "' expected " +
|
||||
skstd::to_string(function.parameters().size()) + " argument";
|
||||
std::to_string(function.parameters().size()) + " argument";
|
||||
if (function.parameters().size() != 1) {
|
||||
msg += "s";
|
||||
}
|
||||
msg += ", but found " + skstd::to_string(arguments.count());
|
||||
msg += ", but found " + std::to_string(arguments.count());
|
||||
context.fErrors->error(line, msg);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -344,7 +344,7 @@ static bool find_existing_declaration(const Context& context,
|
||||
}
|
||||
for (size_t i = 0; i < parameters.size(); i++) {
|
||||
if (parameters[i]->modifiers() != other->parameters()[i]->modifiers()) {
|
||||
errors.error(line, "modifiers on parameter " + skstd::to_string(i + 1) +
|
||||
errors.error(line, "modifiers on parameter " + std::to_string(i + 1) +
|
||||
" differ between declaration and definition");
|
||||
return false;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ static bool index_out_of_range(const Context& context, SKSL_INT index, const Exp
|
||||
return false;
|
||||
}
|
||||
|
||||
context.fErrors->error(base.fLine, "index " + skstd::to_string(index) + " out of range for '" +
|
||||
context.fErrors->error(base.fLine, "index " + std::to_string(index) + " out of range for '" +
|
||||
base.type().displayName() + "'");
|
||||
return true;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public:
|
||||
return skstd::to_string(this->floatValue());
|
||||
}
|
||||
if (this->type().isInteger()) {
|
||||
return skstd::to_string(this->intValue());
|
||||
return std::to_string(this->intValue());
|
||||
}
|
||||
SkASSERT(this->type().isBoolean());
|
||||
return fValue ? "true" : "false";
|
||||
|
@ -202,7 +202,7 @@ std::unique_ptr<Statement> SwitchStatement::Convert(const Context& context,
|
||||
context.fErrors->error(sc->fLine, "duplicate default case");
|
||||
} else {
|
||||
context.fErrors->error(sc->fLine, "duplicate case value '" +
|
||||
skstd::to_string(sc->value()) + "'");
|
||||
std::to_string(sc->value()) + "'");
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -956,7 +956,7 @@ bool Type::checkForOutOfRangeLiteral(const Context& context, double value, int l
|
||||
// We found a value that can't fit in the type. Flag it as an error.
|
||||
context.fErrors->error(line, "integer is out of range for type '" +
|
||||
this->displayName() + "': " +
|
||||
skstd::to_string((SKSL_INT)value));
|
||||
std::to_string((SKSL_INT)value));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user