Revert "Switch to the new SkSL lexer."
This reverts commit c576e93d174f3106e072a2f506bca3990b541265.
Reason for revert: ASAN failures
Original change's description:
> Switch to the new SkSL lexer.
>
> This completely replaces flex with a new in-house lexical analyzer generator,
> which we have done for performance and memory usage reasons. Flex requires us
> to copy strings every time we need the text of a token, whereas this new lexer
> allows us to handle strings as a (non-null-terminated) pointer and length
> everywhere, eliminating most string copies.
>
> Bug: skia:
> Change-Id: I2add26efc9e20cb699520e82abcf713af3968aca
> Reviewed-on: https://skia-review.googlesource.com/39780
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
TBR=bsalomon@google.com,ethannicholas@google.com
Change-Id: If27b750a5f696d06a6bcffed12fe9f0598e084a6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/44881
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/sksl/SkSLHCodeGenerator.cpp b/src/sksl/SkSLHCodeGenerator.cpp
index 482020a..50d2428 100644
--- a/src/sksl/SkSLHCodeGenerator.cpp
+++ b/src/sksl/SkSLHCodeGenerator.cpp
@@ -23,17 +23,17 @@
, fSectionAndParameterHelper(*program, *errors) {}
String HCodeGenerator::ParameterType(const Type& type) {
- if (type.name() == "float2") {
+ if (type.fName == "float2") {
return "SkPoint";
- } else if (type.name() == "int4") {
+ } else if (type.fName == "int4") {
return "SkIRect";
- } else if (type.name() == "float4") {
+ } else if (type.fName == "float4") {
return "SkRect";
- } else if (type.name() == "float4x4") {
+ } else if (type.fName == "float4x4") {
return "SkMatrix44";
} else if (type.kind() == Type::kSampler_Kind) {
return "sk_sp<GrTextureProxy>";
- } else if (type.name() == "colorSpaceXform") {
+ } else if (type.fName == "colorSpaceXform") {
return "sk_sp<GrColorSpaceXform>";
}
return type.name();
@@ -127,7 +127,7 @@
separator = "";
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
this->writef("%s%s %s", separator, ParameterType(param->fType).c_str(),
- String(param->fName).c_str());
+ param->fName.c_str());
separator = ", ";
}
this->writeSection(CONSTRUCTOR_PARAMS_SECTION, separator);
@@ -136,7 +136,7 @@
fFullName.c_str());
separator = "";
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
- this->writef("%s%s", separator, String(param->fName).c_str());
+ this->writef("%s%s", separator, param->fName.c_str());
separator = ", ";
}
this->writeExtraConstructorParams(separator);
@@ -148,7 +148,7 @@
void HCodeGenerator::failOnSection(const char* section, const char* msg) {
std::vector<const Section*> s = fSectionAndParameterHelper.getSections(section);
if (s.size()) {
- fErrors.error(s[0]->fOffset, String("@") + section + " " + msg);
+ fErrors.error(s[0]->fPosition, String("@") + section + " " + msg);
}
}
@@ -165,7 +165,7 @@
const char* separator = "";
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
this->writef("%s%s %s", separator, ParameterType(param->fType).c_str(),
- String(param->fName).c_str());
+ param->fName.c_str());
separator = ", ";
}
this->writeSection(CONSTRUCTOR_PARAMS_SECTION, separator);
@@ -177,8 +177,7 @@
this->writef(")");
this->writeSection(INITIALIZERS_SECTION, "\n , ");
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
- String nameString(param->fName);
- const char* name = nameString.c_str();
+ const char* name = param->fName.c_str();
if (param->fType.kind() == Type::kSampler_Kind) {
this->writef("\n , %s(std::move(%s)", FieldName(name).c_str(), name);
for (const Section* s : fSectionAndParameterHelper.getSections(
@@ -202,7 +201,7 @@
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
if (param->fType.kind() == Type::kSampler_Kind) {
this->writef(" this->addTextureSampler(&%s);\n",
- FieldName(String(param->fName).c_str()).c_str());
+ FieldName(param->fName.c_str()).c_str());
}
}
for (const Section* s : fSectionAndParameterHelper.getSections(COORD_TRANSFORM_SECTION)) {
@@ -217,8 +216,8 @@
void HCodeGenerator::writeFields() {
this->writeSection(FIELDS_SECTION);
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
- this->writef(" %s %s;\n", FieldType(param->fType).c_str(),
- FieldName(String(param->fName).c_str()).c_str());
+ const char* name = param->fName.c_str();
+ this->writef(" %s %s;\n", FieldType(param->fType).c_str(), FieldName(name).c_str());
}
for (const Section* s : fSectionAndParameterHelper.getSections(COORD_TRANSFORM_SECTION)) {
this->writef(" GrCoordTransform %sCoordTransform;\n",
@@ -246,8 +245,7 @@
if (param->fType.kind() == Type::kSampler_Kind) {
continue;
}
- String nameString(param->fName);
- const char* name = nameString.c_str();
+ const char* name = param->fName.c_str();
this->writef(" %s %s() const { return %s; }\n",
FieldType(param->fType).c_str(), name, FieldName(name).c_str());
}