Switched SymbolTable.fErrorReporter over to .fContext

Holding on to the ErrorReporter directly could leave it talking to the
wrong reporter if the context was updated.

Change-Id: I60a343f0c5d296c4e847bb8cf97ecce3136579f6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/442796
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
This commit is contained in:
Ethan Nicholas 2021-08-27 15:34:05 -04:00 committed by SkCQ
parent 8ff0394331
commit c7774a779f
6 changed files with 10 additions and 9 deletions

View File

@ -140,7 +140,7 @@ Compiler::~Compiler() {}
#define TYPE(t) fContext->fTypes.f ## t .get()
std::shared_ptr<SymbolTable> Compiler::makeRootSymbolTable() {
auto rootSymbolTable = std::make_shared<SymbolTable>(&this->errorReporter(), /*builtin=*/true);
auto rootSymbolTable = std::make_shared<SymbolTable>(*fContext, /*builtin=*/true);
const SkSL::Symbol* rootTypes[] = {
TYPE(Void),

View File

@ -552,7 +552,7 @@ std::shared_ptr<SymbolTable> Rehydrator::symbolTable(bool inherit) {
std::shared_ptr<SymbolTable> oldTable = fSymbolTable;
std::shared_ptr<SymbolTable> result =
inherit ? std::make_shared<SymbolTable>(fSymbolTable, /*builtin=*/true)
: std::make_shared<SymbolTable>(this->errorReporter(), /*builtin=*/true);
: std::make_shared<SymbolTable>(fContext, /*builtin=*/true);
fSymbolTable = result;
std::vector<const Symbol*> ownedSymbols;
ownedSymbols.reserve(ownedCount);

View File

@ -3527,7 +3527,7 @@ void SPIRVCodeGenerator::addRTFlipUniform(int offset) {
name,
/*instanceName=*/"",
/*arraySize=*/0,
std::make_shared<SymbolTable>(fContext.fErrors, /*builtin=*/false));
std::make_shared<SymbolTable>(fContext, /*builtin=*/false));
this->writeInterfaceBlock(intf, false);
}

View File

@ -137,7 +137,7 @@ public:
, fBoolFalse(0)
, fSetupFragPosition(false)
, fCurrentBlock(0)
, fSynthetics(fContext.fErrors, /*builtin=*/true) {
, fSynthetics(fContext, /*builtin=*/true) {
this->setupIntrinsics();
}

View File

@ -7,6 +7,7 @@
#include "src/sksl/ir/SkSLSymbolTable.h"
#include "src/sksl/SkSLContext.h"
#include "src/sksl/ir/SkSLSymbolAlias.h"
#include "src/sksl/ir/SkSLType.h"
#include "src/sksl/ir/SkSLUnresolvedFunction.h"
@ -101,7 +102,7 @@ void SymbolTable::addWithoutOwnership(const Symbol* symbol) {
}
if (!symbol->is<FunctionDeclaration>()) {
fErrorReporter.error(symbol->fOffset, "symbol '" + name + "' was already defined");
fContext.fErrors->error(symbol->fOffset, "symbol '" + name + "' was already defined");
return;
}

View File

@ -28,14 +28,14 @@ class FunctionDeclaration;
*/
class SymbolTable {
public:
SymbolTable(ErrorReporter* errorReporter, bool builtin)
SymbolTable(const Context& context, bool builtin)
: fBuiltin(builtin)
, fErrorReporter(*errorReporter) {}
, fContext(context) {}
SymbolTable(std::shared_ptr<SymbolTable> parent, bool builtin)
: fParent(parent)
, fBuiltin(builtin)
, fErrorReporter(parent->fErrorReporter) {}
, fContext(parent->fContext) {}
/**
* If the input is a built-in symbol table, returns a new empty symbol table as a child of the
@ -141,7 +141,7 @@ private:
std::vector<std::unique_ptr<IRNode>> fOwnedNodes;
std::forward_list<String> fOwnedStrings;
SkTHashMap<SymbolKey, const Symbol*, SymbolKey::Hash> fSymbols;
ErrorReporter& fErrorReporter;
const Context& fContext;
friend class Dehydrator;
};