Added module support to DSLParser
This removes SkSLParser from the last code path where it was still in
use, now instead using DSLParser for module loading.
Change-Id: I3858729ee2949e2900f0bcfc3f622aa4b5ef3d5d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452719
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp
index 67f1958..c0486d0 100644
--- a/src/sksl/SkSLCompiler.cpp
+++ b/src/sksl/SkSLCompiler.cpp
@@ -316,23 +316,13 @@
printf("error reading %s\n", data.fPath);
abort();
}
- const String* source = fRootModule.fSymbols->takeOwnershipOfString(std::move(text));
-
ParsedModule baseModule = {base, /*fIntrinsics=*/nullptr};
- std::vector<std::unique_ptr<ProgramElement>> elements;
- std::vector<const ProgramElement*> sharedElements;
- dsl::StartModule(this, kind, settings, baseModule);
- dsl::SetErrorReporter(&this->errorReporter());
- AutoSource as(this, source->c_str());
- IRGenerator::IRBundle ir = fIRGenerator->convertProgram(baseModule, /*isBuiltinCode=*/true,
- *source);
- SkASSERT(ir.fSharedElements.empty());
- LoadedModule module = { kind, std::move(ir.fSymbolTable), std::move(ir.fElements) };
+ LoadedModule result = DSLParser(this, settings, kind,
+ std::move(text)).moduleInheritingFrom(std::move(baseModule));
if (this->errorCount()) {
printf("Unexpected errors: %s\n", this->fErrorText.c_str());
SkDEBUGFAILF("%s %s\n", data.fPath, this->fErrorText.c_str());
}
- dsl::End();
#else
ProgramConfig config;
config.fKind = kind;
@@ -340,10 +330,10 @@
AutoProgramConfig autoConfig(fContext, &config);
SkASSERT(data.fData && (data.fSize != 0));
Rehydrator rehydrator(fContext.get(), base, data.fData, data.fSize);
- LoadedModule module = { kind, rehydrator.symbolTable(), rehydrator.elements() };
+ LoadedModule result = { kind, rehydrator.symbolTable(), rehydrator.elements() };
#endif
- return module;
+ return result;
}
ParsedModule Compiler::parseModule(ProgramKind kind, ModuleData data, const ParsedModule& base) {
@@ -449,7 +439,7 @@
#if SKSL_DSL_PARSER
settings.fDSLMangling = false;
- return DSLParser(this, settings, kind, text).program();
+ return DSLParser(this, settings, kind, std::move(text)).program();
#else
auto textPtr = std::make_unique<String>(std::move(text));
AutoSource as(this, textPtr->c_str());