Merge pull request #3032 from mbechard/master

Improve naming in link validation
This commit is contained in:
Greg Fischer 2022-09-20 10:19:08 -06:00 committed by GitHub
commit b40f87f1d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -638,18 +638,18 @@ void TIntermediate::mergeBlockDefinitions(TInfoSink& infoSink, TIntermSymbol* bl
class TMergeBlockTraverser : public TIntermTraverser { class TMergeBlockTraverser : public TIntermTraverser {
public: public:
TMergeBlockTraverser(const TIntermSymbol* newSym) TMergeBlockTraverser(const TIntermSymbol* newSym)
: newSymbol(newSym), unitType(nullptr), unit(nullptr), memberIndexUpdates(nullptr) : newSymbol(newSym), newType(nullptr), unit(nullptr), memberIndexUpdates(nullptr)
{ {
} }
TMergeBlockTraverser(const TIntermSymbol* newSym, const glslang::TType* unitType, glslang::TIntermediate* unit, TMergeBlockTraverser(const TIntermSymbol* newSym, const glslang::TType* unitType, glslang::TIntermediate* unit,
const std::map<unsigned int, unsigned int>* memberIdxUpdates) const std::map<unsigned int, unsigned int>* memberIdxUpdates)
: TIntermTraverser(false, true), newSymbol(newSym), unitType(unitType), unit(unit), memberIndexUpdates(memberIdxUpdates) : TIntermTraverser(false, true), newSymbol(newSym), newType(unitType), unit(unit), memberIndexUpdates(memberIdxUpdates)
{ {
} }
virtual ~TMergeBlockTraverser() {} virtual ~TMergeBlockTraverser() {}
const TIntermSymbol* newSymbol; const TIntermSymbol* newSymbol;
const glslang::TType* unitType; // copy of original type const glslang::TType* newType; // shallow copy of the new type
glslang::TIntermediate* unit; // intermediate that is being updated glslang::TIntermediate* unit; // intermediate that is being updated
const std::map<unsigned int, unsigned int>* memberIndexUpdates; const std::map<unsigned int, unsigned int>* memberIndexUpdates;
@ -665,10 +665,10 @@ void TIntermediate::mergeBlockDefinitions(TInfoSink& infoSink, TIntermSymbol* bl
virtual bool visitBinary(TVisit, glslang::TIntermBinary* node) virtual bool visitBinary(TVisit, glslang::TIntermBinary* node)
{ {
if (!unit || !unitType || !memberIndexUpdates || memberIndexUpdates->empty()) if (!unit || !newType || !memberIndexUpdates || memberIndexUpdates->empty())
return true; return true;
if (node->getOp() == EOpIndexDirectStruct && node->getLeft()->getType() == *unitType) { if (node->getOp() == EOpIndexDirectStruct && node->getLeft()->getType() == *newType) {
// this is a dereference to a member of the block since the // this is a dereference to a member of the block since the
// member list changed, need to update this to point to the // member list changed, need to update this to point to the
// right index // right index
@ -696,9 +696,9 @@ void TIntermediate::mergeBlockDefinitions(TInfoSink& infoSink, TIntermSymbol* bl
// The 'unit' intermediate needs the block structures update, but also structure entry indices // The 'unit' intermediate needs the block structures update, but also structure entry indices
// may have changed from the old block to the new one that it was merged into, so update those // may have changed from the old block to the new one that it was merged into, so update those
// in 'visitBinary' // in 'visitBinary'
TType unitType; TType newType;
unitType.shallowCopy(unitBlock->getType()); newType.shallowCopy(block->getType());
TMergeBlockTraverser unitFinalLinkTraverser(block, &unitType, unit, &memberIndexUpdates); TMergeBlockTraverser unitFinalLinkTraverser(block, &newType, unit, &memberIndexUpdates);
unit->getTreeRoot()->traverse(&unitFinalLinkTraverser); unit->getTreeRoot()->traverse(&unitFinalLinkTraverser);
// update the member list // update the member list